feat(core): replace emoji-mart with affine icon picker (#13644)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- New Features
  - Unified icon picker with consistent rendering across the app.
  - Picker can auto-close after selection.
  - “Remove” now clears the icon selection.

- Refactor
- Icon handling consolidated across editors, navigation, and document
titles for consistent behavior.
  - Picker now opens on the Emoji panel by default.

- Style
  - Adjusted line-height and selectors for icon picker visuals.

- Chores
  - Removed unused emoji-mart dependencies.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Cats Juice
2025-09-26 14:41:29 +08:00
committed by GitHub
parent c540400496
commit d272c4342d
16 changed files with 121 additions and 138 deletions
@@ -6,6 +6,8 @@ import {
type DropTargetTreeInstruction,
IconAndNameEditorMenu,
IconButton,
type IconData,
IconRenderer,
Menu,
MenuItem,
useDraggable,
@@ -13,7 +15,6 @@ import {
} from '@affine/component';
import { Guard } from '@affine/core/components/guard';
import { AppSidebarService } from '@affine/core/modules/app-sidebar';
import type { ExplorerIconType } from '@affine/core/modules/db/schema/schema';
import { ExplorerIconService } from '@affine/core/modules/explorer-icon/services/explorer-icon';
import type { ExplorerType } from '@affine/core/modules/explorer-icon/store/explorer-icon';
import type { DocPermissionActions } from '@affine/core/modules/permissions';
@@ -142,13 +143,12 @@ export const NavigationPanelTreeNodeRenameModal = ({
);
const onIconChange = useCallback(
(type?: ExplorerIconType, icon?: string) => {
(data?: IconData) => {
if (!explorerIconConfig) return;
explorerIconService.setIcon({
where: explorerIconConfig.where,
id: explorerIconConfig.id,
type,
icon,
icon: data,
});
},
[explorerIconConfig, explorerIconService]
@@ -161,8 +161,7 @@ export const NavigationPanelTreeNodeRenameModal = ({
onIconChange={onIconChange}
onNameChange={handleRename}
name={rawName ?? ''}
iconType={explorerIcon?.type ?? 'emoji'}
icon={explorerIcon?.icon ?? ''}
icon={explorerIcon?.icon}
width={sidebarWidth - 16}
contentOptions={{
sideOffset: 36,
@@ -461,10 +460,7 @@ export const NavigationPanelTreeNode = ({
/>
</div>
<div className={styles.iconContainer}>
{/* Only emoji icon is supported for now */}
{explorerIcon && explorerIcon.type === 'emoji'
? explorerIcon.icon
: fallbackIcon}
<IconRenderer data={explorerIcon?.icon} fallback={fallbackIcon} />
</div>
</div>