Skip to content

Commit

Permalink
feat: add title bar
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Oct 22, 2024
1 parent 6001062 commit 8679c69
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import type { ReactElement } from 'react';

import { Titlebar } from './titlebar';

export const PDFViewer = (): ReactElement => {
return (
<>
<Titlebar id={'0'} name={'AFFiNE'} size={10} ext=".pdf" zoom={100} />
<div>{'PDF Viewer'}</div>
<div>{'PDF ...'}</div>
</>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { cssVarV2 } from '@toeverything/theme/v2';
import { style } from '@vanilla-extract/css';

export const titlebar = style({
display: 'flex',
justifyContent: 'space-between',
width: '100%',
height: '52px',
padding: '10px 0 10px 8px',
background: cssVarV2('layer/background/primary'),
fontSize: '12px',
fontWeight: 400,
color: cssVarV2('text/secondary'),
borderTopWidth: '0.5px',
borderTopStyle: 'solid',
borderTopColor: cssVarV2('layer/insideBorder/border'),
});

export const titlebarChild = style({
selectors: {
[`${titlebar} > &`]: {
display: 'flex',
gap: '12px',
alignItems: 'center',
paddingLeft: '12px',
paddingRight: '12px',
},
},
});

export const titlebarName = style({
display: 'flex',
});
75 changes: 75 additions & 0 deletions packages/frontend/component/src/components/pdf-viewer/titlebar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import {
EditIcon,
LocalDataIcon,
MoreHorizontalIcon,
ZoomDownIcon,
ZoomUpIcon,
} from '@blocksuite/icons/rc';
import { useState } from 'react';

import { IconButton } from '../../ui/button';
import { Menu, MenuItem } from '../../ui/menu';
import * as styles from './styles.css';

export interface TitlebarProps {
id: string;
name: string;
ext: string;
size: number;
zoom: number;
}

const items = [
{
name: 'Rename',
icon: <EditIcon />,
action() {},
},
{
name: 'Download',
icon: <LocalDataIcon />,
action() {},
},
];

export const MenuItems = () =>
items.map(({ name, icon, action }) => (
<MenuItem key={name} onClick={action} prefixIcon={icon}>
{name}
</MenuItem>
));

export const Titlebar = ({ name, ext, size, zoom = 100 }: TitlebarProps) => {
const [openMenu, setOpenMenu] = useState(false);

return (
<div className={styles.titlebar}>
<div className={styles.titlebarChild}>
<div className={styles.titlebarName}>
<div>{name}</div>
<span>{ext}</span>
</div>
<div>{size}MB</div>
<IconButton icon={<LocalDataIcon />}></IconButton>
<Menu
items={<MenuItems />}
rootOptions={{
open: openMenu,
onOpenChange: setOpenMenu,
}}
contentOptions={{
side: 'bottom',
avoidCollisions: false,
}}
>
<IconButton icon={<MoreHorizontalIcon />}></IconButton>
</Menu>
</div>
<div className={styles.titlebarChild}>
<IconButton icon={<ZoomDownIcon />}></IconButton>
<div>{zoom}%</div>
<IconButton icon={<ZoomUpIcon />}></IconButton>
</div>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { ReactElement } from 'react';
export const AttachmentPage = (): ReactElement => {
return (
<>
<div>{'Attachment Viewer'}</div>
<PDFViewer />
<div>{'Attachment Viewer'}</div>
</>
);
};
Expand Down

0 comments on commit 8679c69

Please sign in to comment.