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

39 lines
3.6 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": "colorpicker",
"mode": "single",
"curated": true,
"examples": [
{
"id": "colorpicker-ex-1",
"title": "基础用法",
"titleSrc": "",
"desc": "",
"html": "<div class=\"kole-panel\">\n <div class=\"kole-colorpicker\" id=\"app\" role=\"group\"></div>\n</div>",
"preview": {
"show": [
[
0
]
],
"hide": [],
"mode": "single"
},
"previewSafe": true,
"previewUnsafeReasons": [],
"source": "curated",
"code": {
"html": "<div class=\"kole-colorpicker\" role=\"group\"></div>",
"jsx": "import { useState } from 'react';\nimport { KoleColorPicker } from 'kole-ui/react';\n\nconst PRESETS = ['#2F54EB', '#1D39C4', '#10239E', '#CF1322', '#2E7D0A', '#13C2C2', '#722ED1', '#1890FF'];\n\nexport default function Demo() {\n const [color, setColor] = useState({ hex: '#2F54EB', alpha: 1 });\n\n return <KoleColorPicker value={color.hex} presets={PRESETS} onChange={setColor} />;\n}",
"vue3": "<template>\n <KoleColorPicker :value=\"color.hex\" :presets=\"presets\" @change=\"onChange\" />\n</template>\n\n<script setup>\nimport { ref } from 'vue';\nimport { KoleColorPicker } from 'kole-ui/vue3';\n\nconst presets = ['#2F54EB', '#1D39C4', '#10239E', '#CF1322', '#2E7D0A', '#13C2C2', '#722ED1', '#1890FF'];\nconst color = ref({ hex: '#2F54EB', alpha: 1 });\n\nfunction onChange(next) {\n color.value = next;\n}\n</script>",
"vue2": "<template>\n <KoleColorPicker :value=\"color.hex\" :presets=\"presets\" @change=\"onChange\" />\n</template>\n\n<script>\nimport { KoleColorPicker } from 'kole-ui/vue2';\n\nexport default {\n components: { KoleColorPicker },\n data() {\n return {\n presets: ['#2F54EB', '#1D39C4', '#10239E', '#CF1322', '#2E7D0A', '#13C2C2', '#722ED1', '#1890FF'],\n color: { hex: '#2F54EB', alpha: 1 },\n };\n },\n methods: {\n onChange(next) {\n this.color = next;\n },\n },\n};\n</script>",
"tsx": "import { useState } from 'react';\nimport { KoleColorPicker } from 'kole-ui/react';\n\nconst PRESETS = ['#2F54EB', '#1D39C4', '#10239E', '#CF1322', '#2E7D0A', '#13C2C2', '#722ED1', '#1890FF'];\n\nexport default function Demo(): JSX.Element {\n const [color, setColor] = useState({ hex: '#2F54EB', alpha: 1 });\n\n return <KoleColorPicker value={color.hex} presets={PRESETS} onChange={setColor} />;\n}",
"vue3ts": "<template>\n\n <KoleColorPicker :value=\"color.hex\" :presets=\"presets\" @change=\"onChange\" />\n</template>\n\n<script setup lang=\"ts\">\nimport { KoleColorPicker } from 'kole-ui/vue3';\n\nconst demoTitle = ref<string>('基础用法');\nconst presets = ['#2F54EB', '#1D39C4', '#10239E', '#CF1322', '#2E7D0A', '#13C2C2', '#722ED1', '#1890FF'];\nconst color = ref({ hex: '#2F54EB', alpha: 1 });\n\nfunction onChange(next) {\n color.value = next;\n}\n</script>",
"vue2ts": "<template>\n\n <KoleColorPicker :value=\"color.hex\" :presets=\"presets\" @change=\"onChange\" />\n</template>\n\n<script lang=\"ts\">\nimport Vue from 'vue';\nimport { KoleColorPicker } from 'kole-ui/vue2';\n\nexport default {\n components: { KoleColorPicker },\n data(): Record<string, unknown> {\n return {\n presets: ['#2F54EB', '#1D39C4', '#10239E', '#CF1322', '#2E7D0A', '#13C2C2', '#722ED1', '#1890FF'],\n color: { hex: '#2F54EB', alpha: 1 },\n };\n },\n methods: {\n onChange(next) {\n this.color = next;\n },\n },\n};\n</script>"
},
"notes": [
"依据 frameworks/ColorPicker.html:17 的 PRESETS 十六色板与 :30-41 render() 生成的 .kole-colorpicker-presets/-row/-alpha 结构;prop 取 frameworks/ColorPicker.jsx:7 的 value、presets,change 载荷为 { hex, alpha }(ColorPicker.jsx:13-18)"
]
}
]
}