mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-18 14:01:44 +03:00
opti: 1.page tree; 2. icon invert; 3.topbar;
This commit is contained in:
parent
f413d4ce0e
commit
f0788e0b4b
@ -1,43 +1,73 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { MuiDivider as Divider, styled } from '@toeverything/components/ui';
|
import { styled } from '@toeverything/components/ui';
|
||||||
import type { ValueOf } from '@toeverything/utils';
|
import type { ValueOf } from '@toeverything/utils';
|
||||||
|
|
||||||
const StyledTabs = styled('div')({
|
const StyledTabs = styled('div')(({ theme }) => {
|
||||||
width: '100%',
|
|
||||||
height: '12px',
|
|
||||||
marginTop: '12px',
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
cursor: 'pointer',
|
|
||||||
});
|
|
||||||
|
|
||||||
const StyledDivider = styled(Divider, {
|
|
||||||
shouldForwardProp: (prop: string) => !['isActive'].includes(prop),
|
|
||||||
})<{ isActive?: boolean }>(({ isActive }) => {
|
|
||||||
return {
|
return {
|
||||||
flex: 1,
|
width: '100%',
|
||||||
backgroundColor: isActive ? '#3E6FDB' : '#ECF1FB',
|
height: '30px',
|
||||||
borderWidth: '2px',
|
marginTop: '12px',
|
||||||
|
display: 'flex',
|
||||||
|
fontSize: '12px',
|
||||||
|
fontWeight: '600',
|
||||||
|
color: theme.affine.palette.primary,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const StyledTabTitle = styled('div', {
|
||||||
|
shouldForwardProp: (prop: string) => !['isActive'].includes(prop),
|
||||||
|
})<{ isActive?: boolean; isDisabled?: boolean }>`
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
line-height: 18px;
|
||||||
|
padding-top: 4px;
|
||||||
|
border-top: 2px solid #ecf1fb;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
content: '';
|
||||||
|
width: 0;
|
||||||
|
height: 2px;
|
||||||
|
background-color: ${({ isActive, theme }) =>
|
||||||
|
isActive ? theme.affine.palette.primary : ''};
|
||||||
|
position: absolute;
|
||||||
|
left: 100%;
|
||||||
|
top: -2px;
|
||||||
|
transition: all 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
&::after {
|
||||||
|
width: 100%;
|
||||||
|
left: 0;
|
||||||
|
transition-delay: 0.1s;
|
||||||
|
}
|
||||||
|
& ~ div::after {
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
const TAB_TITLE = {
|
const TAB_TITLE = {
|
||||||
PAGES: 'pages',
|
PAGES: 'pages',
|
||||||
GALLERY: 'gallery',
|
GALLERY: 'gallery',
|
||||||
TOC: 'toc',
|
TOC: 'toc',
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
const TabMap = new Map<TabKey, TabValue>([
|
const TabMap = new Map<TabKey, { value: TabValue; disabled?: boolean }>([
|
||||||
['PAGES', 'pages'],
|
['PAGES', { value: 'pages' }],
|
||||||
['GALLERY', 'gallery'],
|
['GALLERY', { value: 'gallery', disabled: true }],
|
||||||
['TOC', 'toc'],
|
['TOC', { value: 'toc' }],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
type TabKey = keyof typeof TAB_TITLE;
|
type TabKey = keyof typeof TAB_TITLE;
|
||||||
type TabValue = ValueOf<typeof TAB_TITLE>;
|
type TabValue = ValueOf<typeof TAB_TITLE>;
|
||||||
|
|
||||||
const Tabs = () => {
|
const Tabs = () => {
|
||||||
const [activeTab, setActiveTab] = useState<TabValue>(TAB_TITLE.PAGES);
|
const [activeValue, setActiveTab] = useState<TabValue>(TAB_TITLE.PAGES);
|
||||||
|
|
||||||
const onClick = (v: TabValue) => {
|
const onClick = (v: TabValue) => {
|
||||||
setActiveTab(v);
|
setActiveTab(v);
|
||||||
@ -45,13 +75,19 @@ const Tabs = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledTabs>
|
<StyledTabs>
|
||||||
{[...TabMap.entries()].map(([k, v]) => {
|
{[...TabMap.entries()].map(([k, { value, disabled = false }]) => {
|
||||||
|
const isActive = activeValue === value;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledDivider
|
<StyledTabTitle
|
||||||
key={v}
|
key={value}
|
||||||
isActive={v === activeTab}
|
className={isActive ? 'active' : ''}
|
||||||
onClick={() => onClick(v)}
|
isActive={isActive}
|
||||||
/>
|
isDisabled={disabled}
|
||||||
|
onClick={() => onClick(value)}
|
||||||
|
>
|
||||||
|
{k}
|
||||||
|
</StyledTabTitle>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</StyledTabs>
|
</StyledTabs>
|
||||||
|
@ -33,9 +33,9 @@ export const LayoutHeader = () => {
|
|||||||
|
|
||||||
<IconButton onClick={toggleInfoSidebar} size="large">
|
<IconButton onClick={toggleInfoSidebar} size="large">
|
||||||
{showSettingsSidebar ? (
|
{showSettingsSidebar ? (
|
||||||
<SideBarViewIcon />
|
|
||||||
) : (
|
|
||||||
<SideBarViewCloseIcon />
|
<SideBarViewCloseIcon />
|
||||||
|
) : (
|
||||||
|
<SideBarViewIcon />
|
||||||
)}
|
)}
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</StyledHelper>
|
</StyledHelper>
|
||||||
|
@ -100,10 +100,10 @@ export const ContainerTabs = () => {
|
|||||||
|
|
||||||
const StyledTabsTitlesContainer = styled('div')(({ theme }) => {
|
const StyledTabsTitlesContainer = styled('div')(({ theme }) => {
|
||||||
return {
|
return {
|
||||||
|
height: '60px',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
marginTop: 24,
|
|
||||||
marginBottom: 24,
|
|
||||||
marginLeft: theme.affine.spacing.smSpacing,
|
marginLeft: theme.affine.spacing.smSpacing,
|
||||||
marginRight: theme.affine.spacing.smSpacing,
|
marginRight: theme.affine.spacing.smSpacing,
|
||||||
};
|
};
|
||||||
|
@ -16,7 +16,6 @@ const StyledContainerForSettingsPanel = styled('div')(({ theme }) => {
|
|||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
paddingTop: 44,
|
|
||||||
paddingBottom: 44,
|
paddingBottom: 44,
|
||||||
height: '100%',
|
height: '100%',
|
||||||
};
|
};
|
||||||
|
@ -15,6 +15,7 @@ import styles from './tree-item.module.scss';
|
|||||||
import { useFlag } from '@toeverything/datasource/feature-flags';
|
import { useFlag } from '@toeverything/datasource/feature-flags';
|
||||||
|
|
||||||
import MoreActions from './MoreActions';
|
import MoreActions from './MoreActions';
|
||||||
|
import { useTheme } from '@toeverything/components/ui';
|
||||||
export type TreeItemProps = {
|
export type TreeItemProps = {
|
||||||
/** The main text to display on this line */
|
/** The main text to display on this line */
|
||||||
value: string;
|
value: string;
|
||||||
@ -61,11 +62,13 @@ export const TreeItem = forwardRef<HTMLDivElement, TreeItemProps>(
|
|||||||
},
|
},
|
||||||
ref
|
ref
|
||||||
) => {
|
) => {
|
||||||
const { workspace_id } = useParams();
|
const { workspace_id, page_id } = useParams();
|
||||||
const BooleanPageTreeItemMoreActions = useFlag(
|
const BooleanPageTreeItemMoreActions = useFlag(
|
||||||
'BooleanPageTreeItemMoreActions',
|
'BooleanPageTreeItemMoreActions',
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
const theme = useTheme();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li
|
<li
|
||||||
ref={wrapperRef}
|
ref={wrapperRef}
|
||||||
@ -106,6 +109,11 @@ export const TreeItem = forwardRef<HTMLDivElement, TreeItemProps>(
|
|||||||
className={styles['Text']}
|
className={styles['Text']}
|
||||||
{...handleProps}
|
{...handleProps}
|
||||||
to={`/${workspace_id}/${pageId}`}
|
to={`/${workspace_id}/${pageId}`}
|
||||||
|
style={{
|
||||||
|
...(pageId === page_id && {
|
||||||
|
color: theme.affine.palette.primary,
|
||||||
|
}),
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{value}
|
{value}
|
||||||
</Link>
|
</Link>
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding-left: var(--spacing);
|
padding-left: var(--spacing);
|
||||||
list-style: none;
|
list-style: none;
|
||||||
padding: 6px 0;
|
padding-top: 6px;
|
||||||
|
padding-bottom: 6px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
&:hover {
|
&:hover {
|
||||||
background: #f5f7f8;
|
background: #f5f7f8;
|
||||||
|
Loading…
Reference in New Issue
Block a user