{ "slug": "icon", "curated": true, "mode": "scenarios", "examples": [ { "id": "icon-ex-1", "title": "尺寸档位(关键字 + 任意 CSS 长度)", "titleSrc": "demo", "desc": "", "html": "
\n
\n
\n

size 只驱动 CSS 变量 --kole-icon-size(落地为 font-size),SVG 边长恒为 1em,故关键字与任意 CSS 长度走同一条路径。

\n
", "preview": { "show": [ [ 0, 2 ] ], "hide": [ [ 1 ], [ 2 ], [ 0, 0 ], [ 0, 1 ], [ 0, 3 ], [ 0, 4 ], [ 0, 5 ], [ 0, 6 ], [ 0, 7 ], [ 0, 8 ], [ 0, 2, 0 ] ], "mode": "scenarios" }, "previewSafe": true, "previewUnsafeReasons": [], "source": "curated", "code": { "html": "
\n
\n
\n

size 只驱动 CSS 变量 --kole-icon-size(落地为 font-size),SVG 边长恒为 1em,故关键字与任意 CSS 长度走同一条路径。

\n
", "jsx": "import { KoleIcon } from 'kole-ui/react';\n\n<>\n \n \n \n \n \n \n", "vue3": "\n\n", "vue2": "\n\n", "tsx": "import { KoleIcon } from 'kole-ui/react';\n\ntype IconSize = 'small' | 'default' | 'large' | 'xlarge' | '18px' | '2rem';\ninterface SizeSample {\n size: IconSize;\n label: string;\n}\n\nconst samples: ReadonlyArray = [\n { size: 'small', label: '搜索(small)' },\n { size: 'default', label: '搜索(default)' },\n { size: 'large', label: '搜索(large)' },\n { size: 'xlarge', label: '搜索(xlarge)' },\n { size: '18px', label: '搜索(18px)' },\n { size: '2rem', label: '搜索(2rem)' },\n];\n\nexport default function KoleIconSizeDemo(): JSX.Element {\n return (\n <>\n {samples.map((sample) => (\n \n ))}\n \n );\n}", "vue3ts": "\n\n", "vue2ts": "\n\n" }, "notes": [ "依据 frameworks/Icon.html:204 TIERS = ['small','default','large','xlarge'] 与 :216 fill('row-size', TIERS.map(...)) 的实参;:220 fill('row-size-any', ...) 给出任意 CSS 长度 18px / 2rem", "TS 形态依据 TS-VARIANTS.md:tsx 用 type IconSize 字面量联合 + ReadonlyArray 循环;vue3ts/vue2ts 用 ", "vue2": "\n\n", "tsx": "import { KoleIcon } from 'kole-ui/react';\n\ntype IconTone = 'default' | 'brand' | 'secondary' | 'danger' | 'success' | 'warning';\ninterface ToneSample {\n tone: IconTone;\n label: string;\n}\n\nconst tones: ReadonlyArray = [\n { tone: 'default', label: '收藏(default)' },\n { tone: 'brand', label: '收藏(brand)' },\n { tone: 'secondary', label: '收藏(secondary)' },\n { tone: 'danger', label: '收藏(danger)' },\n { tone: 'success', label: '收藏(success)' },\n { tone: 'warning', label: '收藏(warning)' },\n];\n\nexport default function KoleIconToneDemo(): JSX.Element {\n return (\n <>\n {tones.map((sample) => (\n \n ))}\n \n \n );\n}", "vue3ts": "\n\n", "vue2ts": "\n\n" }, "notes": [ "依据 frameworks/Icon.html:205 TONES = ['default','brand','secondary','danger','success','warning'] 与 :225 fill('row-tone', TONES.map(...));:229 fill('row-tone-color', ...) 的 color='var(--kole-color-error)' 覆盖 tone='brand'" ] }, { "id": "icon-ex-3", "title": "旋转 spin", "titleSrc": "demo", "desc": "", "html": "
\n
\n

spin 表示「进行中」;样式表在 prefers-reduced-motion: reduce 下把动画置 none(不会旋转)。

\n
", "preview": { "show": [ [ 0, 4 ] ], "hide": [ [ 1 ], [ 2 ], [ 0, 0 ], [ 0, 1 ], [ 0, 2 ], [ 0, 3 ], [ 0, 5 ], [ 0, 6 ], [ 0, 7 ], [ 0, 8 ], [ 0, 4, 0 ] ], "mode": "scenarios" }, "previewSafe": true, "previewUnsafeReasons": [], "source": "curated", "code": { "html": "
\n
\n

spin 表示「进行中」;样式表在 prefers-reduced-motion: reduce 下把动画置 none(不会旋转)。

\n
", "jsx": "import { KoleIcon } from 'kole-ui/react';\n\n<>\n \n 正在同步数据…\n \n", "vue3": "\n\n", "vue2": "\n\n", "tsx": "import { KoleIcon } from 'kole-ui/react';\n\ntype SpinnerName = 'loading' | 'refresh';\ninterface SpinEntry {\n name: SpinnerName;\n label: string;\n tone?: 'brand';\n}\n\nconst spinners: readonly [SpinEntry, SpinEntry] = [\n { name: 'loading', label: '加载中', tone: 'brand' },\n { name: 'refresh', label: '刷新中' },\n];\n\nexport default function KoleIconSpinDemo(): JSX.Element {\n const [busy, idle] = spinners;\n return (\n <>\n \n 正在同步数据…\n \n \n );\n}", "vue3ts": "\n\n", "vue2ts": "\n\n" }, "notes": [ "依据 frameworks/Icon.html:233 fill('row-spin', ...) 的两个实参:{ name:'loading', spin:true, tone:'brand', label:'加载中' } 与 { name:'refresh', spin:true, label:'刷新中' }" ] }, { "id": "icon-ex-4", "title": "无障碍:label 有值 / 无值", "titleSrc": "demo", "desc": "", "html": "
\n
\n
\n

同一张图标:有 label 时是「有语义的图」,无 label 时是装饰。判据只看 label 是否有值,与 name 无关。

\n
", "preview": { "show": [ [ 0, 5 ] ], "hide": [ [ 1 ], [ 2 ], [ 0, 0 ], [ 0, 1 ], [ 0, 2 ], [ 0, 3 ], [ 0, 4 ], [ 0, 6 ], [ 0, 7 ], [ 0, 8 ], [ 0, 5, 0 ] ], "mode": "scenarios" }, "previewSafe": true, "previewUnsafeReasons": [], "source": "curated", "code": { "html": "
\n
\n
\n

同一张图标:有 label 时是「有语义的图」,无 label 时是装饰。判据只看 label 是否有值,与 name 无关。

\n
", "jsx": "import { KoleIcon } from 'kole-ui/react';\n\n<>\n \n \n", "vue3": "\n\n", "vue2": "\n\n", "tsx": "import { KoleIcon } from 'kole-ui/react';\n\ninterface A11ySample {\n key: 'with-label' | 'without-label';\n label: string;\n}\n\nconst samples: ReadonlyArray = [\n { key: 'with-label', label: '校验通过' },\n { key: 'without-label', label: '' },\n];\n\nexport default function KoleIconA11yDemo(): JSX.Element {\n return (\n <>\n {samples.map((sample) => (\n \n ))}\n \n );\n}", "vue3ts": "\n\n", "vue2ts": "\n\n" }, "notes": [ "依据 frameworks/Icon.html:239 fill('row-a11y-labelled', ...) 有 label 与 :243 fill('row-a11y-decorative', ...) 无 label 的同一张 check-circle;判据只有 label 是否有值" ] }, { "id": "icon-ex-5", "title": "图标名查找(core 层内联 + 别名折叠)", "titleSrc": "demo", "desc": "", "html": "
\n
\n
\n
\n

查找只认注入表里的名字(别名在注入时已折叠成终态表);查不到时用默认插槽兜底,不抛错、不显示错误图标。

\n
", "preview": { "show": [ [ 0, 6 ] ], "hide": [ [ 1 ], [ 2 ], [ 0, 0 ], [ 0, 1 ], [ 0, 2 ], [ 0, 3 ], [ 0, 4 ], [ 0, 5 ], [ 0, 7 ], [ 0, 8 ], [ 0, 6, 0 ] ], "mode": "scenarios" }, "previewSafe": true, "previewUnsafeReasons": [], "source": "curated", "code": { "html": "
\n
\n
\n
\n

查找只认注入表里的名字(别名在注入时已折叠成终态表);查不到时用默认插槽兜底,不抛错、不显示错误图标。

\n
", "jsx": "import { KoleIcon } from 'kole-ui/react';\n\n<>\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ?\n", "vue3": "\n\n", "vue2": "\n\n", "tsx": "import { KoleIcon } from 'kole-ui/react';\n\ntype CoreIconName =\n | 'search' | 'filter' | 'view' | 'hide' | 'edit' | 'delete' | 'copy'\n | 'download' | 'upload' | 'setting' | 'bell' | 'user' | 'mail'\n | 'calendar' | 'folder' | 'image' | 'cart' | 'money' | 'clock'\n | 'help-circle' | 'warn' | 'info' | 'date';\n\ninterface RegistryEntry {\n name: CoreIconName;\n label: string;\n tone?: 'warning' | 'brand';\n}\n\nconst registry: ReadonlyArray = [\n { name: 'search', label: 'search' },\n { name: 'filter', label: 'filter' },\n { name: 'view', label: 'view' },\n { name: 'hide', label: 'hide' },\n { name: 'edit', label: 'edit' },\n { name: 'delete', label: 'delete' },\n { name: 'copy', label: 'copy' },\n { name: 'download', label: 'download' },\n { name: 'upload', label: 'upload' },\n { name: 'setting', label: 'setting' },\n { name: 'bell', label: 'bell' },\n { name: 'user', label: 'user' },\n { name: 'mail', label: 'mail' },\n { name: 'calendar', label: 'calendar' },\n { name: 'folder', label: 'folder' },\n { name: 'image', label: 'image' },\n { name: 'cart', label: 'cart' },\n { name: 'money', label: 'money' },\n { name: 'clock', label: 'clock' },\n { name: 'help-circle', label: 'help-circle' },\n { name: 'warn', label: 'warn → warning', tone: 'warning' },\n { name: 'info', label: 'info → info-circle', tone: 'brand' },\n { name: 'date', label: 'date → calendar' },\n];\n\nexport default function KoleIconRegistryDemo(): JSX.Element {\n return (\n <>\n {registry.map((entry) => (\n \n ))}\n ?\n \n );\n}", "vue3ts": "\n\n", "vue2ts": "\n\n" }, "notes": [ "依据 frameworks/Icon.html:206-208 LOOKUP_NAMES 的 20 个名字与 :248 fill('row-lookup', LOOKUP_NAMES.map(...));别名实参取自 :257 fill('row-alias', ...)、未命中回落默认插槽取自 :263 fill('row-miss', ...)", "TS 形态依据 TS-VARIANTS.md:tsx 用 type CoreIconName 字面量联合 + ReadonlyArray 循环(末项回落插槽单列);vue3ts/vue2ts 用 ", "vue2": "\n\n", "tsx": "import { KoleIcon } from 'kole-ui/react';\n\ntype ToolbarIconName = 'add' | 'download' | 'setting';\ninterface ToolbarAction {\n name: ToolbarIconName;\n text: string;\n iconLabel?: string;\n}\n\ntype SortOrder = 'ascending' | 'descending';\ninterface SortHead {\n order: SortOrder;\n name: 'arrow-up' | 'arrow-down';\n text: string;\n iconLabel: string;\n}\n\nconst primary: ToolbarAction = { name: 'add', text: '新建' };\nconst actions: ReadonlyArray = [\n { name: 'download', text: '导出' },\n { name: 'setting', text: '设置', iconLabel: '设置' },\n];\n\nconst sortHeads: ReadonlyArray = [\n { order: 'ascending', name: 'arrow-up', text: '名称', iconLabel: '名称排序' },\n { order: 'descending', name: 'arrow-down', text: '更新时间', iconLabel: '更新时间排序' },\n];\n\nexport default function KoleIconScenarioDemo(): JSX.Element {\n return (\n <>\n \n {actions.map((action) => (\n \n ))}\n {sortHeads.map((head) => (\n \n ))}\n
\n \n 暂无数据\n 调整筛选条件后重试,或新建一条记录。\n
\n \n );\n}", "vue3ts": "\n\n", "vue2ts": "\n\n" }, "notes": [ "依据 frameworks/Icon.html:268 fill('row-buttons', ...) 的三个按钮实参、:276 fill('row-sort', ...) 经 :210 sortHead(key,state,iconName) 的 arrow-up/arrow-down/sort、:281 fill('row-empty', ...) 的 folder + xlarge + secondary" ] }, { "id": "icon-ex-7", "title": "历史兼容(icon 字形字符)", "titleSrc": "demo", "desc": "", "html": "
\n
\n

既有 icon(字形字符,默认 ★)继续可用;name 有值时 name 优先,故旧调用点不破、新调用点用 name。

\n
", "preview": { "show": [ [ 0, 8 ] ], "hide": [ [ 1 ], [ 2 ], [ 0, 0 ], [ 0, 1 ], [ 0, 2 ], [ 0, 3 ], [ 0, 4 ], [ 0, 5 ], [ 0, 6 ], [ 0, 7 ], [ 0, 8, 0 ] ], "mode": "scenarios" }, "previewSafe": true, "previewUnsafeReasons": [], "source": "curated", "code": { "html": "
\n
\n

既有 icon(字形字符,默认 ★)继续可用;name 有值时 name 优先,故旧调用点不破、新调用点用 name。

\n
", "jsx": "import { KoleIcon } from 'kole-ui/react';\n\n<>\n \n \n", "vue3": "\n\n", "vue2": "\n\n", "tsx": "import { KoleIcon } from 'kole-ui/react';\n\ntype Glyph = '★';\ninterface LegacySample {\n key: string;\n name?: 'star';\n glyph: Glyph;\n tone?: 'brand';\n label: string;\n}\n\nconst legacy: ReadonlyArray = [\n { key: 'glyph-only', glyph: '★', label: '收藏' },\n { key: 'name-wins', name: 'star', glyph: '★', tone: 'brand', label: '收藏(name 生效)' },\n];\n\nexport default function KoleIconLegacyDemo(): JSX.Element {\n return (\n <>\n {legacy.map((sample) => (\n \n ))}\n \n );\n}", "vue3ts": "\n\n", "vue2ts": "\n\n" }, "notes": [ "依据 frameworks/Icon.html:289 fill('row-compat', ...) 的两个实参:{ icon:'★', label:'收藏' } 与 { name:'star', icon:'★', tone:'brand', label:'收藏(name 生效)' }" ] } ] }