opti: 1.adjust padding of page-tree item; 2. fetch new icon from figma;

This commit is contained in:
mitsuha
2022-08-02 17:10:13 +08:00
parent efa23c806a
commit 68eddb597c
17 changed files with 234 additions and 98 deletions

View File

@@ -47,11 +47,11 @@ export function Page(props: PageProps) {
} }
); );
await services.api.userConfig.addRecentPage( // await services.api.userConfig.addRecentPage(
props.workspace, // props.workspace,
user.id, // user.id,
page_id // page_id
); // );
await services.api.editorBlock.clearUndoRedo(props.workspace); await services.api.editorBlock.clearUndoRedo(props.workspace);
}; };
updateRecentPages(); updateRecentPages();

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill-rule="evenodd" d="M11.04 12.96V18h1.92v-5.04H18v-1.92h-5.04V6h-1.92v5.04H6v1.92h5.04Z" clip-rule="evenodd"/></svg>

After

Width:  |  Height:  |  Size: 185 B

View File

@@ -0,0 +1,21 @@
import { FC } from 'react';
// eslint-disable-next-line no-restricted-imports
import { SvgIcon } from '@mui/material';
// eslint-disable-next-line no-restricted-imports
import type { SvgIconProps } from '@mui/material';
export interface AddIconProps extends Omit<SvgIconProps, 'color'> {
color?: string
}
export const AddIcon: FC<AddIconProps> = ({ color, style, ...props}) => {
const propsStyles = {"color": color};
const customStyles = {};
const styles = {...propsStyles, ...customStyles, ...style}
return (
<SvgIcon style={styles} {...props}>
<path fillRule="evenodd" d="M11.04 12.96V18h1.92v-5.04H18v-1.92h-5.04V6h-1.92v5.04H6v1.92h5.04Z" clipRule="evenodd" />
</SvgIcon>
)
};

View File

@@ -1,4 +1,4 @@
export const timestamp = 1659000896562; export const timestamp = 1659423582387;
export * from './image/image'; export * from './image/image';
export * from './format-clear/format-clear'; export * from './format-clear/format-clear';
export * from './backward-undo/backward-undo'; export * from './backward-undo/backward-undo';
@@ -125,4 +125,8 @@ export * from './eraser/eraser';
export * from './group-by/group-by'; export * from './group-by/group-by';
export * from './layout/layout'; export * from './layout/layout';
export * from './lock/lock'; export * from './lock/lock';
export * from './unlock/unlock'; export * from './unlock/unlock';
export * from './more-tags-an-subblocks/more-tags-an-subblocks';
export * from './page-in-page-tree/page-in-page-tree';
export * from './pin/pin';
export * from './add/add';

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill-rule="evenodd" d="M2.2 3v13A3.8 3.8 0 0 0 6 19.8h10.316A2.801 2.801 0 0 0 21.8 19a2.8 2.8 0 0 0-5.484-.8H6A2.2 2.2 0 0 1 3.8 16v-6h12.584a2.801 2.801 0 1 0-.12-1.6H3.8V3H2.2ZM19 7.8a1.2 1.2 0 1 0 0 2.4 1.2 1.2 0 0 0 0-2.4ZM17.8 19a1.2 1.2 0 1 1 2.4 0 1.2 1.2 0 0 1-2.4 0Z" clip-rule="evenodd"/></svg>

After

Width:  |  Height:  |  Size: 371 B

View File

