Merge branch 'feat/datacenter' into feat/datacenter-i18n

This commit is contained in:
JimmFly
2023-02-01 13:04:52 +08:00
10 changed files with 79 additions and 34 deletions

View File

@@ -1,7 +1,7 @@
import { Modal, ModalWrapper, ModalCloseButton } from '@/ui/modal'; import { Modal, ModalWrapper, ModalCloseButton } from '@/ui/modal';
import { StyledButtonWrapper, StyledTitle } from './styles'; import { StyledButtonWrapper, StyledTitle } from './styles';
import { Button } from '@/ui/button'; import { Button } from '@/ui/button';
import { Wrapper, Content } from '@/ui/layout'; import { Content, FlexWrapper } from '@/ui/layout';
import Loading from '@/components/loading'; import Loading from '@/components/loading';
import { usePageHelper } from '@/hooks/use-page-helper'; import { usePageHelper } from '@/hooks/use-page-helper';
import { useAppState } from '@/providers/app-state-provider'; import { useAppState } from '@/providers/app-state-provider';
@@ -116,7 +116,7 @@ export const ImportModal = ({ open, onClose }: ImportModalProps) => {
)} )}
{status === 'importing' && ( {status === 'importing' && (
<Wrapper <FlexWrapper
wrap={true} wrap={true}
justifyContent="center" justifyContent="center"
style={{ marginTop: 22, paddingBottom: '32px' }} style={{ marginTop: 22, paddingBottom: '32px' }}
@@ -126,7 +126,7 @@ export const ImportModal = ({ open, onClose }: ImportModalProps) => {
OOOOPS! Sorry forgot to remind you that we are working on the OOOOPS! Sorry forgot to remind you that we are working on the
import function import function
</Content> </Content>
</Wrapper> </FlexWrapper>
)} )}
</ModalWrapper> </ModalWrapper>
</Modal> </Modal>

View File

@@ -1,7 +1,7 @@
import { useConfirm } from '@/providers/ConfirmProvider'; import { useConfirm } from '@/providers/ConfirmProvider';
import { PageMeta } from '@/providers/app-state-provider'; import { PageMeta } from '@/providers/app-state-provider';
import { Menu, MenuItem } from '@/ui/menu'; import { Menu, MenuItem } from '@/ui/menu';
import { Wrapper } from '@/ui/layout'; import { FlexWrapper } from '@/ui/layout';
import { IconButton } from '@/ui/button'; import { IconButton } from '@/ui/button';
import { import {
MoreVerticalIcon, MoreVerticalIcon,
@@ -63,13 +63,13 @@ export const OperationCell = ({ pageMeta }: { pageMeta: PageMeta }) => {
</> </>
); );
return ( return (
<Wrapper alignItems="center" justifyContent="center"> <FlexWrapper alignItems="center" justifyContent="center">
<Menu content={OperationMenu} placement="bottom-end" disablePortal={true}> <Menu content={OperationMenu} placement="bottom-end" disablePortal={true}>
<IconButton darker={true}> <IconButton darker={true}>
<MoreVerticalIcon /> <MoreVerticalIcon />
</IconButton> </IconButton>
</Menu> </Menu>
</Wrapper> </FlexWrapper>
); );
}; };
@@ -80,7 +80,7 @@ export const TrashOperationCell = ({ pageMeta }: { pageMeta: PageMeta }) => {
const { confirm } = useConfirm(); const { confirm } = useConfirm();
const { t } = useTranslation(); const { t } = useTranslation();
return ( return (
<Wrapper> <FlexWrapper>
<IconButton <IconButton
darker={true} darker={true}
style={{ marginRight: '12px' }} style={{ marginRight: '12px' }}
@@ -108,6 +108,6 @@ export const TrashOperationCell = ({ pageMeta }: { pageMeta: PageMeta }) => {
> >
<DeleteIcon /> <DeleteIcon />
</IconButton> </IconButton>
</Wrapper> </FlexWrapper>
); );
}; };

View File

