mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
feat: add fav button (#4159)
Co-authored-by: Alex Yang <himself65@outlook.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { PlusIcon } from '@blocksuite/icons';
|
||||
import type { Workspace } from '@blocksuite/store';
|
||||
import { IconButton } from '@toeverything/components/button';
|
||||
import { usePageMetaHelper } from '@toeverything/hooks/use-block-suite-page-meta';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { usePageHelper } from '../../../blocksuite/block-suite-page-list/utils';
|
||||
|
||||
type AddFavouriteButtonProps = {
|
||||
workspace: Workspace;
|
||||
};
|
||||
|
||||
export const AddFavouriteButton = ({ workspace }: AddFavouriteButtonProps) => {
|
||||
const { createPage } = usePageHelper(workspace);
|
||||
const { setPageMeta } = usePageMetaHelper(workspace);
|
||||
const handleAddFavorite = useCallback(async () => {
|
||||
const id = createPage();
|
||||
setPageMeta(id, { favorite: true });
|
||||
}, [createPage, setPageMeta]);
|
||||
|
||||
return (
|
||||
<IconButton
|
||||
data-testid="slider-bar-add-favorite-button"
|
||||
onClick={handleAddFavorite}
|
||||
size="small"
|
||||
>
|
||||
<PlusIcon />
|
||||
</IconButton>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user