@@ -0,0 +1,21 @@
import { FC } from 'react';
// eslint-disable-next-line no-restricted-imports
import { SvgIcon } from '@mui/material';
// eslint-disable-next-line no-restricted-imports
import type { SvgIconProps } from '@mui/material';
export interface MoreTagsAnSubblocksIconProps extends Omit<SvgIconProps, 'color'> {
color?: string
}
export const MoreTagsAnSubblocksIcon: FC<MoreTagsAnSubblocksIconProps> = ({ color, style, ...props}) => {
const propsStyles = {"color": color};
const customStyles = {};
const styles = {...propsStyles, ...customStyles, ...style}
return (
<SvgIcon style={styles} {...props}>
<path fillRule="evenodd" d="M2.2 3v13A3.8 3.8 0 0 0 6 19.8h10.316A2.801 2.801 0 0 0 21.8 19a2.8 2.8 0 0 0-5.484-.8H6A2.2 2.2 0 0 1 3.8 16v-6h12.584a2.801 2.801 0 1 0-.12-1.6H3.8V3H2.2ZM19 7.8a1.2 1.2 0 1 0 0 2.4 1.2 1.2 0 0 0 0-2.4ZM17.8 19a1.2 1.2 0 1 1 2.4 0 1.2 1.2 0 0 1-2.4 0Z" clipRule="evenodd" />
</SvgIcon>
)
};

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><circle cx="12" cy="12" r="2.5"/></svg>

After

Width:  |  Height:  |  Size: 99 B

View File

@@ -0,0 +1,21 @@
import { FC } from 'react';
// eslint-disable-next-line no-restricted-imports
import { SvgIcon } from '@mui/material';
// eslint-disable-next-line no-restricted-imports
import type { SvgIconProps } from '@mui/material';
export interface PageInPageTreeIconProps extends Omit<SvgIconProps, 'color'> {
color?: string
}
export const PageInPageTreeIcon: FC<PageInPageTreeIconProps> = ({ color, style, ...props}) => {
const propsStyles = {"color": color};
const customStyles = {};
const styles = {...propsStyles, ...customStyles, ...style}
return (
<SvgIcon style={styles} {...props}>
<circle cx={12} cy={12} r={2.5} />
</SvgIcon>
)
};

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><g clip-path="url(#a)"><path fill-rule="evenodd" d="M20.403 7.84a2 2 0 0 1 0 2.828l-2.12 2.12-1.414-1.414-2.596 2.595a6.003 6.003 0 0 1-1.172 6.83l-4.243-4.243-3.834 3.834a1 1 0 1 1-1.414-1.414l3.834-3.834L3.2 10.9a6.002 6.002 0 0 1 6.83-1.173l2.595-2.596-1.414-1.414 2.12-2.12a2 2 0 0 1 2.829 0l4.242 4.242Z" clip-rule="evenodd"/></g><defs><clipPath id="a"><path d="M0 0H24V24H0z" transform="matrix(-1 0 0 1 24 0)"/></clipPath></defs></svg>

After

Width:  |  Height:  |  Size: 501 B

View File

@@ -0,0 +1,21 @@
import { FC } from 'react';
// eslint-disable-next-line no-restricted-imports
import { SvgIcon } from '@mui/material';
// eslint-disable-next-line no-restricted-imports
import type { SvgIconProps } from '@mui/material';
export interface PinIconProps extends Omit<SvgIconProps, 'color'> {
color?: string
}
export const PinIcon: FC<PinIconProps> = ({ color, style, ...props}) => {
const propsStyles = {"color": color};
const customStyles = {};
const styles = {...propsStyles, ...customStyles, ...style}
return (
<SvgIcon style={styles} {...props}>
<g clipPath="url(#a)"><path fillRule="evenodd" d="M20.403 7.84a2 2 0 0 1 0 2.828l-2.12 2.12-1.414-1.414-2.596 2.595a6.003 6.003 0 0 1-1.172 6.83l-4.243-4.243-3.834 3.834a1 1 0 1 1-1.414-1.414l3.834-3.834L3.2 10.9a6.002 6.002 0 0 1 6.83-1.173l2.595-2.596-1.414-1.414 2.12-2.12a2 2 0 0 1 2.829 0l4.242 4.242Z" clipRule="evenodd" /></g><defs><clipPath id="a"><path d="M0 0H24V24H0z" transform="matrix(-1 0 0 1 24 0)" /></clipPath></defs>
</SvgIcon>
)
};