@@ -1,5 +1,5 @@
import { CloudInsyncIcon, LogOutIcon } from '@blocksuite/icons'; import { CloudInsyncIcon, LogOutIcon } from '@blocksuite/icons';
import { Wrapper } from '@/ui/layout'; import { FlexWrapper } from '@/ui/layout';
import { WorkspaceAvatar } from '@/components/workspace-avatar'; import { WorkspaceAvatar } from '@/components/workspace-avatar';
import { IconButton } from '@/ui/button'; import { IconButton } from '@/ui/button';
import { useAppState } from '@/providers/app-state-provider'; import { useAppState } from '@/providers/app-state-provider';
@@ -20,7 +20,7 @@ export const Footer = ({
<StyledFooter> <StyledFooter>
{user && ( {user && (
<> <>
<Wrapper> <FlexWrapper>
<WorkspaceAvatar <WorkspaceAvatar
size={40} size={40}
name={user.name} name={user.name}
@@ -30,7 +30,7 @@ export const Footer = ({
<p>{user.name}</p> <p>{user.name}</p>
<p>{user.email}</p> <p>{user.email}</p>
</StyleUserInfo> </StyleUserInfo>
</Wrapper> </FlexWrapper>
<IconButton <IconButton
onClick={() => { onClick={() => {
onLogout(); onLogout();

View File

@@ -8,8 +8,8 @@ import { PublishIcon, UsersIcon } from '@blocksuite/icons';
import { WorkspaceUnit } from '@affine/datacenter'; import { WorkspaceUnit } from '@affine/datacenter';
import { useAppState } from '@/providers/app-state-provider'; import { useAppState } from '@/providers/app-state-provider';
import { StyleWorkspaceInfo, StyleWorkspaceTitle, StyledCard } from './styles'; import { StyleWorkspaceInfo, StyleWorkspaceTitle, StyledCard } from './styles';
import { Wrapper } from '@/ui/layout';
import { useTranslation } from '@affine/i18n'; import { useTranslation } from '@affine/i18n';
import { FlexWrapper } from '@/ui/layout';
export const WorkspaceCard = ({ export const WorkspaceCard = ({
workspaceData, workspaceData,
@@ -27,9 +27,9 @@ export const WorkspaceCard = ({
}} }}
active={workspaceData.id === currentWorkspace?.id} active={workspaceData.id === currentWorkspace?.id}
> >
<Wrapper> <FlexWrapper>
<WorkspaceUnitAvatar size={58} workspaceUnit={workspaceData} /> <WorkspaceUnitAvatar size={58} workspaceUnit={workspaceData} />
</Wrapper> </FlexWrapper>
<StyleWorkspaceInfo> <StyleWorkspaceInfo>
<StyleWorkspaceTitle> <StyleWorkspaceTitle>

View File

@@ -1,5 +1,5 @@
import { Modal, ModalWrapper, ModalCloseButton } from '@/ui/modal'; import { Modal, ModalWrapper, ModalCloseButton } from '@/ui/modal';
import { Wrapper } from '@/ui/layout'; import { FlexWrapper } from '@/ui/layout';
import { useState } from 'react'; import { useState } from 'react';
import { CreateWorkspaceModal } from '../create-workspace'; import { CreateWorkspaceModal } from '../create-workspace';
@@ -97,11 +97,11 @@ export const WorkspaceModal = ({ open, onClose }: WorkspaceModalProps) => {
setCreateWorkspaceOpen(true); setCreateWorkspaceOpen(true);
}} }}
> >
<Wrapper> <FlexWrapper>
<StyleWorkspaceAdd className="add-icon"> <StyleWorkspaceAdd className="add-icon">
<AddIcon fontSize={18} /> <AddIcon fontSize={18} />
</StyleWorkspaceAdd> </StyleWorkspaceAdd>
</Wrapper> </FlexWrapper>
<StyleWorkspaceInfo> <StyleWorkspaceInfo>
<StyleWorkspaceTitle>{t('New Workspace')}</StyleWorkspaceTitle> <StyleWorkspaceTitle>{t('New Workspace')}</StyleWorkspaceTitle>

View File

@@ -45,6 +45,7 @@ export const StyledCard = styled.div<{
borderRadius: '12px', borderRadius: '12px',
border: `1px solid ${borderColor}`, border: `1px solid ${borderColor}`,
...displayFlex('flex-start', 'flex-start'), ...displayFlex('flex-start', 'flex-start'),
marginBottom: '24px',
':hover': { ':hover': {
background: theme.colors.hoverBackground, background: theme.colors.hoverBackground,
'.add-icon': { '.add-icon': {
@@ -125,7 +126,7 @@ export const StyledModalContent = styled('div')({
padding: '8px 40px', padding: '8px 40px',
marginTop: '72px', marginTop: '72px',
overflow: 'auto', overflow: 'auto',
...displayFlex('space-between', 'flex-start', 'column'), ...displayFlex('space-between', 'flex-start', 'flex-start'),
flexWrap: 'wrap', flexWrap: 'wrap',
}); });
export const StyledOperationWrapper = styled.div(() => { export const StyledOperationWrapper = styled.div(() => {

View File

@@ -25,7 +25,7 @@ import { useConfirm } from '@/providers/ConfirmProvider';
import { toast } from '@/ui/toast'; import { toast } from '@/ui/toast';
import useMembers from '@/hooks/use-members'; import useMembers from '@/hooks/use-members';
import Loading from '@/components/loading'; import Loading from '@/components/loading';
import { Wrapper } from '@/ui/layout'; import { FlexWrapper } from '@/ui/layout';
import { useTranslation } from '@affine/i18n'; import { useTranslation } from '@affine/i18n';
import { EnableWorkspaceButton } from '@/components/enable-workspace'; import { EnableWorkspaceButton } from '@/components/enable-workspace';
@@ -41,9 +41,9 @@ export const MembersPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
<StyledMemberContainer> <StyledMemberContainer>
<StyledMemberListContainer> <StyledMemberListContainer>
{!loaded && ( {!loaded && (
<Wrapper justifyContent="center"> <FlexWrapper justifyContent="center">
<Loading size={25} /> <Loading size={25} />
</Wrapper> </FlexWrapper>
)} )}
{loaded && members.length === 0 && ( {loaded && members.length === 0 && (
<Empty width={648} sx={{ marginTop: '60px' }} height={300} /> <Empty width={648} sx={{ marginTop: '60px' }} height={300} />

View File

@@ -2,12 +2,12 @@ import type { CSSProperties } from 'react';
export const displayFlex = ( export const displayFlex = (
justifyContent: CSSProperties['justifyContent'] = 'unset', justifyContent: CSSProperties['justifyContent'] = 'unset',
alignItems: CSSProperties['alignContent'] = 'unset', alignItems: CSSProperties['alignItems'] = 'unset',
alignContent: CSSProperties['alignContent'] = 'unset' alignContent: CSSProperties['alignContent'] = 'unset'
): { ): {
display: CSSProperties['display']; display: CSSProperties['display'];
justifyContent: CSSProperties['justifyContent']; justifyContent: CSSProperties['justifyContent'];
alignItems: CSSProperties['alignContent']; alignItems: CSSProperties['alignItems'];
alignContent: CSSProperties['alignContent']; alignContent: CSSProperties['alignContent'];
} => { } => {
return { return {

View File

@@ -14,8 +14,21 @@ export type ContentProps = {
lineNum?: number; lineNum?: number;
children: string; children: string;
}; };
export const Content = styled('div', {
export const Content = styled.div<ContentProps>( shouldForwardProp: prop => {
return ![
'color',
'fontSize',
'weight',
'lineHeight',
'ellipsis',
'lineNum',
'width',
'maxWidth',
'align',
].includes(prop);
},
})<ContentProps>(
({ ({
theme, theme,
color, color,

View File

@@ -2,6 +2,14 @@ import type { CSSProperties } from 'react';
import { styled } from '@/styles'; import { styled } from '@/styles';
export type WrapperProps = { export type WrapperProps = {
display?: CSSProperties['display'];
width?: CSSProperties['width'];
height?: CSSProperties['height'];
padding?: CSSProperties['padding'];
margin?: CSSProperties['margin'];
};
export type FlexWrapperProps = {
display?: CSSProperties['display']; display?: CSSProperties['display'];
flexDirection?: CSSProperties['flexDirection']; flexDirection?: CSSProperties['flexDirection'];
justifyContent?: CSSProperties['justifyContent']; justifyContent?: CSSProperties['justifyContent'];
@@ -13,9 +21,22 @@ export type WrapperProps = {
// Sometimes we just want to wrap a component with a div to set flex or other styles, but we don't want to create a new component for it. // Sometimes we just want to wrap a component with a div to set flex or other styles, but we don't want to create a new component for it.
export const Wrapper = styled('div', { export const Wrapper = styled('div', {
shouldForwardProp: prop => {
return !['display', 'width', 'height', 'padding', 'margin'].includes(prop);
},
})<WrapperProps>(({ display, width, height, padding, margin }) => {
return {
display,
width,
height,
padding,
margin,
};
});
export const FlexWrapper = styled(Wrapper, {
shouldForwardProp: prop => { shouldForwardProp: prop => {
return ![ return ![
'display',
'justifyContent', 'justifyContent',
'alignItems', 'alignItems',
'wrap', 'wrap',
@@ -24,18 +45,17 @@ export const Wrapper = styled('div', {
'flexGrow', 'flexGrow',
].includes(prop); ].includes(prop);
}, },
})<WrapperProps>( })<FlexWrapperProps>(
({ ({
display = 'flex', justifyContent,
justifyContent = 'flex-start', alignItems,
alignItems = 'center',
wrap = false, wrap = false,
flexDirection = 'row', flexDirection,
flexShrink = '0', flexShrink,
flexGrow = '0', flexGrow,
}) => { }) => {
return { return {
display, display: 'flex',
justifyContent, justifyContent,
alignItems, alignItems,
flexWrap: wrap ? 'wrap' : 'nowrap', flexWrap: wrap ? 'wrap' : 'nowrap',
@@ -46,4 +66,15 @@ export const Wrapper = styled('div', {
} }
); );
// TODO: Complete me
export const GridWrapper = styled(Wrapper, {
shouldForwardProp: prop => {
return ![''].includes(prop);
},
})<WrapperProps>(() => {
return {
display: 'grid',
};
});
export default Wrapper; export default Wrapper;