diff --git a/docs/.vitepress/theme/components/icons/IconPreview.vue b/docs/.vitepress/theme/components/icons/IconPreview.vue index 5e4b634d6..4cd4f5142 100644 --- a/docs/.vitepress/theme/components/icons/IconPreview.vue +++ b/docs/.vitepress/theme/components/icons/IconPreview.vue @@ -3,6 +3,7 @@ import type { IconEntity } from '../../types'; import { computed, ref } from 'vue'; import createLucideIcon from '@lucide/vue/src/createLucideIcon'; import { useIconStyleContext } from '../../composables/useIconStyle'; +import { squarePen } from '../../../data/iconNodes'; const props = defineProps<{ name: IconEntity['name']; @@ -19,6 +20,31 @@ const iconComponent = computed(() => { if (!props.name || !props.iconNode) return null; return createLucideIcon(props.name, props.iconNode); }); + +const SquarePenIcon = createLucideIcon('SquarePen', squarePen); + +const innerSvg = computed(() => { + if (!props.iconNode) return ''; + + const string = props.iconNode + .map(([tag, attrs]) => { + const attributes = Object.entries(attrs) + .map(([key, value]) => `${key}="${value}"`) + .join(' '); + return `<${tag} ${attributes}/>`; + }) + .join(''); + + return string + .replace(/>[\r\n ]+<') + .replace(/(<.*?>)|\s+/g, (m, $1) => $1 || ' ') + .trim(); +}); + +const base64InnerSvg = computed(() => { + if (typeof window === 'undefined') return ''; + return btoa(innerSvg.value); +}); @@ -75,6 +111,8 @@ const iconComponent = computed(() => { position: relative; background: var(--vp-c-bg-alt); border-radius: 8px; + overflow: hidden; + flex-shrink: 0; } .icon-container > :deep(svg:not(.icon-grid)) { width: 100%; @@ -85,6 +123,34 @@ const iconComponent = computed(() => { opacity: 0.8; } +.studio-button { + position: absolute; + bottom: 8px; + right: 8px; + background: var(--vp-c-bg); + border: 1px solid var(--vp-c-divider); + border-radius: 6px; + padding: 5px; + display: flex; + align-items: center; + justify-content: center; + color: var(--vp-c-text-2); + opacity: 0; + transition: opacity 0.2s, color 0.2s, background-color 0.2s; + z-index: 2; +} + +.icon-container:hover .studio-button, +.studio-button:focus-visible { + opacity: 1; +} + +.studio-button:hover, +.studio-button:focus-visible { + background: var(--vp-c-bg-soft); + color: var(--vp-c-text-1); +} + .icon-component.customizable { will-change: width, height, stroke-width, stroke; /* color: var(--customize-color, currentColor);