Files
aurora-admin/site/examples/themeswitcher.json
T

40 lines
5.7 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"slug": "themeswitcher",
"curated": true,
"mode": "single",
"examples": [
{
"id": "themeswitcher-ex-1",
"title": "基础用法",
"titleSrc": "",
"desc": "",
"html": "<div class=\"kole-page\">\n <h2 class=\"kole-h2\">ThemeSwitcher 主题切换</h2>\n <p class=\"kole-desc\">日间 / 夜间 / 自动主题 + 品牌色切换,实时预览。</p>\n <div class=\"kole-demo\">\n <div class=\"kole-themesw\" id=\"sw\" role=\"radiogroup\" aria-label=\"主题模式\">\n <div class=\"kole-themesw-opt\" role=\"radio\" tabindex=\"0\" aria-checked=\"false\" data-mode=\"light\">\n <span class=\"kole-themesw-dot light\"></span>\n 日间\n </div>\n <div class=\"kole-themesw-opt\" role=\"radio\" tabindex=\"0\" aria-checked=\"false\" data-mode=\"dark\">\n <span class=\"kole-themesw-dot dark\"></span>\n 夜间\n </div>\n <div class=\"kole-themesw-opt\" role=\"radio\" tabindex=\"0\" aria-checked=\"false\" data-mode=\"auto\">\n <span class=\"kole-themesw-dot auto\"></span>\n 自动\n </div>\n <div class=\"kole-themesw-colors\" id=\"colors\"></div>\n <div class=\"kole-themesw-label\" id=\"label\"></div>\n </div>\n <div class=\"kole-card\" style=\"margin-top:12px\">\n <div class=\"kole-card__body\">\n <button class=\"kole-btn kole-btn--primary\">品牌色按钮</button>\n <span style=\"margin-left:10px\">\n 当前主题:\n <b id=\"cur\"></b>\n </span>\n </div>\n </div>\n </div>\n</div>",
"preview": {
"show": [
[
0
]
],
"hide": [],
"mode": "single"
},
"previewSafe": true,
"previewUnsafeReasons": [],
"source": "curated",
"code": {
"html": "<h2>ThemeSwitcher 主题切换</h2>\n<p>日间 / 夜间 / 自动主题 + 品牌色切换,实时预览。</p>\n<div class=\"kole-themesw\" id=\"sw\" role=\"radiogroup\" aria-label=\"主题模式\">\n <div class=\"kole-themesw-opt\" role=\"radio\" tabindex=\"0\" aria-checked=\"false\" data-mode=\"light\">\n <span class=\"kole-themesw-dot light\"></span>\n 日间\n </div>\n <div class=\"kole-themesw-opt\" role=\"radio\" tabindex=\"0\" aria-checked=\"false\" data-mode=\"dark\">\n <span class=\"kole-themesw-dot dark\"></span>\n 夜间\n </div>\n <div class=\"kole-themesw-opt\" role=\"radio\" tabindex=\"0\" aria-checked=\"false\" data-mode=\"auto\">\n <span class=\"kole-themesw-dot auto\"></span>\n 自动\n </div>\n <div class=\"kole-themesw-colors\"></div>\n <div class=\"kole-themesw-label\"></div>\n</div>\n<div style=\"margin-top:12px\">\n <button>品牌色按钮</button>\n <span style=\"margin-left:10px\">\n 当前主题:\n <b></b>\n </span>\n</div>",
"jsx": "import { useState } from 'react';\nimport { KoleThemeSwitcher } from 'kole-ui/react';\n\nconst BRANDS = ['#2F54EB', '#1677FF', '#722ED1', '#13C2C2', '#FA541C', '#EB2F96'];\n\nfunction ThemePanel() {\n const [mode, setMode] = useState('auto');\n const [brand, setBrand] = useState(BRANDS[0]);\n return (\n <KoleThemeSwitcher\n mode={mode}\n brand={brand}\n onModeChange={setMode}\n onBrandChange={setBrand}\n />\n );\n}",
"vue3": "<template>\n <KoleThemeSwitcher\n :mode=\"mode\"\n :brand=\"brand\"\n @update:mode=\"mode = $event\"\n @update:brand=\"brand = $event\"\n />\n</template>\n\n<script setup>\nimport { ref } from 'vue';\nimport { KoleThemeSwitcher } from 'kole-ui/vue3';\n\nconst mode = ref('auto');\nconst brand = ref('#2F54EB');\n</script>",
"vue2": "<template>\n <KoleThemeSwitcher\n :mode=\"mode\"\n :brand=\"brand\"\n @update:mode=\"mode = $event\"\n @update:brand=\"brand = $event\"\n />\n</template>\n\n<script>\nimport { KoleThemeSwitcher } from 'kole-ui/vue2';\nexport default {\n components: { KoleThemeSwitcher },\n data() {\n return { mode: 'auto', brand: '#2F54EB' };\n }\n};\n</script>",
"tsx": "import { useState } from 'react';\nimport { KoleThemeSwitcher } from 'kole-ui/react';\n\nconst BRANDS = ['#2F54EB', '#1677FF', '#722ED1', '#13C2C2', '#FA541C', '#EB2F96'];\n\nfunction ThemePanel(): JSX.Element {\n const [mode, setMode] = useState<string>('auto');\n const [brand, setBrand] = useState(BRANDS[0]);\n return (\n <KoleThemeSwitcher\n mode={mode}\n brand={brand}\n onModeChange={setMode}\n onBrandChange={setBrand}\n />\n );\n}\n\nexport default ThemePanel;",
"vue3ts": "<template>\n\n <KoleThemeSwitcher\n :mode=\"mode\"\n :brand=\"brand\"\n @update:mode=\"mode = $event\"\n @update:brand=\"brand = $event\"\n />\n</template>\n\n<script setup lang=\"ts\">\nimport { KoleThemeSwitcher } from 'kole-ui/vue3';\n\nconst mode = ref<string>('auto');\nconst brand = ref<string>('#2F54EB');\n</script>",
"vue2ts": "<template>\n\n <KoleThemeSwitcher\n :mode=\"mode\"\n :brand=\"brand\"\n @update:mode=\"mode = $event\"\n @update:brand=\"brand = $event\"\n />\n</template>\n\n<script lang=\"ts\">\nimport Vue from 'vue';\nimport { KoleThemeSwitcher } from 'kole-ui/vue2';\n\nexport default {\n components: { KoleThemeSwitcher },\n data(): Record<string, unknown> {\n return { mode: 'auto', brand: '#2F54EB' };\n }\n};\n</script>"
},
"notes": [
"依据 frameworks/ThemeSwitcher.html 第 33-34 行:brands = ['#2F54EB','#1677FF','#722ED1','#13C2C2','#FA541C','#EB2F96'],初始 mode = 'auto'、brand = '#2F54EB';mode 三态 light|dark|auto 与品牌色取值见 site/details/themeswitcher.json 的 contract.dims。",
"两端回调名取自四端实现:React onModeChange / onBrandChange(frameworks/ThemeSwitcher.jsx 第 11 行参数表),vue3 与 vue2 均 emit update:mode / update:brand(frameworks/ThemeSwitcher.vue3.vue 第 42 行)。"
]
}
]
}