fix: lint style

This commit is contained in:
DiamondThree
2023-01-31 16:53:16 +08:00
31 changed files with 529 additions and 489 deletions

View File

@@ -91,8 +91,6 @@ export const ContactModal = ({
<span>Alpha</span> <span>Alpha</span>
</StyledModalHeaderLeft> </StyledModalHeaderLeft>
<ModalCloseButton <ModalCloseButton
top={6}
right={6}
onClick={() => { onClick={() => {
onClose(); onClose();
}} }}

View File

@@ -29,8 +29,6 @@ export const DeleteModal = ({
<ModalWrapper width={620} height={334}> <ModalWrapper width={620} height={334}>
<Header> <Header>
<ModalCloseButton <ModalCloseButton
top={6}
right={6}
onClick={() => { onClick={() => {
onClose(); onClose();
}} }}

View File

@@ -14,8 +14,8 @@ import {
UndoIcon, UndoIcon,
RedoIcon, RedoIcon,
} from './Icons'; } from './Icons';
import { MuiSlide } from '@/ui/mui';
import { Tooltip } from '@/ui/tooltip'; import { Tooltip } from '@/ui/tooltip';
import Slide from '@mui/material/Slide';
import useCurrentPageMeta from '@/hooks/use-current-page-meta'; import useCurrentPageMeta from '@/hooks/use-current-page-meta';
import { useAppState } from '@/providers/app-state-provider'; import { useAppState } from '@/providers/app-state-provider';
import useHistoryUpdated from '@/hooks/use-history-update'; import useHistoryUpdated from '@/hooks/use-history-update';
@@ -127,7 +127,7 @@ export const EdgelessToolbar = () => {
const { mode } = useCurrentPageMeta() || {}; const { mode } = useCurrentPageMeta() || {};
return ( return (
<Slide <MuiSlide
direction="right" direction="right"
in={mode === 'edgeless'} in={mode === 'edgeless'}
mountOnEnter mountOnEnter
@@ -155,7 +155,7 @@ export const EdgelessToolbar = () => {
</StyledToolbarWrapper> </StyledToolbarWrapper>
<UndoRedo /> <UndoRedo />
</StyledEdgelessToolbar> </StyledEdgelessToolbar>
</Slide> </MuiSlide>
); );
}; };

View File

@@ -6,7 +6,7 @@ import {
StyledBrowserWarning, StyledBrowserWarning,
StyledCloseButton, StyledCloseButton,
} from './styles'; } from './styles';
import CloseIcon from '@mui/icons-material/Close'; import { CloseIcon } from '@blocksuite/icons';
import { useWarningMessage, shouldShowWarning } from './utils'; import { useWarningMessage, shouldShowWarning } from './utils';
import EditorOptionMenu from './header-right-items/EditorOptionMenu'; import EditorOptionMenu from './header-right-items/EditorOptionMenu';
import TrashButtonGroup from './header-right-items/TrashButtonGroup'; import TrashButtonGroup from './header-right-items/TrashButtonGroup';

View File

@@ -6,7 +6,7 @@ import {
StyledTransformIcon, StyledTransformIcon,
} from './style'; } from './style';
import { CloseIcon, ContactIcon, HelpIcon, KeyboardIcon } from './Icons'; import { CloseIcon, ContactIcon, HelpIcon, KeyboardIcon } from './Icons';
import Grow from '@mui/material/Grow'; import { MuiGrow } from '@/ui/mui';
import { Tooltip } from '@/ui/tooltip'; import { Tooltip } from '@/ui/tooltip';
import { useTranslation } from '@affine/i18n'; import { useTranslation } from '@affine/i18n';
import { useModal } from '@/providers/GlobalModalProvider'; import { useModal } from '@/providers/GlobalModalProvider';
@@ -35,7 +35,7 @@ export const HelpIsland = ({
setShowContent(false); setShowContent(false);
}} }}
> >
<Grow in={showContent}> <MuiGrow in={showContent}>
<StyledIslandWrapper> <StyledIslandWrapper>
{showList.includes('contact') && ( {showList.includes('contact') && (
<Tooltip content={t('Contact Us')} placement="left-end"> <Tooltip content={t('Contact Us')} placement="left-end">
@@ -66,7 +66,7 @@ export const HelpIsland = ({
</Tooltip> </Tooltip>
)} )}
</StyledIslandWrapper> </StyledIslandWrapper>
</Grow> </MuiGrow>
<div style={{ position: 'relative' }}> <div style={{ position: 'relative' }}>
<StyledIconWrapper <StyledIconWrapper

View File

@@ -14,8 +14,6 @@ export const LoginModal = ({ open, onClose }: LoginModalProps) => {
<ModalWrapper width={560} height={292}> <ModalWrapper width={560} height={292}>
<Header> <Header>
<ModalCloseButton <ModalCloseButton
top={6}
right={6}
onClick={() => { onClick={() => {
onClose(); onClose();
}} }}

View File

@@ -15,8 +15,6 @@ export const LogoutModal = ({ open, onClose }: LoginModalProps) => {
<ModalWrapper width={560} height={292}> <ModalWrapper width={560} height={292}>
<Header> <Header>
<ModalCloseButton <ModalCloseButton
top={6}
right={6}
onClick={() => { onClick={() => {
onClose(true); onClose(true);
}} }}

View File

@@ -13,7 +13,7 @@ import {
useWindowsKeyboardShortcuts, useWindowsKeyboardShortcuts,
useWinMarkdownShortcuts, useWinMarkdownShortcuts,
} from '@/components/shortcuts-modal/config'; } from '@/components/shortcuts-modal/config';
import Slide from '@mui/material/Slide'; import { MuiSlide } from '@/ui/mui';
import { ModalCloseButton } from '@/ui/modal'; import { ModalCloseButton } from '@/ui/modal';
import { getUaHelper } from '@/utils'; import { getUaHelper } from '@/utils';
import { useTranslation } from '@affine/i18n'; import { useTranslation } from '@affine/i18n';
@@ -40,7 +40,7 @@ export const ShortcutsModal = ({ open, onClose }: ModalProps) => {
: windowsKeyboardShortcuts; : windowsKeyboardShortcuts;
return createPortal( return createPortal(
<Slide direction="left" in={open} mountOnEnter unmountOnExit> <MuiSlide direction="left" in={open} mountOnEnter unmountOnExit>
<StyledShortcutsModal data-testid="shortcuts-modal"> <StyledShortcutsModal data-testid="shortcuts-modal">
<> <>
<StyledModalHeader> <StyledModalHeader>
@@ -81,7 +81,7 @@ export const ShortcutsModal = ({ open, onClose }: ModalProps) => {
})} })}
</> </>
</StyledShortcutsModal> </StyledShortcutsModal>
</Slide>, </MuiSlide>,
document.body document.body
); );
}; };

