opti: 1.adjust page-tree header;

This commit is contained in:
mitsuha
2022-08-03 17:18:40 +08:00
parent d683f7ce05
commit 57422cbd78
5 changed files with 147 additions and 51 deletions

View File

@@ -0,0 +1,4 @@
<svg width="52" height="52" viewBox="0 0 52 52" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="52" height="52" rx="10" fill="#3E6FDB"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.2189 11.4392L14.6321 38.7943H20.2472L26.3453 19.8747L32.4461 38.7943H38.0423L28.454 11.4392H24.2189Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 327 B

View File

@@ -31,7 +31,7 @@ import { WorkspaceName } from './workspace-name';
import { CollapsiblePageTree } from './collapsible-page-tree'; import { CollapsiblePageTree } from './collapsible-page-tree';
import { useFlag } from '@toeverything/datasource/feature-flags'; import { useFlag } from '@toeverything/datasource/feature-flags';
import { type BlockEditor } from '@toeverything/components/editor-core'; import { type BlockEditor } from '@toeverything/components/editor-core';
import { Tabs } from './components/tabs';
type PageProps = { type PageProps = {
workspace: string; workspace: string;
}; };
@@ -80,7 +80,9 @@ export function Page(props: PageProps) {
onMouseLeave={() => setSpaceSidebarVisible(false)} onMouseLeave={() => setSpaceSidebarVisible(false)}
> >
<WorkspaceName /> <WorkspaceName />
<Divider light={true} sx={{ my: 1, margin: '6px 0px' }} />
<Tabs />
<WorkspaceSidebarContent> <WorkspaceSidebarContent>
<div> <div>
{dailyNotesFlag && ( {dailyNotesFlag && (
@@ -219,4 +221,5 @@ const WorkspaceSidebar = styled('div')(({ hidden }) => ({
const WorkspaceSidebarContent = styled('div')({ const WorkspaceSidebarContent = styled('div')({
flex: 'auto', flex: 'auto',
overflow: 'hidden auto', overflow: 'hidden auto',
marginTop: '18px',
}); });

View File

@@ -0,0 +1,61 @@
import { useState } from 'react';
import { MuiDivider as Divider, styled } from '@toeverything/components/ui';
import type { ValueOf } from '@toeverything/utils';
const StyledTabs = styled('div')({
width: '100%',
height: '12px',
marginTop: '12px',
display: 'flex',
alignItems: 'center',
cursor: 'pointer',
});
const StyledDivider = styled(Divider)<{ isActive?: boolean }>(
({ isActive }) => {
return {
flex: 1,
backgroundColor: isActive ? '#3E6FDB' : '#ECF1FB',
borderWidth: '2px',
};
}
);
const TAB_TITLE = {
PAGES: 'pages',
GALLERY: 'gallery',
TOC: 'toc',
} as const;
const TabMap = new Map<TabKey, TabValue>([
['PAGES', 'pages'],
['GALLERY', 'gallery'],
['TOC', 'toc'],
]);
type TabKey = keyof typeof TAB_TITLE;
type TabValue = ValueOf<typeof TAB_TITLE>;
const Tabs = () => {
const [activeTab, setActiveTab] = useState<TabValue>(TAB_TITLE.PAGES);
const onClick = (v: TabValue) => {
setActiveTab(v);
};
return (
<StyledTabs>
{[...TabMap.entries()].map(([k, v]) => {
return (
<StyledDivider
key={v}
isActive={v === activeTab}
onClick={() => onClick(v)}
/>
);
})}
</StyledTabs>
);
};
export { Tabs };

View File

@@ -0,0 +1 @@
export { Tabs } from './Tabs';

View File

@@ -1,27 +1,29 @@
import { import {
MuiButton as Button,
Switch,
styled, styled,
MuiOutlinedInput as OutlinedInput, MuiOutlinedInput as OutlinedInput,
} from '@toeverything/components/ui'; } from '@toeverything/components/ui';
import { LogoIcon } from '@toeverything/components/icons'; import { PinIcon } from '@toeverything/components/icons';
import logo from '../../../assets/images/logo.svg';
import { import {
useUserAndSpaces, useUserAndSpaces,
useShowSpaceSidebar, useShowSpaceSidebar,
} from '@toeverything/datasource/state'; } from '@toeverything/datasource/state';
import { useCallback, useEffect, useRef, useState } from 'react'; import React, { useCallback, useEffect, useState } from 'react';
import type { CSSProperties } from 'react';
import { services } from '@toeverything/datasource/db-service'; import { services } from '@toeverything/datasource/db-service';
const WorkspaceContainer = styled('div')({ const WorkspaceContainer = styled('div')({
display: 'flex', display: 'flex',
alignItems: 'center', flexDirection: 'column',
minHeight: 60, paddingBottom: '12px',
padding: '12px 0px',
color: '#566B7D', color: '#566B7D',
}); });
const LeftContainer = styled('div')({ const LeftContainer = styled('div')({
flex: 'auto', flex: 'auto',
display: 'flex', display: 'flex',
height: '52px',
alignItems: 'center',
margin: '0 12px',
}); });
const LogoContainer = styled('div')({ const LogoContainer = styled('div')({
@@ -32,20 +34,40 @@ const LogoContainer = styled('div')({
minWidth: 24, minWidth: 24,
}); });
const StyledLogoIcon = styled(LogoIcon)(({ theme }) => { export const LogoImg = ({ style = {} }: { style?: CSSProperties }) => {
return { return <img style={style} src={logo} alt="AFFiNE Logo" />;
color: theme.affine.palette.primary,
width: '16px !important',
height: '16px !important',
}; };
const StyledPin = styled('div')({
display: 'flex',
justifyContent: 'end',
alignItems: 'center',
});
const StyledWorkspace = styled('div')({
height: '100%',
display: 'flex',
flexDirection: 'column',
justifyContent: 'space-between',
marginLeft: '12px',
paddingLeft: '12px',
});
const StyledWorkspaceDesc = styled('div')({
fontSize: '12px',
color: '#98ACBD',
height: '18px',
display: 'flex',
alignItems: 'center',
}); });
const WorkspaceNameContainer = styled('div')({ const WorkspaceNameContainer = styled('div')({
display: 'flex', display: 'flex',
alignItems: 'center', alignItems: 'center',
flex: 'auto', flex: 'auto',
width: '100px', width: '165px',
marginRight: '10px', height: '34px',
input: { input: {
padding: '5px 10px', padding: '5px 10px',
}, },
@@ -58,21 +80,15 @@ const WorkspaceNameContainer = styled('div')({
}); });
const WorkspaceReNameContainer = styled('div')({ const WorkspaceReNameContainer = styled('div')({
marginRight: '10px', height: '34px',
display: 'flex',
alignItems: 'center',
input: { input: {
padding: '5px 10px', padding: '5px 10px',
}, },
}); });
const ToggleDisplayContainer = styled('div')({
display: 'flex',
alignItems: 'center',
fontSize: 12,
color: '#3E6FDB',
padding: 6,
minWidth: 64,
});
export const WorkspaceName = () => { export const WorkspaceName = () => {
const { currentSpaceId } = useUserAndSpaces(); const { currentSpaceId } = useUserAndSpaces();
const { fixedDisplay, toggleSpaceSidebar } = useShowSpaceSidebar(); const { fixedDisplay, toggleSpaceSidebar } = useShowSpaceSidebar();
@@ -139,14 +155,27 @@ export const WorkspaceName = () => {
return ( return (
<WorkspaceContainer> <WorkspaceContainer>
<StyledPin>
<PinIcon
style={{
width: '20px',
height: '20px',
color: fixedDisplay ? '#3E6FDB' : '',
cursor: 'pointer',
}}
onClick={toggleSpaceSidebar}
/>
</StyledPin>
<LeftContainer> <LeftContainer>
<LogoContainer> <LogoContainer>
<StyledLogoIcon /> <LogoImg />
</LogoContainer> </LogoContainer>
<StyledWorkspace>
{inRename ? ( {inRename ? (
<WorkspaceReNameContainer> <WorkspaceReNameContainer>
<OutlinedInput <OutlinedInput
style={{ width: '140px', height: '28px' }}
value={workspaceName} value={workspaceName}
onChange={handleChange} onChange={handleChange}
onKeyDown={handleKeyDown} onKeyDown={handleKeyDown}
@@ -160,14 +189,12 @@ export const WorkspaceName = () => {
</span> </span>
</WorkspaceNameContainer> </WorkspaceNameContainer>
)} )}
<StyledWorkspaceDesc>
To shape, Not to Adapt.
</StyledWorkspaceDesc>
</StyledWorkspace>
</LeftContainer> </LeftContainer>
<ToggleDisplayContainer onClick={toggleSpaceSidebar}>
<Switch
checked={fixedDisplay}
checkedLabel="ON"
uncheckedLabel="OFF"
/>
</ToggleDisplayContainer>
</WorkspaceContainer> </WorkspaceContainer>
); );
}; };