mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
<!-- 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 -->
30 lines
637 B
TypeScript
30 lines
637 B
TypeScript
import type { ReactNode } from 'react';
|
|
|
|
import { AffineIconRenderer } from './renderer/affine-icon';
|
|
import { type IconData, IconType } from './type';
|
|
|
|
export const IconRenderer = ({
|
|
data,
|
|
fallback,
|
|
}: {
|
|
data?: IconData;
|
|
fallback?: ReactNode;
|
|
}) => {
|
|
if (!data) {
|
|
return fallback ?? null;
|
|
}
|
|
|
|
if (data.type === IconType.Emoji && data.unicode) {
|
|
return data.unicode;
|
|
}
|
|
if (data.type === IconType.AffineIcon && data.name) {
|
|
return <AffineIconRenderer name={data.name} color={data.color} />;
|
|
}
|
|
if (data.type === IconType.Blob) {
|
|
// Not supported yet
|
|
return null;
|
|
}
|
|
|
|
return fallback ?? null;
|
|
};
|