Skip to content

AI-native design editor. Open-source Figma alternative.

Polish fill/stroke sections: editable hex, opacity %, eye toggle, minus

Danila Poyarkovbabeecc76ec1
diff --git a/components.d.ts b/components.d.ts
index f9a2687db..dde5a2604 100644
--- a/components.d.ts
+++ b/components.d.ts
@@ -23,6 +23,8 @@ declare module 'vue' {
IconLucideCheck: typeof import('~icons/lucide/check')['default']
IconLucideChevronDown: typeof import('~icons/lucide/chevron-down')['default']
IconLucideChevronRight: typeof import('~icons/lucide/chevron-right')['default']
+ IconLucideEye: typeof import('~icons/lucide/eye')['default']
+ IconLucideEyeOff: typeof import('~icons/lucide/eye-off')['default']
IconLucideSearch: typeof import('~icons/lucide/search')['default']
LayersPanel: typeof import('./src/components/LayersPanel.vue')['default']
LayoutSection: typeof import('./src/components/properties/LayoutSection.vue')['default']
diff --git a/src/components/properties/FillSection.vue b/src/components/properties/FillSection.vue
index 3a2d24d90..be4643afc 100644
--- a/src/components/properties/FillSection.vue
+++ b/src/components/properties/FillSection.vue
@@ -2,15 +2,15 @@
import ColorPicker from '../ColorPicker.vue'
import { useEditorStore } from '../../stores/editor'
import { DEFAULT_SHAPE_FILL } from '../../constants'
+import { colorToHex, parseColor } from '../../engine/color'
import type { Color, Fill } from '../../engine/scene-graph'
const props = defineProps<{ nodeId: string; fills: Fill[] }>()
const store = useEditorStore()
-function colorHex(c: Color) {
- const hex = (v: number) => Math.round(v * 255).toString(16).padStart(2, '0')
- return `#${hex(c.r)}${hex(c.g)}${hex(c.b)}`
+function hexString(c: Color) {
+ return colorToHex(c).slice(1).toUpperCase()
}
function updateColor(index: number, color: Color) {
@@ -19,12 +19,16 @@ function updateColor(index: number, color: Color) {
store.updateNodeWithUndo(props.nodeId, { fills }, 'Change fill')
}
-function add() {
- store.updateNodeWithUndo(props.nodeId, { fills: [...props.fills, { ...DEFAULT_SHAPE_FILL }] }, 'Add fill')
+function updateHex(index: number, hex: string) {
+ const color = parseColor(hex.startsWith('#') ? hex : `#${hex}`)
+ if (!color) return
+ updateColor(index, color)
}
-function remove(index: number) {
- store.updateNodeWithUndo(props.nodeId, { fills: props.fills.filter((_, i) => i !== index) }, 'Change fill')
+function updateOpacity(index: number, opacity: number) {
+ const fills = [...props.fills]
+ fills[index] = { ...fills[index], opacity: Math.max(0, Math.min(1, opacity / 100)) }
+ store.updateNodeWithUndo(props.nodeId, { fills }, 'Change fill')
}
function toggleVisibility(index: number) {
@@ -32,23 +36,46 @@ function toggleVisibility(index: number) {
fills[index] = { ...fills[index], visible: !fills[index].visible }
store.updateNodeWithUndo(props.nodeId, { fills }, 'Change fill')
}
+
+function add() {
+ store.updateNodeWithUndo(props.nodeId, { fills: [...props.fills, { ...DEFAULT_SHAPE_FILL }] }, 'Add fill')
+}
+
+function remove(index: number) {
+ store.updateNodeWithUndo(props.nodeId, { fills: props.fills.filter((_, i) => i !== index) }, 'Remove fill')
+}
</script>
<template>
<div class="border-b border-border px-3 py-2">
<div class="flex items-center justify-between">
- <label class="mb-1.5 block text-[11px] text-muted">Fill</label>
+ <label class="mb-1 block text-[11px] text-muted">Fill</label>
<button class="cursor-pointer rounded border-none bg-transparent px-1 text-base leading-none text-muted hover:bg-hover hover:text-surface" @click="add">+</button>
</div>
<div v-for="(fill, i) in fills" :key="i" class="group flex items-center gap-1.5 py-0.5">
+ <ColorPicker :color="fill.color" @update="updateColor(i, $event)" />
+ <input
+ class="min-w-0 flex-1 border-none bg-transparent font-mono text-xs text-surface outline-none"
+ :value="hexString(fill.color)"
+ @change="updateHex(i, ($event.target as HTMLInputElement).value)"
+ />
+ <input
+ type="number"
+ class="w-10 rounded border border-border bg-input px-1 py-0.5 text-right text-[11px] text-surface [&::-webkit-inner-spin-button]:hidden"
+ :value="Math.round(fill.opacity * 100)"
+ min="0"
+ max="100"
+ @change="updateOpacity(i, +($event.target as HTMLInputElement).value)"
+ />
+ <span class="text-[11px] text-muted">%</span>
<button
- class="w-4 cursor-pointer border-none bg-transparent p-0 text-center text-xs text-muted"
- :class="{ 'opacity-40': !fill.visible }"
+ class="cursor-pointer border-none bg-transparent p-0 text-muted opacity-0 transition-opacity group-hover:opacity-100 hover:text-surface"
@click="toggleVisibility(i)"
- >{{ fill.visible ? '◉' : '○' }}</button>
- <ColorPicker :color="fill.color" @update="updateColor(i, $event)" />
- <span class="flex-1 font-mono text-xs">{{ colorHex(fill.color) }}</span>
- <button class="cursor-pointer border-none bg-transparent px-0.5 text-sm leading-none text-muted opacity-0 transition-opacity group-hover:opacity-100 hover:text-surface" @click="remove(i)">×</button>
+ >
+ <icon-lucide-eye v-if="fill.visible" class="size-3.5" />
+ <icon-lucide-eye-off v-else class="size-3.5" />
+ </button>
+ <button class="cursor-pointer border-none bg-transparent p-0 text-sm leading-none text-muted hover:text-surface" @click="remove(i)">−</button>
</div>
</div>
</template>
diff --git a/src/components/properties/StrokeSection.vue b/src/components/properties/StrokeSection.vue
index 85408ec19..988415cf1 100644
--- a/src/components/properties/StrokeSection.vue
+++ b/src/components/properties/StrokeSection.vue
@@ -1,15 +1,15 @@
<script setup lang="ts">
import ColorPicker from '../ColorPicker.vue'
import { useEditorStore } from '../../stores/editor'
+import { colorToHex, parseColor } from '../../engine/color'
import type { Color, Stroke } from '../../engine/scene-graph'
const props = defineProps<{ nodeId: string; strokes: Stroke[] }>()
const store = useEditorStore()
-function colorHex(c: Color) {
- const hex = (v: number) => Math.round(v * 255).toString(16).padStart(2, '0')
- return `#${hex(c.r)}${hex(c.g)}${hex(c.b)}`
+function hexString(c: Color) {
+ return colorToHex(c).slice(1).toUpperCase()
}
function updateColor(index: number, color: Color) {
@@ -18,39 +18,81 @@ function updateColor(index: number, color: Color) {
store.updateNodeWithUndo(props.nodeId, { strokes }, 'Change stroke')
}
+function updateHex(index: number, hex: string) {
+ const color = parseColor(hex.startsWith('#') ? hex : `#${hex}`)
+ if (!color) return
+ updateColor(index, color)
+}
+
function updateWeight(index: number, weight: number) {
const strokes = [...props.strokes]
strokes[index] = { ...strokes[index], weight }
store.updateNodeWithUndo(props.nodeId, { strokes }, 'Change stroke')
}
+function updateOpacity(index: number, opacity: number) {
+ const strokes = [...props.strokes]
+ strokes[index] = { ...strokes[index], opacity: Math.max(0, Math.min(1, opacity / 100)) }
+ store.updateNodeWithUndo(props.nodeId, { strokes }, 'Change stroke')
+}
+
+function toggleVisibility(index: number) {
+ const strokes = [...props.strokes]
+ strokes[index] = { ...strokes[index], visible: !strokes[index].visible }
+ store.updateNodeWithUndo(props.nodeId, { strokes }, 'Change stroke')
+}
+
function add() {
const stroke: Stroke = { color: { r: 0, g: 0, b: 0, a: 1 }, weight: 1, opacity: 1, visible: true, align: 'CENTER' }
store.updateNodeWithUndo(props.nodeId, { strokes: [...props.strokes, stroke] }, 'Add stroke')
}
function remove(index: number) {
- store.updateNodeWithUndo(props.nodeId, { strokes: props.strokes.filter((_, i) => i !== index) }, 'Change stroke')
+ store.updateNodeWithUndo(props.nodeId, { strokes: props.strokes.filter((_, i) => i !== index) }, 'Remove stroke')
}
</script>
<template>
<div class="border-b border-border px-3 py-2">
<div class="flex items-center justify-between">
- <label class="mb-1.5 block text-[11px] text-muted">Stroke</label>
+ <label class="mb-1 block text-[11px] text-muted">Stroke</label>
<button class="cursor-pointer rounded border-none bg-transparent px-1 text-base leading-none text-muted hover:bg-hover hover:text-surface" @click="add">+</button>
</div>
<div v-for="(stroke, i) in strokes" :key="i" class="group flex items-center gap-1.5 py-0.5">
<ColorPicker :color="stroke.color" @update="updateColor(i, $event)" />
- <span class="flex-1 font-mono text-xs">{{ colorHex(stroke.color) }}</span>
+ <input
+ class="min-w-0 flex-1 border-none bg-transparent font-mono text-xs text-surface outline-none"
+ :value="hexString(stroke.color)"
+ @change="updateHex(i, ($event.target as HTMLInputElement).value)"
+ />
+ <input
+ type="number"
+ class="w-10 rounded border border-border bg-input px-1 py-0.5 text-right text-[11px] text-surface [&::-webkit-inner-spin-button]:hidden"
+ :value="Math.round(stroke.opacity * 100)"
+ min="0"
+ max="100"
+ @change="updateOpacity(i, +($event.target as HTMLInputElement).value)"
+ />
+ <span class="text-[11px] text-muted">%</span>
+ <button
+ class="cursor-pointer border-none bg-transparent p-0 text-muted opacity-0 transition-opacity group-hover:opacity-100 hover:text-surface"
+ @click="toggleVisibility(i)"
+ >
+ <icon-lucide-eye v-if="stroke.visible" class="size-3.5" />
+ <icon-lucide-eye-off v-else class="size-3.5" />
+ </button>
+ <button class="cursor-pointer border-none bg-transparent p-0 text-sm leading-none text-muted hover:text-surface" @click="remove(i)">−</button>
+ </div>
+ <!-- Stroke weight (shown when any strokes exist) -->
+ <div v-if="strokes.length > 0" class="mt-1 flex items-center gap-1.5">
+ <span class="text-[11px] text-muted">Weight</span>
<input
type="number"
- class="w-9 rounded border border-border bg-input px-1 py-0.5 text-center text-[11px] text-surface [&::-webkit-inner-spin-button]:hidden"
- :value="stroke.weight"
+ class="w-12 rounded border border-border bg-input px-1.5 py-0.5 text-center text-[11px] text-surface [&::-webkit-inner-spin-button]:hidden"
+ :value="strokes[0].weight"
min="0"
- @change="updateWeight(i, +($event.target as HTMLInputElement).value)"
+ @change="updateWeight(0, +($event.target as HTMLInputElement).value)"
/>
- <button class="cursor-pointer border-none bg-transparent px-0.5 text-sm leading-none text-muted opacity-0 transition-opacity group-hover:opacity-100 hover:text-surface" @click="remove(i)">×</button>
</div>
</div>
</template>