mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-09 13:15:51 +08:00
improvement: 1.left toolbar hover style#148;
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
|||||||
usePageTree,
|
usePageTree,
|
||||||
} from '@toeverything/components/layout';
|
} from '@toeverything/components/layout';
|
||||||
import {
|
import {
|
||||||
|
IconButton,
|
||||||
MuiBox as Box,
|
MuiBox as Box,
|
||||||
MuiCollapse as Collapse,
|
MuiCollapse as Collapse,
|
||||||
styled,
|
styled,
|
||||||
@@ -27,6 +28,7 @@ const StyledBtn = styled('div')({
|
|||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
userSelect: 'none',
|
userSelect: 'none',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
|
marginLeft: '12px',
|
||||||
});
|
});
|
||||||
|
|
||||||
export type CollapsiblePageTreeProps = {
|
export type CollapsiblePageTreeProps = {
|
||||||
@@ -70,7 +72,7 @@ export function CollapsiblePageTree(props: CollapsiblePageTreeProps) {
|
|||||||
display: 'flex',
|
display: 'flex',
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
paddingRight: 1,
|
paddingRight: '12px',
|
||||||
'&:hover': {
|
'&:hover': {
|
||||||
background: '#f5f7f8',
|
background: '#f5f7f8',
|
||||||
borderRadius: '5px',
|
borderRadius: '5px',
|
||||||
@@ -80,24 +82,17 @@ export function CollapsiblePageTree(props: CollapsiblePageTreeProps) {
|
|||||||
onMouseLeave={() => setNewPageBtnVisible(false)}
|
onMouseLeave={() => setNewPageBtnVisible(false)}
|
||||||
>
|
>
|
||||||
<StyledBtn onClick={() => setOpen(prev => !prev)}>
|
<StyledBtn onClick={() => setOpen(prev => !prev)}>
|
||||||
{open ? (
|
|
||||||
<ArrowDropDownIcon sx={{ color: '#566B7D' }} />
|
|
||||||
) : (
|
|
||||||
<ArrowRightIcon sx={{ color: '#566B7D' }} />
|
|
||||||
)}
|
|
||||||
{title}
|
{title}
|
||||||
</StyledBtn>
|
</StyledBtn>
|
||||||
|
|
||||||
{newPageBtnVisible && (
|
{newPageBtnVisible && (
|
||||||
<AddIcon
|
<IconButton
|
||||||
style={{
|
size="small"
|
||||||
width: '20px',
|
hoverColor="#E0E6EB"
|
||||||
height: '20px',
|
|
||||||
color: '#98ACBD',
|
|
||||||
cursor: 'pointer',
|
|
||||||
}}
|
|
||||||
onClick={create_page}
|
onClick={create_page}
|
||||||
/>
|
>
|
||||||
|
<AddIcon />
|
||||||
|
</IconButton>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
{children ? (
|
{children ? (
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
import {
|
import { styled, Input } from '@toeverything/components/ui';
|
||||||
styled,
|
|
||||||
MuiOutlinedInput as OutlinedInput,
|
|
||||||
} from '@toeverything/components/ui';
|
|
||||||
import { PinIcon } from '@toeverything/components/icons';
|
import { PinIcon } from '@toeverything/components/icons';
|
||||||
import {
|
import {
|
||||||
useUserAndSpaces,
|
useUserAndSpaces,
|
||||||
useShowSpaceSidebar,
|
useShowSpaceSidebar,
|
||||||
} from '@toeverything/datasource/state';
|
} from '@toeverything/datasource/state';
|
||||||
import React, { useCallback, useEffect, useState } from 'react';
|
import React, {
|
||||||
|
ChangeEvent,
|
||||||
|
KeyboardEvent,
|
||||||
|
useCallback,
|
||||||
|
useEffect,
|
||||||
|
useState,
|
||||||
|
} from 'react';
|
||||||
import { services } from '@toeverything/datasource/db-service';
|
import { services } from '@toeverything/datasource/db-service';
|
||||||
import { Logo } from './components/logo/Logo';
|
import { Logo } from './components/logo/Logo';
|
||||||
|
|
||||||
@@ -124,24 +127,24 @@ export const WorkspaceName = () => {
|
|||||||
};
|
};
|
||||||
}, [currentSpaceId, fetchWorkspaceName]);
|
}, [currentSpaceId, fetchWorkspaceName]);
|
||||||
|
|
||||||
const handleKeyDown = useCallback(
|
const handleKeyDown = useCallback((e: KeyboardEvent<HTMLInputElement>) => {
|
||||||
(e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
if (e.key === 'Enter') {
|
||||||
if (e.key === 'Enter') {
|
e.stopPropagation();
|
||||||
e.stopPropagation();
|
e.preventDefault();
|
||||||
e.preventDefault();
|
setInRename(false);
|
||||||
setInRename(false);
|
}
|
||||||
}
|
}, []);
|
||||||
},
|
|
||||||
[]
|
|
||||||
);
|
|
||||||
const handleChange = useCallback(
|
const handleChange = useCallback(
|
||||||
(e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
async (e: ChangeEvent<HTMLInputElement>) => {
|
||||||
services.api.userConfig.setWorkspaceName(
|
const name = e.target.value;
|
||||||
|
|
||||||
|
await setWorkspaceName(name);
|
||||||
|
await services.api.userConfig.setWorkspaceName(
|
||||||
currentSpaceId,
|
currentSpaceId,
|
||||||
e.currentTarget.value
|
name
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
[]
|
[currentSpaceId]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -165,7 +168,8 @@ export const WorkspaceName = () => {
|
|||||||
<StyledWorkspace>
|
<StyledWorkspace>
|
||||||
{inRename ? (
|
{inRename ? (
|
||||||
<WorkspaceReNameContainer>
|
<WorkspaceReNameContainer>
|
||||||
<OutlinedInput
|
<Input
|
||||||
|
autoFocus
|
||||||
style={{ width: '140px', height: '28px' }}
|
style={{ width: '140px', height: '28px' }}
|
||||||
value={workspaceName}
|
value={workspaceName}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ const StyledContainer = styled('div')({
|
|||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
|
paddingLeft: '12px',
|
||||||
'&:hover': {
|
'&:hover': {
|
||||||
background: '#f5f7f8',
|
background: '#f5f7f8',
|
||||||
borderRadius: '5px',
|
borderRadius: '5px',
|
||||||
@@ -36,11 +37,6 @@ export function CollapsibleTitle(props: CollapsibleTitleProps) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<StyledContainer onClick={() => setOpen(prev => !prev)}>
|
<StyledContainer onClick={() => setOpen(prev => !prev)}>
|
||||||
{open ? (
|
|
||||||
<ArrowDropDownIcon sx={{ color: '#566B7D' }} />
|
|
||||||
) : (
|
|
||||||
<ArrowRightIcon sx={{ color: '#566B7D' }} />
|
|
||||||
)}
|
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
color: '#98ACBD',
|
color: '#98ACBD',
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ const Container = styled('div')(({ theme }) => {
|
|||||||
return {
|
return {
|
||||||
width: '64px',
|
width: '64px',
|
||||||
height: '32px',
|
height: '32px',
|
||||||
backgroundColor: theme.affine.palette.textHover,
|
|
||||||
border: '1px solid #ECF1FB',
|
border: '1px solid #ECF1FB',
|
||||||
borderRadius: '8px',
|
borderRadius: '8px',
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ export const LayoutHeader = () => {
|
|||||||
size="large"
|
size="large"
|
||||||
hoverColor={'transparent'}
|
hoverColor={'transparent'}
|
||||||
disabled={true}
|
disabled={true}
|
||||||
|
style={{ cursor: 'not-allowed' }}
|
||||||
>
|
>
|
||||||
<SearchIcon />
|
<SearchIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
@@ -124,11 +125,11 @@ const StyledHelper = styled('div')({
|
|||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
});
|
});
|
||||||
|
|
||||||
const StyledShare = styled(MuiButton)<{ disabled?: boolean }>({
|
const StyledShare = styled('div')<{ disabled?: boolean }>({
|
||||||
padding: '10px 12px',
|
padding: '10px 12px',
|
||||||
fontWeight: 600,
|
fontWeight: 600,
|
||||||
fontSize: '14px',
|
fontSize: '14px',
|
||||||
cursor: 'pointer',
|
cursor: 'not-allowed',
|
||||||
color: '#98ACBD',
|
color: '#98ACBD',
|
||||||
textTransform: 'none',
|
textTransform: 'none',
|
||||||
/* disabled for current time */
|
/* disabled for current time */
|
||||||
|
|||||||
@@ -10,9 +10,10 @@ import {
|
|||||||
} from '@toeverything/components/ui';
|
} from '@toeverything/components/ui';
|
||||||
import { useNavigate } from 'react-router';
|
import { useNavigate } from 'react-router';
|
||||||
import { formatDistanceToNow } from 'date-fns';
|
import { formatDistanceToNow } from 'date-fns';
|
||||||
|
import { DotIcon } from '../dot-icon';
|
||||||
|
|
||||||
const StyledWrapper = styled('div')({
|
const StyledWrapper = styled('div')({
|
||||||
paddingLeft: '12px',
|
width: '100%',
|
||||||
span: {
|
span: {
|
||||||
textOverflow: 'ellipsis',
|
textOverflow: 'ellipsis',
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
@@ -22,8 +23,8 @@ const StyledWrapper = styled('div')({
|
|||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
paddingRight: '20px',
|
|
||||||
whiteSpace: 'nowrap',
|
whiteSpace: 'nowrap',
|
||||||
|
paddingLeft: '12px',
|
||||||
'&:hover': {
|
'&:hover': {
|
||||||
background: '#f5f7f8',
|
background: '#f5f7f8',
|
||||||
borderRadius: '5px',
|
borderRadius: '5px',
|
||||||
@@ -106,6 +107,8 @@ export const Activities = () => {
|
|||||||
const { id, title, updated } = item;
|
const { id, title, updated } = item;
|
||||||
return (
|
return (
|
||||||
<ListItem className="item" key={id}>
|
<ListItem className="item" key={id}>
|
||||||
|
<DotIcon />
|
||||||
|
|
||||||
<StyledItemContent
|
<StyledItemContent
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigate(`/${currentSpaceId}/${id}`);
|
navigate(`/${currentSpaceId}/${id}`);
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { PageInPageTreeIcon } from '@toeverything/components/icons';
|
||||||
|
|
||||||
|
export const DotIcon = () => {
|
||||||
|
return (
|
||||||
|
<PageInPageTreeIcon
|
||||||
|
style={{ fill: '#98ACBD', width: '20px', height: '20px' }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export { DotIcon } from './DotIcon';
|
||||||
@@ -44,7 +44,7 @@ export type DndTreeProps = {
|
|||||||
*/
|
*/
|
||||||
export function DndTree(props: DndTreeProps) {
|
export function DndTree(props: DndTreeProps) {
|
||||||
const {
|
const {
|
||||||
indentationWidth = 12,
|
indentationWidth = 20,
|
||||||
collapsible,
|
collapsible,
|
||||||
removable,
|
removable,
|
||||||
showDragIndicator,
|
showDragIndicator,
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ import { DndTree } from './DndTree';
|
|||||||
import { useDndTreeAutoUpdate } from './use-page-tree';
|
import { useDndTreeAutoUpdate } from './use-page-tree';
|
||||||
|
|
||||||
const Root = styled('div')({
|
const Root = styled('div')({
|
||||||
minWidth: 160,
|
minWidth: '160px',
|
||||||
maxWidth: 260,
|
maxWidth: '276px',
|
||||||
marginLeft: 18,
|
|
||||||
marginRight: 6,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const PageTree = () => {
|
export const PageTree = () => {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { useParams } from 'react-router-dom';
|
|||||||
import { useFlag } from '@toeverything/datasource/feature-flags';
|
import { useFlag } from '@toeverything/datasource/feature-flags';
|
||||||
|
|
||||||
import MoreActions from './MoreActions';
|
import MoreActions from './MoreActions';
|
||||||
|
import { DotIcon } from '../../dot-icon';
|
||||||
import {
|
import {
|
||||||
ActionButton,
|
ActionButton,
|
||||||
Counter,
|
Counter,
|
||||||
@@ -76,24 +77,25 @@ export const TreeItem = forwardRef<HTMLDivElement, TreeItemProps>(
|
|||||||
ghost={ghost}
|
ghost={ghost}
|
||||||
disableSelection={disableSelection}
|
disableSelection={disableSelection}
|
||||||
disableInteraction={disableInteraction}
|
disableInteraction={disableInteraction}
|
||||||
spacing={`${indentationWidth * depth}px`}
|
spacing={`${indentationWidth * depth + 12}px`}
|
||||||
|
active={pageId === page_id}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
<TreeItemContainer ref={ref} style={style} title={value}>
|
<TreeItemContainer ref={ref} style={style} title={value}>
|
||||||
<ActionButton tabIndex={0} onClick={onCollapse}>
|
<ActionButton tabIndex={0} onClick={onCollapse}>
|
||||||
{childCount !== 0 &&
|
{childCount !== 0 ? (
|
||||||
(collapsed ? (
|
collapsed ? (
|
||||||
<ArrowRightIcon />
|
<ArrowRightIcon />
|
||||||
) : (
|
) : (
|
||||||
<ArrowDropDownIcon />
|
<ArrowDropDownIcon />
|
||||||
))}
|
)
|
||||||
|
) : (
|
||||||
|
<DotIcon />
|
||||||
|
)}
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
|
|
||||||
<TreeItemContent {...handleProps}>
|
<TreeItemContent {...handleProps}>
|
||||||
<TextLink
|
<TextLink to={`/${workspace_id}/${pageId}`}>
|
||||||
to={`/${workspace_id}/${pageId}`}
|
|
||||||
active={pageId === page_id}
|
|
||||||
>
|
|
||||||
{value}
|
{value}
|
||||||
</TextLink>
|
</TextLink>
|
||||||
{BooleanPageTreeItemMoreActions && (
|
{BooleanPageTreeItemMoreActions && (
|
||||||
|
|||||||
@@ -15,11 +15,14 @@ export const Wrapper = styled('li')<{
|
|||||||
indicator?: boolean;
|
indicator?: boolean;
|
||||||
disableSelection?: boolean;
|
disableSelection?: boolean;
|
||||||
disableInteraction?: boolean;
|
disableInteraction?: boolean;
|
||||||
|
active?: boolean;
|
||||||
}>`
|
}>`
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding-left: ${({ spacing }) => spacing};
|
padding-left: ${({ spacing }) => spacing};
|
||||||
list-style: none;
|
list-style: none;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
background-color: ${({ active }) => (active ? '#f5f7f8' : 'transparent')};
|
||||||
|
border-radius: 5px;
|
||||||
|
|
||||||
${({ clone, disableSelection }) =>
|
${({ clone, disableSelection }) =>
|
||||||
(clone || disableSelection) &&
|
(clone || disableSelection) &&
|
||||||
@@ -126,8 +129,6 @@ export const ActionButton = styled('button')<{
|
|||||||
fill?: string;
|
fill?: string;
|
||||||
}>`
|
}>`
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 12px;
|
|
||||||
padding: 0 15px;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
@@ -141,9 +142,10 @@ export const ActionButton = styled('button')<{
|
|||||||
-webkit-tap-highlight-color: transparent;
|
-webkit-tap-highlight-color: transparent;
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
height: 100%;
|
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
fill: #919eab;
|
fill: #919eab;
|
||||||
}
|
}
|
||||||
@@ -182,8 +184,7 @@ export const TextLink = styled(Link, {
|
|||||||
appearance: none;
|
appearance: none;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
color: ${({ theme, active }) =>
|
color: #4c6275;
|
||||||
active ? theme.affine.palette.primary : 'unset'};
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const TreeItemContent = styled('div')`
|
export const TreeItemContent = styled('div')`
|
||||||
@@ -195,7 +196,7 @@ export const TreeItemContent = styled('div')`
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
color: #4c6275;
|
color: #4c6275;
|
||||||
padding-right: 0.5rem;
|
padding-right: 12px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
|||||||
Reference in New Issue
Block a user