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.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
feat(core): template doc list empty ui (#9675)
CatsJuice1c90747899a0
diff --git a/packages/frontend/core/src/modules/template-doc/view/styles.css.ts b/packages/frontend/core/src/modules/template-doc/view/styles.css.tsindex 66b00a57f8..640f94f0a6 100644--- a/packages/frontend/core/src/modules/template-doc/view/styles.css.ts+++ b/packages/frontend/core/src/modules/template-doc/view/styles.css.ts@@ -1,3 +1,4 @@+import { cssVarV2 } from '@toeverything/theme/v2';import { style } from '@vanilla-extract/css';export const list = style({@@ -14,3 +15,6 @@ export const scrollableViewport = style({paddingRight: 8,maxHeight: 360,});+export const emptyIcon = style({+ color: cssVarV2.icon.primary,+});diff --git a/packages/frontend/core/src/modules/template-doc/view/template-list-menu.tsx b/packages/frontend/core/src/modules/template-doc/view/template-list-menu.tsxindex 9645c2b67f..adc471c145 100644--- a/packages/frontend/core/src/modules/template-doc/view/template-list-menu.tsx+++ b/packages/frontend/core/src/modules/template-doc/view/template-list-menu.tsx@@ -1,5 +1,7 @@import { Menu, MenuItem, type MenuProps, Scrollable } from '@affine/component';import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks';+import { useI18n } from '@affine/i18n';+import { InformationIcon } from '@blocksuite/icons/rc';import { useLiveData, useService } from '@toeverything/infra';import { useState } from 'react';@@ -31,6 +33,18 @@ const DocItem = ({ doc, onSelect }: DocItemProps) => {);};+const Empty = () => {+ const t = useI18n();+ return (+ <MenuItem+ disabled+ prefixIcon={<InformationIcon className={styles.emptyIcon} />}+ >+ {t['com.affine.template-list.empty']()}+ </MenuItem>+ );+};+interface TemplateListMenuContentProps extends CommonProps {prefixItems?: React.ReactNode;suffixItems?: React.ReactNode;@@ -48,9 +62,11 @@ export const TemplateListMenuContent = ({return (<ul className={styles.list}>{prefixItems}- {templateDocs.map(doc => (- <DocItem key={doc.id} doc={doc} {...props} />- ))}+ {templateDocs.length ? (+ templateDocs.map(doc => <DocItem key={doc.id} doc={doc} {...props} />)+ ) : (+ <Empty />+ )}{suffixItems}</ul>);diff --git a/packages/frontend/i18n/src/resources/en.json b/packages/frontend/i18n/src/resources/en.jsonindex 5e6efd3e19..2e0ed059db 100644--- a/packages/frontend/i18n/src/resources/en.json+++ b/packages/frontend/i18n/src/resources/en.json@@ -1630,6 +1630,7 @@"com.affine.page-starter-bar.ai": "With AI","com.affine.page-starter-bar.edgeless": "Edgeless","Template": "Template",+ "com.affine.template-list.empty": "No template","com.affine.settings.workspace.template.title": "My Templates","com.affine.settings.workspace.template.journal": "Template for journal","com.affine.settings.workspace.template.journal-desc": "Select a template for your journal",