View File

@@ -3,13 +3,14 @@ import {
LogoIcon, LogoIcon,
SideBarViewIcon, SideBarViewIcon,
SearchIcon, SearchIcon,
SideBarViewCloseIcon,
} from '@toeverything/components/icons'; } from '@toeverything/components/icons';
import { useShowSettingsSidebar } from '@toeverything/datasource/state'; import { useShowSettingsSidebar } from '@toeverything/datasource/state';
import { CurrentPageTitle } from './Title'; import { CurrentPageTitle } from './Title';
import { EditorBoardSwitcher } from './EditorBoardSwitcher'; import { EditorBoardSwitcher } from './EditorBoardSwitcher';
export const LayoutHeader = () => { export const LayoutHeader = () => {
const { toggleSettingsSidebar: toggleInfoSidebar } = const { toggleSettingsSidebar: toggleInfoSidebar, showSettingsSidebar } =
useShowSettingsSidebar(); useShowSettingsSidebar();
return ( return (
@@ -31,7 +32,11 @@ export const LayoutHeader = () => {
</div> </div>
<IconButton onClick={toggleInfoSidebar} size="large"> <IconButton onClick={toggleInfoSidebar} size="large">
<SideBarViewIcon /> {showSettingsSidebar ? (
<SideBarViewIcon />
) : (
<SideBarViewCloseIcon />
)}
</IconButton> </IconButton>
</StyledHelper> </StyledHelper>
</FlexContainer> </FlexContainer>

View File

@@ -50,31 +50,35 @@ export const Activities = () => {
const [recentPages, setRecentPages] = useState([]); const [recentPages, setRecentPages] = useState([]);
const userId = user?.id; const userId = user?.id;
const fetchRecentPages = useCallback(async () => { /* temporarily remove:show recently viewed documents */
if (!userId || !currentSpaceId) { // const fetchRecentPages = useCallback(async () => {
return; // if (!userId || !currentSpaceId) {
} // return;
const recent_pages = await services.api.userConfig.getRecentPages( // }
currentSpaceId, // const recent_pages = await services.api.userConfig.getRecentPages(
userId // currentSpaceId,
); // userId
setRecentPages(recent_pages); // );
}, [userId, currentSpaceId]); // setRecentPages(recent_pages);
// }, [userId, currentSpaceId]);
useEffect(() => { // useEffect(() => {
(async () => { // (async () => {
await fetchRecentPages(); // await fetchRecentPages();
})(); // })();
}, [fetchRecentPages]); // }, [fetchRecentPages]);
/* show recently edit documents */
const getRecentEditPages = async (state, block) => {
console.log(state, await block.children());
};
useEffect(() => { useEffect(() => {
let unobserve: () => void; let unobserve: () => void;
const observe = async () => { const observe = async () => {
unobserve = await services.api.userConfig.observe( unobserve = await services.api.userConfig.observe(
{ workspace: currentSpaceId }, { workspace: currentSpaceId },
() => { getRecentEditPages
fetchRecentPages();
}
); );
}; };
observe(); observe();
@@ -82,7 +86,7 @@ export const Activities = () => {
return () => { return () => {
unobserve?.(); unobserve?.();
}; };
}, [currentSpaceId, fetchRecentPages]); }, [currentSpaceId, getRecentEditPages]);
return ( return (
<StyledWrapper> <StyledWrapper>

View File

@@ -95,30 +95,37 @@ export function DndTree(props: DndTreeProps) {
> >
{/* <button onClick={() => handleAdd()}> add top node</button> */} {/* <button onClick={() => handleAdd()}> add top node</button> */}
{flattenedItems.map( {flattenedItems.map(
({ id, title, children, collapsed, depth }) => ( ({ id, title, children, collapsed, depth }) => {
<DndTreeItem return (
key={id} <DndTreeItem
id={id} key={id}
// value={id} id={id}
value={title} // value={id}
collapsed={Boolean(collapsed && children.length)} value={title}
depth={ collapsed={Boolean(
id === activeId && projected collapsed && children.length
? projected.depth )}
: depth depth={
} id === activeId && projected
indentationWidth={indentationWidth} ? projected.depth
indicator={showDragIndicator} : depth
onCollapse={ }
collapsible && children.length indentationWidth={indentationWidth}
? () => handleCollapse(id) indicator={showDragIndicator}
: undefined childCount={children.length}
} onCollapse={
onRemove={ collapsible && children.length
removable ? () => handleRemove(id) : undefined ? () => handleCollapse(id)
} : undefined
/> }
) onRemove={
removable
? () => handleRemove(id)
: undefined
}
/>
);
}
)} )}
<DragOverlay <DragOverlay
dropAnimation={dropAnimation} dropAnimation={dropAnimation}

View File

@@ -5,6 +5,8 @@ import {
CascaderItemProps, CascaderItemProps,
MuiDivider as Divider, MuiDivider as Divider,
MuiClickAwayListener as ClickAwayListener, MuiClickAwayListener as ClickAwayListener,
IconButton,
styled,
} from '@toeverything/components/ui'; } from '@toeverything/components/ui';
import React from 'react'; import React from 'react';
import { NavLink, useNavigate } from 'react-router-dom'; import { NavLink, useNavigate } from 'react-router-dom';
@@ -12,6 +14,8 @@ import { copyToClipboard } from '@toeverything/utils';
import { services, TemplateFactory } from '@toeverything/datasource/db-service'; import { services, TemplateFactory } from '@toeverything/datasource/db-service';
import { NewFromTemplatePortal } from './NewFromTemplatePortal'; import { NewFromTemplatePortal } from './NewFromTemplatePortal';
import { useFlag } from '@toeverything/datasource/feature-flags'; import { useFlag } from '@toeverything/datasource/feature-flags';
import { MoreIcon, AddIcon } from '@toeverything/components/icons';
const MESSAGES = { const MESSAGES = {
COPY_LINK_SUCCESS: 'Copyed link to clipboard', COPY_LINK_SUCCESS: 'Copyed link to clipboard',
}; };
@@ -20,6 +24,12 @@ interface ActionsProps {
pageId: string; pageId: string;
onRemove: () => void; onRemove: () => void;
} }
const StyledAction = styled('div')({
display: 'flex',
alignItems: 'center',
});
function DndTreeItemMoreActions(props: ActionsProps) { function DndTreeItemMoreActions(props: ActionsProps) {
const [alert_open, set_alert_open] = React.useState(false); const [alert_open, set_alert_open] = React.useState(false);
const [anchorEl, setAnchorEl] = React.useState<HTMLDivElement | null>(null); const [anchorEl, setAnchorEl] = React.useState<HTMLDivElement | null>(null);
@@ -236,12 +246,23 @@ function DndTreeItemMoreActions(props: ActionsProps) {
return ( return (
<ClickAwayListener onClickAway={() => handleClose()}> <ClickAwayListener onClickAway={() => handleClose()}>
<div> <div>
<span <div className={styles['TreeItemMoreActions']}>
className={styles['TreeItemMoreActions']} <StyledAction>
onClick={handleClick} <IconButton
> size="small"
··· onClick={handle_new_child_page}
</span> >
<AddIcon />
</IconButton>
<IconButton
size="small"
hoverColor="#E0E6EB"
onClick={handleClick}
>
<MoreIcon />
</IconButton>
</StyledAction>
</div>
<Cascader <Cascader
items={menuList} items={menuList}
anchorEl={anchorEl} anchorEl={anchorEl}

View File

@@ -65,7 +65,7 @@ export const TreeItem = forwardRef<HTMLDivElement, TreeItemProps>(
const navigate = useNavigate(); const navigate = useNavigate();
const BooleanPageTreeItemMoreActions = useFlag( const BooleanPageTreeItemMoreActions = useFlag(
'BooleanPageTreeItemMoreActions', 'BooleanPageTreeItemMoreActions',
false true
); );
return ( return (
<li <li
@@ -94,7 +94,12 @@ export const TreeItem = forwardRef<HTMLDivElement, TreeItemProps>(
title={value} title={value}
> >
<Action onClick={onCollapse}> <Action onClick={onCollapse}>
{collapsed ? <ArrowRightIcon /> : <ArrowDropDownIcon />} {childCount !== 0 &&
(collapsed ? (
<ArrowRightIcon />
) : (
<ArrowDropDownIcon />
))}
</Action> </Action>
{/*<Action>*/} {/*<Action>*/}
{/* <DocumentIcon />*/} {/* <DocumentIcon />*/}

View File

@@ -83,11 +83,11 @@
justify-content: space-around; justify-content: space-around;
background-color: #fff; background-color: #fff;
color: #4c6275; color: #4c6275;
padding: 0 0.5rem; padding-right: 0.5rem;
overflow: hidden; overflow: hidden;
.TreeItemMoreActions { .TreeItemMoreActions {
visibility: hidden; visibility: visible;
cursor: pointer; cursor: pointer;
} }
&:hover { &:hover {

View File

@@ -36,6 +36,7 @@ interface IconButtonProps {
style?: CSSProperties; style?: CSSProperties;
className?: string; className?: string;
size?: SizeType; size?: SizeType;
hoverColor?: CSSProperties['backgroundColor'];
} }
export const IconButton: FC<PropsWithChildren<IconButtonProps>> = ({ export const IconButton: FC<PropsWithChildren<IconButtonProps>> = ({
@@ -57,47 +58,48 @@ export const IconButton: FC<PropsWithChildren<IconButtonProps>> = ({
); );
}; };
const Container = styled('button')<{ size?: SizeType }>( const Container = styled('button')<{
({ theme, size = SIZE_MIDDLE }) => { size?: SizeType;
const { iconSize, areaSize } = SIZE_CONFIG[size]; hoverColor?: CSSProperties['backgroundColor'];
}>(({ theme, size = SIZE_MIDDLE, hoverColor }) => {
const { iconSize, areaSize } = SIZE_CONFIG[size];
return { return {
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
width: areaSize,
height: areaSize,
backgroundColor: 'transparent',
color: theme.affine.palette.icons,
padding: theme.affine.spacing.iconPadding,
borderRadius: '3px',
'& svg': {
width: iconSize,
height: iconSize,
display: 'flex', display: 'flex',
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',
width: areaSize, },
height: areaSize,
backgroundColor: theme.affine.palette.white,
color: theme.affine.palette.icons,
padding: theme.affine.spacing.iconPadding,
borderRadius: '5px',
'& svg': { '&:hover': {
width: iconSize, backgroundColor: hoverColor || theme.affine.palette.hover,
height: iconSize, },
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
},
'&:hover': { [`&${buttonStatus.hover}`]: {
backgroundColor: theme.affine.palette.hover, backgroundColor: theme.affine.palette.hover,
}, },
[`&${buttonStatus.hover}`]: { '&:focus': {
backgroundColor: theme.affine.palette.hover, color: theme.affine.palette.primary,
}, },
[`&.${buttonStatus.focus}`]: {
color: theme.affine.palette.primary,
},
'&:focus': { [`&${buttonStatus.disabled}`]: {
color: theme.affine.palette.primary, cursor: 'not-allowed',
}, },
[`&.${buttonStatus.focus}`]: { };
color: theme.affine.palette.primary, });
},
[`&${buttonStatus.disabled}`]: {
cursor: 'not-allowed',
},
};
}
);