View File

@@ -0,0 +1,56 @@
import { CloudInsyncIcon, LogOutIcon } from '@blocksuite/icons';
import { Wrapper } from '@/ui/layout';
import { WorkspaceAvatar } from '@/components/workspace-avatar';
import { IconButton } from '@/ui/button';
import { useAppState } from '@/providers/app-state-provider';
import { StyledFooter, StyleUserInfo, StyleSignIn } from './styles';
export const Footer = ({
onLogin,
onLogout,
}: {
onLogin: () => void;
onLogout: () => void;
}) => {
const { user } = useAppState();
return (
<StyledFooter>
{user && (
<>
<Wrapper>
<WorkspaceAvatar
size={40}
name={user.name}
avatar={user.avatar}
></WorkspaceAvatar>
<StyleUserInfo>
<p>{user.name}</p>
<p>{user.email}</p>
</StyleUserInfo>
</Wrapper>
<IconButton
onClick={() => {
onLogout();
}}
>
<LogOutIcon />
</IconButton>
</>
)}
{!user && (
<StyleSignIn
onClick={async () => {
onLogin();
}}
>
<span>
<CloudInsyncIcon fontSize={16} />
</span>
Sign in to sync with AFFINE Cloud
</StyleSignIn>
)}
</StyledFooter>
);
};

View File

@@ -0,0 +1,61 @@
import { LOCALES } from '@affine/i18n';
import { styled } from '@/styles';
import { useTranslation } from '@affine/i18n';
import { ArrowDownIcon } from '@blocksuite/icons';
import { Button } from '@/ui/button';
import { Menu, MenuItem } from '@/ui/menu';
const LanguageMenuContent = () => {
const { i18n } = useTranslation();
const changeLanguage = (event: string) => {
i18n.changeLanguage(event);
};
return (
<>
{LOCALES.map(option => {
return (
<ListItem
key={option.name}
title={option.name}
onClick={() => {
changeLanguage(option.tag);
}}
>
{option.originalName}
</ListItem>
);
})}
</>
);
};
export const LanguageMenu = () => {
const { i18n } = useTranslation();
const currentLanguage = LOCALES.find(item => item.tag === i18n.language);
return (
<Menu
content={<LanguageMenuContent />}
placement="bottom"
trigger="click"
disablePortal={true}
>
<Button
icon={<ArrowDownIcon />}
iconPosition="end"
noBorder={true}
style={{ textTransform: 'capitalize' }}
>
{currentLanguage?.originalName}
</Button>
</Menu>
);
};
const ListItem = styled(MenuItem)(({ theme }) => ({
height: '38px',
color: theme.colors.popoverColor,
fontSize: theme.font.sm,
textTransform: 'capitalize',
padding: '0 24px',
}));

View File

@@ -0,0 +1,69 @@
import { WorkspaceUnitAvatar } from '@/components/workspace-avatar';
import {
CloudIcon,
LocalIcon,
OfflineIcon,
} from '@/components/workspace-modal/icons';
import { PublishIcon, UsersIcon } from '@blocksuite/icons';
import { WorkspaceUnit } from '@affine/datacenter';
import { useAppState } from '@/providers/app-state-provider';
import { StyleWorkspaceInfo, StyleWorkspaceTitle, StyledCard } from './styles';
import { Wrapper } from '@/ui/layout';
export const WorkspaceCard = ({
workspaceData,
onClick,
}: {
workspaceData: WorkspaceUnit;
onClick: (data: WorkspaceUnit) => void;
}) => {
const { currentWorkspace, isOwner } = useAppState();
return (
<StyledCard
onClick={() => {
onClick(workspaceData);
}}
active={workspaceData.id === currentWorkspace?.id}
>
<Wrapper>
<WorkspaceUnitAvatar size={58} workspaceUnit={workspaceData} />
</Wrapper>
<StyleWorkspaceInfo>
<StyleWorkspaceTitle>
{workspaceData.name || 'AFFiNE'}
</StyleWorkspaceTitle>
{isOwner ? (
workspaceData.provider === 'local' ? (
<p>
<LocalIcon />
Local Workspace
</p>
) : (
<p>
<CloudIcon />
Cloud Workspace
</p>
)
) : (
<p>
<UsersIcon fontSize={20} color={'#FF646B'} />
Joined Workspace
</p>
)}
{workspaceData.provider === 'local' && (
<p>
<OfflineIcon />
All data can be accessed offline
</p>
)}
{workspaceData.published && (
<p>
<PublishIcon fontSize={16} /> Published to Web
</p>
)}
</StyleWorkspaceInfo>
</StyledCard>
);
};

