diff --git a/docs/.vitepress/components/IconCustomizer.vue b/docs/.vitepress/components/IconCustomizer.vue index a79efd9ec..fac73e947 100644 --- a/docs/.vitepress/components/IconCustomizer.vue +++ b/docs/.vitepress/components/IconCustomizer.vue @@ -1,44 +1,60 @@ - - Customizer - + + + Customizer + + + + + @@ -88,13 +104,13 @@ syncRef(size, iconSize) Size - {{ iconSize }}px + {{ size }}px @@ -112,12 +128,19 @@ syncRef(size, iconSize) display: block; } +.card-header { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 12px; +} + .card-title { font-weight: 700; color: var(--vp-c-text-1); line-height: 32px; font-size: 16px; - margin-bottom: 12px; + /* margin-bottom: 12px; */ } .card { background: var(--vp-c-bg); @@ -189,4 +212,31 @@ syncRef(size, iconSize) margin-bottom: 8px; gap: 12px; } + +.reset-button { + background: none; + padding: 0; + transition: ease-in-out 0.1s transform; +} + +.reset-button:hover { + background: none; + border-color: transparent; +} + +/* a rotate css animation keyframes */ +@keyframes rotate { + 0% { + transform: rotate(0deg); + } + 100% { + transform: rotate(359deg); + } +} + +.reset-button:active { + transform: rotate(45deg); +} + + diff --git a/docs/.vitepress/components/IconItem.vue b/docs/.vitepress/components/IconItem.vue index bc478510d..cac544d3d 100644 --- a/docs/.vitepress/components/IconItem.vue +++ b/docs/.vitepress/components/IconItem.vue @@ -44,7 +44,7 @@ function navigateToIcon() { :aria-label="name" > - + diff --git a/docs/.vitepress/components/IconPreview.vue b/docs/.vitepress/components/IconPreview.vue index 8893dbcbe..3b9f070b3 100644 --- a/docs/.vitepress/components/IconPreview.vue +++ b/docs/.vitepress/components/IconPreview.vue @@ -2,7 +2,7 @@ import type { IconEntity } from '../types' import { computed } from 'vue' import createLucideIcon from 'lucide-vue-next/src/createLucideIcon'; -import { useIconSizeContext } from '../composables/useSharedSize'; +import { useIconStyleContext } from '../composables/useIconStyle'; const props = defineProps<{ name: IconEntity['name'] @@ -10,7 +10,7 @@ const props = defineProps<{ customizable?: boolean }>() -const { size } = useIconSizeContext() +const { size, color, strokeWidth } = useIconStyleContext() const gridLines = computed(() => Array.from({ length:(size.value - 1) })) @@ -27,6 +27,8 @@ const iconComponent = computed(() => { class="icon-component" :class="{ customizable }" :size="size" + :color="color" + :stroke-width="strokeWidth" /> @@ -64,7 +66,7 @@ const iconComponent = computed(() => { .icon-component.customizable { will-change: width, height, stroke-width, stroke; - color: var(--customize-color, currentColor); - stroke-width: var(--customize-strokeWidth, 2); + /* color: var(--customize-color, currentColor); + stroke-width: var(--customize-strokeWidth, 2); */ } diff --git a/docs/.vitepress/composables/useIconStyle.ts b/docs/.vitepress/composables/useIconStyle.ts new file mode 100644 index 000000000..3df4144df --- /dev/null +++ b/docs/.vitepress/composables/useIconStyle.ts @@ -0,0 +1,35 @@ +/* eslint-disable no-console */ + +import { + ref, provide, inject, Ref +} from 'vue'; + +export const ICON_STYLE_CONTEXT = Symbol('size'); + +interface IconSizeContext { + size: Ref + strokeWidth: Ref + color: Ref +} + +export const context = { + size: ref(24), + strokeWidth: ref(2), + color: ref('currentColor'), +}; + +export function useIconStyleProvider(): IconSizeContext { + provide(ICON_STYLE_CONTEXT, context); + + return context; +} + +export function useIconStyleContext(): IconSizeContext{ + const context = inject(ICON_STYLE_CONTEXT); + + if (!context) { + throw new Error('useIconStyleContext must be used with useIconStyleProvider'); + } + + return context; +} diff --git a/docs/.vitepress/composables/useSharedSize.ts b/docs/.vitepress/composables/useSharedSize.ts deleted file mode 100644 index 5d691afeb..000000000 --- a/docs/.vitepress/composables/useSharedSize.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* eslint-disable no-console */ - -import { - ref, provide, inject, Ref -} from 'vue'; - -export const SIZE_CONTEXT_NAME = Symbol('size'); - -interface IconSizeContext { - size: Ref -} - -export const context = { - size: ref(24), -}; - -export function useIconSizeProvider(): IconSizeContext { - provide(SIZE_CONTEXT_NAME, context); - - return context; -} - -export function useIconSizeContext(): IconSizeContext{ - const context = inject(SIZE_CONTEXT_NAME); - - if (!context) { - throw new Error('useIconSizeContext must be used with useIconSizeProvider'); - } - - return context; -} diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts index 66ce0b12d..0a7ea527e 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -4,7 +4,7 @@ import './style.css' import { Theme } from 'vitepress' import IconsSidebarNavAfter from './layouts/IconsSidebarNavAfter.vue' import HomeHeroIconsCard from '../components/HomeHeroIconsCard.vue' -import { SIZE_CONTEXT_NAME, context } from '../composables/useSharedSize' +import { ICON_STYLE_CONTEXT, context } from '../composables/useIconStyle' const theme: Partial = { extends: DefaultTheme, @@ -15,7 +15,7 @@ const theme: Partial = { }) }, enhanceApp({ app }) { - app.provide(SIZE_CONTEXT_NAME,context) + app.provide(ICON_STYLE_CONTEXT, context) } } diff --git a/docs/nitro.config.ts b/docs/nitro.config.ts index 1518e28ee..e8144e15e 100644 --- a/docs/nitro.config.ts +++ b/docs/nitro.config.ts @@ -4,7 +4,7 @@ export default defineNitroConfig({ preset: 'vercel-edge', srcDir: '.vitepress', routeRules: { - '/api/**': { cors: false, swr: true }, + '/api/**': { cors: false }, }, esbuild: { options: { diff --git a/scripts/writeIconNodes.mjs b/scripts/writeIconNodes.mjs index 90b8042f1..129e5cb9f 100644 --- a/scripts/writeIconNodes.mjs +++ b/scripts/writeIconNodes.mjs @@ -10,14 +10,16 @@ const icons = renderIconsObject(svgFiles, ICONS_DIR, true); const iconNodesDirectory = path.resolve(currentDir, 'iconNodes'); -fs.unlinkSync(path.resolve(currentDir, 'iconNodes/index.ts')); +if (fs.existsSync(iconNodesDirectory)) { + fs.unlinkSync(path.resolve(currentDir, 'iconNodes')); +} if (!fs.existsSync(iconNodesDirectory)) { fs.mkdirSync(iconNodesDirectory); } const writeIconFiles = Object.entries(icons).map(async ([iconName, { children }]) => { - const location = path.resolve(iconNodesDirectory, `${iconName}.json`); + const location = path.resolve(iconNodesDirectory, `${iconName}.node.json`); const iconNode = children.map(({ name, attributes }) => [name, attributes]); const output = JSON.stringify(iconNode, null, 2); @@ -26,7 +28,7 @@ const writeIconFiles = Object.entries(icons).map(async ([iconName, { children }] const indexFile = path.resolve(iconNodesDirectory, `index.ts`); await fs.promises.appendFile( indexFile, - `export { default as ${toCamelCase(iconName)} } from './${iconName}.json';\n`, + `export { default as ${toCamelCase(iconName)} } from './${iconName}.node.json';\n`, 'utf-8', ); });