Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix: lint style

DiamondThree79f1ca494d24
diff --cc packages/app/src/components/workspace-modal/SelectLanguageMenu.tsx
index 0000000000,ad579e145b..ad579e145b
mode 000000,100644..100644
--- a/packages/app/src/components/workspace-modal/SelectLanguageMenu.tsx
+++ b/packages/app/src/components/workspace-modal/SelectLanguageMenu.tsx
diff --cc packages/app/src/components/workspace-modal/index.tsx
index 7c7dafc4f7,93b1bb7279..6799ad5e78
--- a/packages/app/src/components/workspace-modal/index.tsx
+++ b/packages/app/src/components/workspace-modal/index.tsx
@@@ -1,33 -1,35 +1,34 @@@
- import { styled } from '@/styles';
- import { Modal, ModalWrapper } from '@/ui/modal';
- import { Button, IconButton } from '@/ui/button';
+ import { Modal, ModalWrapper, ModalCloseButton } from '@/ui/modal';
+ import { Wrapper } from '@/ui/layout';
import { useState } from 'react';
import { CreateWorkspaceModal } from '../create-workspace';
- import {
- UsersIcon,
- AddIcon,
- LogOutIcon,
- CloudInsyncIcon,
- CloseIcon,
- } from '@blocksuite/icons';
- import {
- WorkspaceAvatar,
- WorkspaceUnitAvatar,
- } from '@/components/workspace-avatar';
++
+ import { Tooltip } from '@/ui/tooltip';
-import { toast } from '@/ui/toast';
+
+ import { AddIcon, HelpCenterIcon } from '@blocksuite/icons';
+
import { useAppState } from '@/providers/app-state-provider';
import { useRouter } from 'next/router';
import { useTranslation } from '@affine/i18n';
- import { LanguageMenu } from './languageMenu';
-import { LanguageMenu } from './LanguageMenu';
++import { LanguageMenu } from './SelectLanguageMenu';
- import {
- CloudIcon,
- LineIcon,
- LocalIcon,
- OfflineIcon,
- PublishedIcon,
- } from './icons';
import { LoginModal } from '../login-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';
-import { useConfirm } from '@/providers/ConfirmProvider';
interface WorkspaceModalProps {
open: boolean;
onClose: () => void;
@@@ -41,8 -42,10 +41,9 @@@ export const WorkspaceModal = ({ open,
const { t } = useTranslation();
const [loginOpen, setLoginOpen] = useState(false);
const [logoutOpen, setLogoutOpen] = useState(false);
- const { confirm } = useConfirm();
+
return (
- <div>
+ <>
<Modal open={open} onClose={onClose}>
<ModalWrapper
width={720}
@@@ -74,298 -78,87 +76,75 @@@
onClick={() => {
onClose();
}}
- >
- <CloseIcon></CloseIcon>
- </Button>
- </HeaderOption>
- </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>
+ absolute={false}
+ />
+ </StyledOperationWrapper>
+ </StyledModalHeader>
- <StyleWorkspaceInfo>
- <StyleWorkspaceTitle>
- {item.name || 'AFFiNE'}
- </StyleWorkspaceTitle>
- {isOwner ? (
- item.provider === 'local' ? (
- <p>
- <LocalIcon />
- Local Workspace
- </p>
- ) : (
- <p>
- <CloudIcon />
- Cloud Workspace
- </p>
- )
- ) : (
- <p>
- <UsersIcon fontSize={20} color={'#FF646B'} />
- Joined Workspace
- </p>
- )}
- {item.provider === 'local' && (
- <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>
+ <StyledModalContent>
+ {workspaceList.map((item, index) => {
+ return (
+ <WorkspaceCard
+ workspaceData={item}
+ onClick={workspaceData => {
+ router.replace(`/workspace/${workspaceData.id}`);
+ onClose();
+ }}
+ key={index}
+ ></WorkspaceCard>
+ );
+ })}
+ <StyledCard
+ onClick={() => {
+ setCreateWorkspaceOpen(true);
+ }}
+ >
+ <Wrapper>
+ <StyleWorkspaceAdd className="add-icon">
+ <AddIcon fontSize={18} />
+ </StyleWorkspaceAdd>
+ </Wrapper>
- <StyleWorkspaceInfo>
- <StyleWorkspaceTitle>New workspace</StyleWorkspaceTitle>
- <p>Crete or import</p>
- </StyleWorkspaceInfo>
- </WorkspaceItem>
- </WorkspaceList>
- {/* <p style={{ fontSize: '14px', color: '#ccc', margin: '12px 0' }}>
- {t('Tips')}
- {t('Workspace description')}
- </p> */}
- </Content>
- <LoginModal
- open={loginOpen}
- onClose={() => {
- setLoginOpen(false);
- }}
- ></LoginModal>
- <Footer>
- {!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);
+ <StyleWorkspaceInfo>
+ <StyleWorkspaceTitle>New workspace</StyleWorkspaceTitle>
+ <p>Crete or import</p>
+ </StyleWorkspaceInfo>
+ </StyledCard>
+ </StyledModalContent>
+
+ <Footer
+ onLogin={() => {
+ setLoginOpen(true);
}}
- ></CreateWorkspaceModal>
- <LogoutModal
- open={logoutOpen}
- onClose={async wait => {
- if (!wait) {
- await logout();
- router.replace(`/workspace`);
- }
- setLogoutOpen(false);
+ onLogout={() => {
- setLoginOpen(true);
- confirm({
- title: 'Sign out?',
- content: `All data has been stored in the cloud. `,
- confirmText: 'Sign out',
- cancelText: 'Cancel',
- }).then(async confirm => {
- if (confirm) {
- await logout();
- await router.replace(`/workspace`);
- toast('Enabled success');
- }
- });
++ setLogoutOpen(true);
}}
- ></LogoutModal>
+ />
</ModalWrapper>
</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,
- },
- },
- };
- });
diff --cc packages/app/src/components/workspace-modal/languageMenu.tsx
index d8f907663d,ad579e145b..0000000000
deleted file mode 100644,100644
--- a/packages/app/src/components/workspace-modal/languageMenu.tsx
+++ /dev/null
@@@ -1,93 -1,61 +1,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';
-import { Menu, MenuItem } from '@/ui/menu';
--
- export const LanguageMenu = () => {
-const LanguageMenuContent = () => {
-- 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 (
- <>
- {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 (
- <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}
- <Menu
- content={<LanguageMenuContent />}
- placement="bottom"
- trigger="click"
- disablePortal={true}
-- >
- <StyledTitleButton
- style={{ border: 'none', padding: '0px' }}
- onClick={() => {
- setShow(!show);
- }}
- <Button
- icon={<ArrowDownIcon />}
- iconPosition="end"
- noBorder={true}
- style={{ textTransform: 'capitalize' }}
-- >
- <StyledContainer>
- <StyledText>{languageName}</StyledText>
- <ArrowDownIcon fontSize={18} />
- </StyledContainer>
- </StyledTitleButton>
- </StyledTooltip>
- {currentLanguage?.originalName}
- </Button>
- </Menu>
-- );
--};
-
- 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%',
-const ListItem = styled(MenuItem)(({ theme }) => ({
- height: '38px',
-- color: theme.colors.popoverColor,
-- fontSize: theme.font.sm,
-- textTransform: 'capitalize',
- }));
-
- const StyledTitleButton = styled(Button)(({ theme }) => ({
- color: theme.colors.popoverColor,
- fontSize: theme.font.sm,
- padding: '0 24px',
--}));