View File

@@ -1,33 +1,34 @@
import { styled } from '@/styles'; import { Modal, ModalWrapper, ModalCloseButton } from '@/ui/modal';
import { Modal, ModalWrapper } from '@/ui/modal'; import { Wrapper } from '@/ui/layout';
import { Button, IconButton } from '@/ui/button';
import { useState } from 'react'; import { useState } from 'react';
import { CreateWorkspaceModal } from '../create-workspace'; import { CreateWorkspaceModal } from '../create-workspace';
import {
UsersIcon, import { Tooltip } from '@/ui/tooltip';
AddIcon,
LogOutIcon, import { AddIcon, HelpCenterIcon } from '@blocksuite/icons';
CloudInsyncIcon,
CloseIcon,
} from '@blocksuite/icons';
import {
WorkspaceAvatar,
WorkspaceUnitAvatar,
} from '@/components/workspace-avatar';
import { useAppState } from '@/providers/app-state-provider'; import { useAppState } from '@/providers/app-state-provider';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import { useTranslation } from '@affine/i18n'; import { useTranslation } from '@affine/i18n';
import { LanguageMenu } from './languageMenu'; import { LanguageMenu } from './SelectLanguageMenu';
import {
CloudIcon,
LineIcon,
LocalIcon,
OfflineIcon,
PublishedIcon,
} from './icons';
import { LoginModal } from '../login-modal'; import { LoginModal } from '../login-modal';
import { LogoutModal } from '../logout-modal'; import { LogoutModal } from '../logout-modal';
import {
StyledCard,
StyledSplitLine,
StyleWorkspaceInfo,
StyleWorkspaceTitle,
StyledModalHeaderLeft,
StyledModalTitle,
StyledHelperContainer,
StyledModalContent,
StyledOperationWrapper,
StyleWorkspaceAdd,
StyledModalHeader,
} from './styles';
import { WorkspaceCard } from './WorkspaceCard';
import { Footer } from './Footer';
interface WorkspaceModalProps { interface WorkspaceModalProps {
open: boolean; open: boolean;
onClose: () => void; onClose: () => void;
@@ -35,337 +36,115 @@ interface WorkspaceModalProps {
export const WorkspaceModal = ({ open, onClose }: WorkspaceModalProps) => { export const WorkspaceModal = ({ open, onClose }: WorkspaceModalProps) => {
const [createWorkspaceOpen, setCreateWorkspaceOpen] = useState(false); const [createWorkspaceOpen, setCreateWorkspaceOpen] = useState(false);
const { workspaceList, currentWorkspace, user, logout, isOwner } = const { workspaceList, logout } = useAppState();
useAppState();
const router = useRouter(); const router = useRouter();
const { t } = useTranslation(); const { t } = useTranslation();
const [loginOpen, setLoginOpen] = useState(false); const [loginOpen, setLoginOpen] = useState(false);
const [logoutOpen, setLogoutOpen] = useState(false); const [logoutOpen, setLogoutOpen] = useState(false);
return ( return (
<div> <>
<Modal open={open} onClose={onClose}> <Modal open={open} onClose={onClose}>
<ModalWrapper <ModalWrapper
width={720} width={720}
height={690}
style={{ style={{
padding: '24px 40px',
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
}} }}
> >
<Header> <StyledModalHeader>
<ContentTitle>{t('My Workspaces')}</ContentTitle> <StyledModalHeaderLeft>
<HeaderOption> <StyledModalTitle>{t('My Workspaces')}</StyledModalTitle>
<LanguageMenu /> <Tooltip
<div content={t(
style={{ 'A workspace is your virtual space to capture, create and plan as just one person or together as a team.'
display: 'inline-block', )}
border: 'none', placement="top-start"
margin: '2px 16px', disablePortal={true}
height: '24px',
position: 'relative',
top: '4px',
}}
> >
<LineIcon></LineIcon> <StyledHelperContainer>
</div> <HelpCenterIcon />
</StyledHelperContainer>
</Tooltip>
</StyledModalHeaderLeft>
<Button <StyledOperationWrapper>
style={{ border: 'none', padding: 0 }} <LanguageMenu />
<StyledSplitLine />
<ModalCloseButton
onClick={() => { onClick={() => {
onClose(); onClose();
}} }}
> absolute={false}
<CloseIcon></CloseIcon> />
</Button> </StyledOperationWrapper>
</HeaderOption> </StyledModalHeader>
</Header>
<Content>
<WorkspaceList>
{workspaceList.map((item, index) => {
return (
<WorkspaceItem
onClick={() => {
router.replace(`/workspace/${item.id}`);
onClose();
}}
active={item.id === currentWorkspace?.id}
key={index}
>
<div>
<WorkspaceUnitAvatar size={58} workspaceUnit={item} />
</div>
<StyleWorkspaceInfo> <StyledModalContent>
<StyleWorkspaceTitle> {workspaceList.map((item, index) => {
{item.name || 'AFFiNE'} return (
</StyleWorkspaceTitle> <WorkspaceCard
{isOwner ? ( workspaceData={item}
item.provider === 'local' ? ( onClick={workspaceData => {
<p> router.replace(`/workspace/${workspaceData.id}`);
<LocalIcon /> onClose();
Local Workspace }}
</p> key={index}
) : ( ></WorkspaceCard>
<p> );
<CloudIcon /> })}
Cloud Workspace <StyledCard
</p> onClick={() => {
) setCreateWorkspaceOpen(true);
) : ( }}
<p> >
<UsersIcon fontSize={20} color={'#FF646B'} /> <Wrapper>
Joined Workspace <StyleWorkspaceAdd className="add-icon">
</p> <AddIcon fontSize={18} />
)} </StyleWorkspaceAdd>
{item.provider === 'local' && ( </Wrapper>
<p>
<OfflineIcon />
All data can be accessed offline
</p>
)}
{item.published && (
<p>
<PublishedIcon /> Published to Web
</p>
)}
</StyleWorkspaceInfo>
</WorkspaceItem>
);
})}
<WorkspaceItem
onClick={() => {
setCreateWorkspaceOpen(true);
}}
>
<div>
<StyleWorkspaceAdd className="add-icon">
<AddIcon fontSize={18} />
</StyleWorkspaceAdd>
</div>
<StyleWorkspaceInfo> <StyleWorkspaceInfo>
<StyleWorkspaceTitle>New workspace</StyleWorkspaceTitle> <StyleWorkspaceTitle>New workspace</StyleWorkspaceTitle>
<p>Crete or import</p> <p>Crete or import</p>
</StyleWorkspaceInfo> </StyleWorkspaceInfo>
</WorkspaceItem> </StyledCard>
</WorkspaceList> </StyledModalContent>
{/* <p style={{ fontSize: '14px', color: '#ccc', margin: '12px 0' }}>
{t('Tips')} <Footer
{t('Workspace description')} onLogin={() => {
</p> */} setLoginOpen(true);
</Content>
<LoginModal
open={loginOpen}
onClose={() => {
setLoginOpen(false);
}} }}
></LoginModal> onLogout={() => {
<Footer> setLogoutOpen(true);
{!user ? (
<StyleSignIn
onClick={async () => {
setLoginOpen(true);
}}
>
<span>
<CloudInsyncIcon fontSize={16} />
</span>
Sign in to sync with AFFINE Cloud
</StyleSignIn>
) : (
<div style={{ display: 'flex' }}>
<div style={{ paddingTop: '20px' }}>
<WorkspaceAvatar
size={40}
name={user.name}
avatar={user.avatar}
></WorkspaceAvatar>
</div>
<StyleUserInfo style={{}}>
<p>{user.name}</p>
<p>{user.email}</p>
</StyleUserInfo>
<div style={{ paddingTop: '25px' }}>
<IconButton
onClick={() => {
setLogoutOpen(true);
// confirm({
// title: 'Sign out?',
// content: `All data has been stored in the cloud. `,
// confirmText: 'Sign out',
// cancelText: 'Cancel',
// }).then(async confirm => {
// // if (confirm) {
// // if (user) {
// // await logout();
// // router.replace(`/workspace`);
// // toast('Enabled success');
// // }
// // }
// });
}}
>
<LogOutIcon></LogOutIcon>
</IconButton>
</div>
</div>
)}
</Footer>
<CreateWorkspaceModal
open={createWorkspaceOpen}
onClose={() => {
setCreateWorkspaceOpen(false);
}} }}
></CreateWorkspaceModal> />
<LogoutModal
open={logoutOpen}
onClose={async wait => {
if (!wait) {
await logout();
router.replace(`/workspace`);
}
setLogoutOpen(false);
}}
></LogoutModal>
</ModalWrapper> </ModalWrapper>
</Modal> </Modal>
</div>
<LoginModal
open={loginOpen}
onClose={() => {
setLoginOpen(false);
}}
/>
<LogoutModal
open={logoutOpen}
onClose={async wait => {
if (!wait) {
await logout();
router.replace(`/workspace`);
}
setLogoutOpen(false);
}}
/>
<CreateWorkspaceModal
open={createWorkspaceOpen}
onClose={() => {
setCreateWorkspaceOpen(false);
}}
/>
</>
); );
}; };
const Header = styled('div')({
display: 'flex',
});
const Content = styled('div')({
flexDirection: 'column',
alignItems: 'center',
gap: '16px',
flex: 1,
});
const HeaderOption = styled.div(() => {
return {
marginLeft: '16px',
};
});
const ContentTitle = styled('div')({
fontSize: '20px',
lineHeight: '24px',
fontWeight: 600,
textAlign: 'left',
flex: 1,
});
const WorkspaceList = styled('div')({
maxHeight: '500px',
overflow: 'auto',
display: 'grid',
gridRowGap: '24px',
gridColumnGap: '24px',
fontSize: '16px',
marginTop: '36px',
gridTemplateColumns: 'repeat(2, 1fr)',
});
export const WorkspaceItem = styled.div<{
active?: boolean;
}>(({ theme, active }) => {
const borderColor = active ? theme.colors.primaryColor : 'transparent';
return {
cursor: 'pointer',
padding: '16px',
height: '124px',
boxShadow: theme.shadow.modal,
display: 'flex',
borderRadius: '12px',
border: `1px solid ${borderColor}`,
':hover': {
background: theme.colors.hoverBackground,
'.add-icon': {
border: `1.5px dashed ${theme.colors.primaryColor}`,
svg: {
fill: theme.colors.primaryColor,
},
},
},
};
});
const StyleWorkspaceInfo = styled.div(({ theme }) => {
return {
marginLeft: '16px',
p: {
fontSize: theme.font.xs,
lineHeight: '16px',
},
svg: {
verticalAlign: 'text-bottom',
marginRight: '8px',
},
};
});
const StyleWorkspaceTitle = styled.div(({ theme }) => {
return {
fontSize: theme.font.base,
fontWeight: 600,
lineHeight: '24px',
marginBottom: '8px',
};
});
const StyleWorkspaceAdd = styled.div(() => {
return {
width: '58px',
height: '58px',
borderRadius: '100%',
textAlign: 'center',
background: '#f4f5fa',
border: '1.5px dashed #f4f5fa',
lineHeight: '58px',
marginTop: '2px',
};
});
const Footer = styled('div')({
paddingTop: '16px',
});
const StyleUserInfo = styled.div(({ theme }) => {
return {
textAlign: 'left',
marginLeft: '16px',
marginTop: '16px',
flex: 1,
p: {
lineHeight: '24px',
color: theme.colors.iconColor,
},
'p:nth-child(1)': {
color: theme.colors.textColor,
fontWeight: 600,
},
};
});
const StyleSignIn = styled.div(({ theme }) => {
return {
cursor: 'pointer',
fontSize: '16px',
fontWeight: 700,
color: theme.colors.iconColor,
span: {
display: 'inline-block',
width: '40px',
height: '40px',
borderRadius: '40px',
backgroundColor: theme.colors.innerHoverBackground,
textAlign: 'center',
lineHeight: '44px',
marginRight: '16px',
svg: {
fill: theme.colors.primaryColor,
},
},
};
});

View File

@@ -1,93 +0,0 @@
import { LOCALES } from '@affine/i18n';
import { TooltipProps } from '@mui/material';
import { styled } from '@/styles';
import { Tooltip } from '@mui/material';
import { useState } from 'react';
import { useTranslation } from '@affine/i18n';
import { ArrowDownIcon } from '@blocksuite/icons';
import { Button } from '@/ui/button';
export const LanguageMenu = () => {
const { i18n } = useTranslation();
const changeLanguage = (event: string) => {
i18n.changeLanguage(event);
};
const [show, setShow] = useState(false);
const currentLanguage = LOCALES.find(item => item.tag === i18n.language);
const [languageName, setLanguageName] = useState(
currentLanguage?.originalName
);
return (
<StyledTooltip
title={
<>
{LOCALES.map(option => {
return (
<ListItem
style={{ border: 'none' }}
key={option.name}
title={option.name}
onClick={() => {
changeLanguage(option.tag);
setShow(false);
setLanguageName(option.originalName);
}}
>
{option.originalName}
</ListItem>
);
})}
</>
}
open={show}
>
<StyledTitleButton
style={{ border: 'none', padding: '0px' }}
onClick={() => {
setShow(!show);
}}
>
<StyledContainer>
<StyledText>{languageName}</StyledText>
<ArrowDownIcon fontSize={18} />
</StyledContainer>
</StyledTitleButton>
</StyledTooltip>
);
};
const StyledContainer = styled('div')(() => ({
display: 'flex',
alignItems: 'center',
}));
const StyledText = styled('span')(({ theme }) => ({
marginRight: '4px',
marginLeft: '16px',
fontSize: theme.font.sm,
fontWeight: '500',
textTransform: 'capitalize',
}));
const StyledTooltip = styled(({ className, ...props }: TooltipProps) => (
<Tooltip {...props} classes={{ popper: className }} />
))(({ theme }) => ({
zIndex: theme.zIndex.modal,
'& .MuiTooltip-tooltip': {
backgroundColor: theme.colors.popoverBackground,
boxShadow: theme.shadow.modal,
color: theme.colors.popoverColor,
},
}));
const ListItem = styled(Button)(({ theme }) => ({
display: 'block',
width: '100%',
color: theme.colors.popoverColor,
fontSize: theme.font.sm,
textTransform: 'capitalize',
}));
const StyledTitleButton = styled(Button)(({ theme }) => ({
color: theme.colors.popoverColor,
fontSize: theme.font.sm,
}));

View File

@@ -1,38 +1,161 @@
import { displayFlex, styled } from '@/styles'; import { displayFlex, styled } from '@/styles';
export const StyledTitle = styled.div(() => { export const StyledSplitLine = styled.div(({ theme }) => {
return { return {
...displayFlex('center', 'center'), width: '1px',
fontSize: '20px', height: '20px',
fontWeight: 500, background: theme.colors.iconColor,
marginTop: '60px', marginRight: '24px',
lineHeight: 1,
}; };
}); });
export const StyledContent = styled.div(() => { export const StyleWorkspaceInfo = styled.div(({ theme }) => {
return { return {
padding: '0 40px', marginLeft: '15px',
marginTop: '32px', p: {
fontSize: '18px', height: '20px',
lineHeight: '25px', fontSize: theme.font.xs,
'p:not(last-of-type)': { ...displayFlex('flex-start', 'center'),
marginBottom: '10px', },
svg: {
marginRight: '10px',
}, },
}; };
}); });
export const StyledButton = styled.div(({ theme }) => { export const StyleWorkspaceTitle = styled.div(({ theme }) => {
return { return {
width: '146px', fontSize: theme.font.base,
height: '42px', fontWeight: 600,
background: theme.colors.primaryColor, lineHeight: '24px',
color: '#FFFFFF', marginBottom: '10px',
fontSize: '18px', };
fontWeight: 500, });
borderRadius: '21px',
margin: '52px auto 0', export const StyledCard = styled.div<{
active?: boolean;
}>(({ theme, active }) => {
const borderColor = active ? theme.colors.primaryColor : 'transparent';
return {
width: '310px',
height: '124px',
cursor: 'pointer', cursor: 'pointer',
padding: '16px',
boxShadow: '0px 0px 8px rgba(0, 0, 0, 0.1)',
borderRadius: '12px',
border: `1px solid ${borderColor}`,
...displayFlex('flex-start', 'flex-start'),
':hover': {
background: theme.colors.hoverBackground,
'.add-icon': {
border: `1.5px dashed ${theme.colors.primaryColor}`,
svg: {
fill: theme.colors.primaryColor,
},
},
},
};
});
export const StyledFooter = styled('div')({
height: '84px',
padding: '0 40px',
...displayFlex('space-between', 'center'),
});
export const StyleUserInfo = styled.div(({ theme }) => {
return {
textAlign: 'left',
marginLeft: '16px',
flex: 1,
p: {
lineHeight: '24px',
color: theme.colors.iconColor,
},
'p:nth-child(1)': {
color: theme.colors.textColor,
fontWeight: 600,
},
};
});
export const StyleSignIn = styled.div(({ theme }) => {
return {
cursor: 'pointer',
fontSize: '16px',
fontWeight: 700,
color: theme.colors.iconColor,
span: {
display: 'inline-block',
width: '40px',
height: '40px',
borderRadius: '40px',
backgroundColor: theme.colors.innerHoverBackground,
textAlign: 'center',
lineHeight: '44px',
marginRight: '16px',
svg: {
fill: theme.colors.primaryColor,
},
},
};
});
export const StyledModalHeaderLeft = styled.div(() => {
return { ...displayFlex('flex-start', 'center') };
});
export const StyledModalTitle = styled.div(({ theme }) => {
return {
fontWeight: 600,
fontSize: theme.font.h6,
};
});
export const StyledHelperContainer = styled.div(({ theme }) => {
return {
color: theme.colors.iconColor,
marginLeft: '15px',
fontWeight: 400,
...displayFlex('center', 'center'), ...displayFlex('center', 'center'),
}; };
}); });
export const StyledModalContent = styled('div')({
height: '534px',
padding: '8px 40px',
marginTop: '72px',
overflow: 'auto',
...displayFlex('space-between', 'flex-start', 'column'),
flexWrap: 'wrap',
});
export const StyledOperationWrapper = styled.div(() => {
return {
...displayFlex('flex-end', 'center'),
};
});
export const StyleWorkspaceAdd = styled.div(() => {
return {
width: '58px',
height: '58px',
borderRadius: '100%',
textAlign: 'center',
background: '#f4f5fa',
border: '1.5px dashed #f4f5fa',
lineHeight: '58px',
marginTop: '2px',
};
});
export const StyledModalHeader = styled('div')(({ theme }) => {
return {
width: '100%',
height: '72px',
position: 'absolute',
left: 0,
top: 0,
background: theme.colors.pageBackground,
borderRadius: '24px 24px 0 0',
padding: '0 40px',
...displayFlex('space-between', 'center'),
};
});

View File

@@ -1,5 +1,5 @@
import { displayFlex, styled } from '@/styles'; import { displayFlex, styled } from '@/styles';
import MuiAvatar from '@mui/material/Avatar'; import { MuiAvatar } from '@/ui/mui';
import IconButton from '@/ui/button/IconButton'; import IconButton from '@/ui/button/IconButton';
import Input from '@/ui/input'; import Input from '@/ui/input';

View File

@@ -4,7 +4,7 @@ import { Modal, ModalWrapper, ModalCloseButton } from '@/ui/modal';
import { Button } from '@/ui/button'; import { Button } from '@/ui/button';
import Input from '@/ui/input'; import Input from '@/ui/input';
import { useState } from 'react'; import { useState } from 'react';
import { Avatar } from '@mui/material'; import { MuiAvatar } from '@/ui/mui';
import useMembers from '@/hooks/use-members'; import useMembers from '@/hooks/use-members';
import { User } from '@affine/datacenter'; import { User } from '@affine/datacenter';
import { useTranslation } from '@affine/i18n'; import { useTranslation } from '@affine/i18n';
@@ -76,8 +76,6 @@ export const InviteMemberModal = ({
<ModalWrapper width={460} height={236}> <ModalWrapper width={460} height={236}>
<Header> <Header>
<ModalCloseButton <ModalCloseButton
top={6}
right={6}
onClick={() => { onClick={() => {
onClose(); onClose();
}} }}
@@ -102,7 +100,7 @@ export const InviteMemberModal = ({
) : ( ) : (
<Member> <Member>
{userData?.avatar ? ( {userData?.avatar ? (
<Avatar src={userData?.avatar}></Avatar> <MuiAvatar src={userData?.avatar}></MuiAvatar>
) : ( ) : (
<MemberIcon> <MemberIcon>
<EmailIcon></EmailIcon> <EmailIcon></EmailIcon>

View File

@@ -1,5 +1,5 @@
import { styled } from '@/styles'; import { styled } from '@/styles';
import MuiAvatar from '@mui/material/Avatar'; import { MuiAvatar } from '@/ui/mui';
export const StyledMemberTitleContainer = styled('li')(() => { export const StyledMemberTitleContainer = styled('li')(() => {
return { return {

View File

@@ -1,4 +1,4 @@
import MuiAvatar from '@mui/material/Avatar'; import { MuiAvatar } from '@/ui/mui';
import { styled } from '@/styles'; import { styled } from '@/styles';
export const WorkspaceItemWrapper = styled('div')(({ theme }) => ({ export const WorkspaceItemWrapper = styled('div')(({ theme }) => ({

View File

@@ -1,4 +1,4 @@
import MuiAvatar from '@mui/material/Avatar'; import { MuiAvatar } from '@/ui/mui';
import { styled } from '@/styles'; import { styled } from '@/styles';
import { StyledPopperContainer } from '@/ui/shared/Container'; import { StyledPopperContainer } from '@/ui/shared/Container';

View File

@@ -11,7 +11,6 @@ import {
StyledSubListItem, StyledSubListItem,
} from './style'; } from './style';
import { Arrow } from './icons'; import { Arrow } from './icons';
import Collapse from '@mui/material/Collapse';
import { import {
ArrowDownIcon, ArrowDownIcon,
SearchIcon, SearchIcon,
@@ -22,6 +21,7 @@ import {
SettingsIcon, SettingsIcon,
} from '@blocksuite/icons'; } from '@blocksuite/icons';
import Link from 'next/link'; import Link from 'next/link';
import { MuiCollapse } from '@/ui/mui';
import { Tooltip } from '@/ui/tooltip'; import { Tooltip } from '@/ui/tooltip';
import { useModal } from '@/providers/GlobalModalProvider'; import { useModal } from '@/providers/GlobalModalProvider';
import { useAppState } from '@/providers/app-state-provider'; import { useAppState } from '@/providers/app-state-provider';
@@ -38,7 +38,7 @@ const FavoriteList = ({ showList }: { showList: boolean }) => {
const { t } = useTranslation(); const { t } = useTranslation();
const favoriteList = pageList.filter(p => p.favorite && !p.trash); const favoriteList = pageList.filter(p => p.favorite && !p.trash);
return ( return (
<Collapse in={showList}> <MuiCollapse in={showList}>
{favoriteList.map((pageMeta, index) => { {favoriteList.map((pageMeta, index) => {
const active = router.query.pageId === pageMeta.id; const active = router.query.pageId === pageMeta.id;
return ( return (
@@ -60,7 +60,7 @@ const FavoriteList = ({ showList }: { showList: boolean }) => {
{favoriteList.length === 0 && ( {favoriteList.length === 0 && (
<StyledSubListItem disable={true}>{t('No item')}</StyledSubListItem> <StyledSubListItem disable={true}>{t('No item')}</StyledSubListItem>
)} )}
</Collapse> </MuiCollapse>
); );
}; };
export const WorkSpaceSliderBar = () => { export const WorkSpaceSliderBar = () => {

View File

@@ -1,7 +1,6 @@
import { useWorkspaceHelper } from '@/hooks/use-workspace-helper'; import { useWorkspaceHelper } from '@/hooks/use-workspace-helper';
import { styled } from '@/styles'; import { styled } from '@/styles';
import { Empty } from '@/ui/empty'; import { Empty } from '@/ui/empty';
// import { Avatar } from '@mui/material';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';

View File

@@ -117,3 +117,29 @@ export const textEllipsis = (lineNum = 1): CSSProperties => {
whiteSpace: 'nowrap', whiteSpace: 'nowrap',
}; };
}; };
export const positionAbsolute = ({
left,
top,
right,
bottom,
}: {
left?: CSSProperties['left'];
top?: CSSProperties['top'];
right?: CSSProperties['right'];
bottom?: CSSProperties['bottom'];
}): {
position: CSSProperties['position'];
left: CSSProperties['left'];
top: CSSProperties['top'];
right: CSSProperties['right'];
bottom: CSSProperties['bottom'];
} => {
return {
position: 'absolute',
left,
top,
right,
bottom,
};
};

View File

@@ -15,16 +15,26 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
hoverStyle, hoverStyle,
shape = 'default', shape = 'default',
icon, icon,
iconPosition = 'start',
type = 'default', type = 'default',
children, children,
bold = false, bold = false,
loading = false, loading = false,
noBorder = false,
...props ...props
}, },
ref ref
) => { ) => {
const { iconSize } = getSize(size); const { iconSize } = getSize(size);
const iconElement =
icon &&
cloneElement(Children.only(icon), {
width: iconSize,
height: iconSize,
className: `affine-button-icon ${icon.props.className ?? ''}`,
});
return ( return (
<StyledButton <StyledButton
ref={ref} ref={ref}
@@ -38,19 +48,16 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
// @ts-ignore // @ts-ignore
type={type} type={type}
bold={bold} bold={bold}
noBorder={noBorder}
{...props} {...props}
> >
{loading ? ( {loading ? (
<Loading type={type}></Loading> <Loading type={type}></Loading>
) : ( ) : (
<> <>
{icon && {iconPosition === 'start' && iconElement}
cloneElement(Children.only(icon), {
width: iconSize,
height: iconSize,
className: `affine-button-icon ${icon.props.className ?? ''}`,
})}
{children && <span>{children}</span>} {children && <span>{children}</span>}
{iconPosition === 'end' && iconElement}
</> </>
)} )}
</StyledButton> </StyledButton>

View File

@@ -17,8 +17,10 @@ export type ButtonProps = PropsWithChildren &
hoverColor?: CSSProperties['color']; hoverColor?: CSSProperties['color'];
hoverStyle?: CSSProperties; hoverStyle?: CSSProperties;
icon?: ReactElement; icon?: ReactElement;
iconPosition?: 'start' | 'end';
shape?: 'default' | 'round' | 'circle'; shape?: 'default' | 'round' | 'circle';
type?: 'primary' | 'warning' | 'danger' | 'default'; type?: 'primary' | 'warning' | 'danger' | 'default';
bold?: boolean; bold?: boolean;
loading?: boolean; loading?: boolean;
noBorder?: boolean;
}; };

View File

@@ -149,6 +149,7 @@ export const StyledButton = styled('button', {
'hoverStyle', 'hoverStyle',
'type', 'type',
'bold', 'bold',
'noBorder',
].includes(prop); ].includes(prop);
}, },
})< })<
@@ -162,6 +163,7 @@ export const StyledButton = styled('button', {
| 'shape' | 'shape'
| 'type' | 'type'
| 'bold' | 'bold'
| 'noBorder'
> >
>( >(
({ ({
@@ -174,6 +176,7 @@ export const StyledButton = styled('button', {
bold = false, bold = false,
shape = 'default', shape = 'default',
type = 'default', type = 'default',
noBorder = false,
}) => { }) => {
const { fontSize, borderRadius, padding, height } = getSize(size); const { fontSize, borderRadius, padding, height } = getSize(size);
@@ -181,7 +184,7 @@ export const StyledButton = styled('button', {
height, height,
paddingLeft: padding, paddingLeft: padding,
paddingRight: padding, paddingRight: padding,
border: '1px solid', border: noBorder ? 'none' : '1px solid',
...displayInlineFlex('center', 'center'), ...displayInlineFlex('center', 'center'),
position: 'relative', position: 'relative',
// TODO: disabled color is not decided // TODO: disabled color is not decided

View File

@@ -5,6 +5,7 @@ import { styled } from '@/styles';
export type ModalCloseButtonProps = { export type ModalCloseButtonProps = {
top?: number; top?: number;
right?: number; right?: number;
absolute?: boolean;
} & Omit<IconButtonProps, 'children'> & } & Omit<IconButtonProps, 'children'> &
HTMLAttributes<HTMLButtonElement>; HTMLAttributes<HTMLButtonElement>;
@@ -13,16 +14,23 @@ const StyledIconButton = styled(IconButton)<
>(({ top, right }) => { >(({ top, right }) => {
return { return {
position: 'absolute', position: 'absolute',
top: top ?? 6, top: top ?? 24,
right: right ?? 6, right: right ?? 40,
}; };
}); });
export const ModalCloseButton = ({ ...props }: ModalCloseButtonProps) => { export const ModalCloseButton = ({
return ( absolute = true,
...props
}: ModalCloseButtonProps) => {
return absolute ? (
<StyledIconButton {...props}> <StyledIconButton {...props}>
<CloseIcon /> <CloseIcon />
</StyledIconButton> </StyledIconButton>
) : (
<IconButton>
<CloseIcon />
</IconButton>
); );
}; };

View File

@@ -11,7 +11,7 @@ export const ModalWrapper = styled.div<{
height, height,
minHeight, minHeight,
backgroundColor: theme.colors.popoverBackground, backgroundColor: theme.colors.popoverBackground,
borderRadius: '12px', borderRadius: '24px',
position: 'relative', position: 'relative',
}; };
}); });

View File

@@ -0,0 +1,7 @@
import MuiBreadcrumbs from '@mui/material/Breadcrumbs';
import MuiCollapse from '@mui/material/Collapse';
import MuiSlide from '@mui/material/Slide';
import MuiAvatar from '@mui/material/Avatar';
import MuiGrow from '@mui/material/Grow';
export { MuiBreadcrumbs, MuiCollapse, MuiSlide, MuiAvatar, MuiGrow };

View File

@@ -5,6 +5,7 @@ import type { TooltipProps } from '@mui/material';
const StyledTooltip = styled(StyledPopperContainer)(({ theme }) => { const StyledTooltip = styled(StyledPopperContainer)(({ theme }) => {
return { return {
maxWidth: '320px',
boxShadow: theme.shadow.tooltip, boxShadow: theme.shadow.tooltip,
padding: '4px 12px', padding: '4px 12px',
backgroundColor: theme.colors.tooltipBackground, backgroundColor: theme.colors.tooltipBackground,

View File

@@ -148,5 +148,6 @@
"Sync Description2": "<1>{{workspaceName}}</1> is a Cloud Workspace. All data will be synchronised and saved to AFFiNE Cloud.", "Sync Description2": "<1>{{workspaceName}}</1> is a Cloud Workspace. All data will be synchronised and saved to AFFiNE Cloud.",
"Delete Workspace Description": "Deleting (<1>{{workspace}}</1>) cannot be undone, please proceed with caution. All contents will be lost.", "Delete Workspace Description": "Deleting (<1>{{workspace}}</1>) cannot be undone, please proceed with caution. All contents will be lost.",
"core": "core", "core": "core",
"all": "all" "all": "all",
"A workspace is your virtual space to capture, create and plan as just one person or together as a team.": "A workspace is your virtual space to capture, create and plan as just one person or together as a team."
} }

View File

@@ -144,5 +144,6 @@
"Publish": "发布", "Publish": "发布",
"Workspace Settings": "工作区设置", "Workspace Settings": "工作区设置",
"core": "核心", "core": "核心",
"all": "全部" "all": "全部",
"A workspace is your virtual space to capture, create and plan as just one person or together as a team.": "工作空间是一个人或一个团队创建和计划的虚拟空间。"
} }