Skip to content

Commit

Permalink
fix: move the style to correct place
Browse files Browse the repository at this point in the history
  • Loading branch information
darkskygit committed Jul 31, 2024
1 parent dbb6109 commit c7923e3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
useLiveData,
useService,
} from '@toeverything/infra';
import clsx from 'clsx';
import { useEffect, useState } from 'react';

import { ToolContainer } from '../../workspace';
Expand All @@ -14,6 +15,7 @@ import {
aiIslandBtn,
aiIslandWrapper,
gradient,
toolStyle,
} from './styles.css';

const RIGHT_SIDEBAR_AI_HAS_EVER_OPENED_KEY =
Expand Down Expand Up @@ -49,7 +51,7 @@ export const AIIsland = () => {
}, [activeTab, haveChatTab, sidebarOpen]);

return (
<ToolContainer>
<ToolContainer className={clsx(toolStyle, { hide })}>
<div
className={aiIslandWrapper}
data-hide={hide}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { cssVar } from '@toeverything/theme';
import { createVar, keyframes, style } from '@vanilla-extract/css';

export const toolStyle = style({
selectors: {
'&.hide': {
pointerEvents: 'none',
},
},
});

export const aiIslandWrapper = style({
width: 44,
height: 44,
Expand Down
3 changes: 0 additions & 3 deletions packages/frontend/core/src/components/workspace/index.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,5 @@ export const toolStyle = style({
'&.trash': {
bottom: '78px',
},
'&[aria-disabled="true"]': {
pointerEvents: 'none',
},
},
});
18 changes: 4 additions & 14 deletions packages/frontend/core/src/components/workspace/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useAppSettingHelper } from '@affine/core/hooks/affine/use-app-setting-helper';
import { WorkbenchService } from '@affine/core/modules/workbench';
import {
DocsService,
GlobalContextService,
Expand Down Expand Up @@ -72,26 +71,17 @@ export const MainContainer = forwardRef<

MainContainer.displayName = 'MainContainer';

export const ToolContainer = (props: PropsWithChildren): ReactElement => {
const workbench = useService(WorkbenchService).workbench;
const isSidePanelOpen = useLiveData(workbench.sidebarOpen$);
const activeView = useLiveData(workbench.activeView$);
const inChatPanel = useLiveData(
activeView.activeSidebarTab$.map(t => t?.id === 'chat')
);
export const ToolContainer = (
props: PropsWithChildren<{ className?: string }>
): ReactElement => {
const docId = useLiveData(
useService(GlobalContextService).globalContext.docId.$
);
const docRecordList = useService(DocsService).list;
const doc = useLiveData(docId ? docRecordList.doc$(docId) : undefined);
const inTrash = useLiveData(doc?.meta$)?.trash;
return (
<div
className={clsx(toolStyle, {
trash: inTrash,
})}
aria-disabled={isSidePanelOpen && inChatPanel}
>
<div className={clsx(toolStyle, { trash: inTrash }, props.className)}>
{props.children}
</div>
);
Expand Down

0 comments on commit c7923e3

Please sign in to comment.