Skip to content

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

refactor(app): centralize demo color palette

Danila Poyarkov365c6f70d01d
diff --git a/src/app/demo/colors.ts b/src/app/demo/colors.ts
index 8f3f9631c..ba9bd4a3a 100644
--- a/src/app/demo/colors.ts
+++ b/src/app/demo/colors.ts
@@ -1,20 +1,21 @@
import { BLACK } from '@open-pencil/core/constants'
import type { Color, Fill, GradientStop, Stroke } from '@open-pencil/core/scene-graph'
-export { BLACK }
-
-export const WHITE: Color = { r: 1, g: 1, b: 1, a: 1 }
-export const GRAY_50: Color = { r: 0.98, g: 0.98, b: 0.98, a: 1 }
-export const GRAY_100: Color = { r: 0.96, g: 0.96, b: 0.97, a: 1 }
-export const GRAY_200: Color = { r: 0.9, g: 0.9, b: 0.92, a: 1 }
-export const GRAY_500: Color = { r: 0.55, g: 0.55, b: 0.58, a: 1 }
-export const BLUE: Color = { r: 0.23, g: 0.51, b: 0.96, a: 1 }
-export const INDIGO: Color = { r: 0.38, g: 0.35, b: 0.95, a: 1 }
-export const PURPLE: Color = { r: 0.59, g: 0.28, b: 0.96, a: 1 }
-export const GREEN: Color = { r: 0.13, g: 0.77, b: 0.42, a: 1 }
-export const ORANGE: Color = { r: 0.96, g: 0.52, b: 0.13, a: 1 }
-export const RED: Color = { r: 0.91, g: 0.22, b: 0.22, a: 1 }
-export const TEAL: Color = { r: 0.08, g: 0.73, b: 0.73, a: 1 }
+export const DEMO_COLORS = {
+ white: { r: 1, g: 1, b: 1, a: 1 },
+ black: BLACK,
+ gray50: { r: 0.98, g: 0.98, b: 0.98, a: 1 },
+ gray100: { r: 0.96, g: 0.96, b: 0.97, a: 1 },
+ gray200: { r: 0.9, g: 0.9, b: 0.92, a: 1 },
+ gray500: { r: 0.55, g: 0.55, b: 0.58, a: 1 },
+ blue: { r: 0.23, g: 0.51, b: 0.96, a: 1 },
+ indigo: { r: 0.38, g: 0.35, b: 0.95, a: 1 },
+ purple: { r: 0.59, g: 0.28, b: 0.96, a: 1 },
+ green: { r: 0.13, g: 0.77, b: 0.42, a: 1 },
+ orange: { r: 0.96, g: 0.52, b: 0.13, a: 1 },
+ red: { r: 0.91, g: 0.22, b: 0.22, a: 1 },
+ teal: { r: 0.08, g: 0.73, b: 0.73, a: 1 }
+} satisfies Record<string, Color>
export function solid(color: Color, opacity = 1): Fill {
return { type: 'SOLID', color, opacity, visible: true }
diff --git a/src/app/demo/sections/app-preview.ts b/src/app/demo/sections/app-preview.ts
index e9da3f567..1d0e561b2 100644
--- a/src/app/demo/sections/app-preview.ts
+++ b/src/app/demo/sections/app-preview.ts
@@ -1,17 +1,4 @@
-import {
- BLACK,
- BLUE,
- GRAY_200,
- GRAY_50,
- GRAY_500,
- GREEN,
- INDIGO,
- RED,
- WHITE,
- gradient,
- solid,
- thinStroke
-} from '@/app/demo/colors'
+import { DEMO_COLORS, gradient, solid, thinStroke } from '@/app/demo/colors'
import type { EditorStore } from '@/app/editor/session'
export function createAppPreviewSection(
@@ -27,31 +14,31 @@ export function createAppPreviewSection(
const frameId = store.createShape('FRAME', 20, 48, 520, 460, appSectionId)
graph.updateNode(frameId, {
name: 'Dashboard',
- fills: [solid(GRAY_50)],
- strokes: thinStroke(GRAY_200),
+ fills: [solid(DEMO_COLORS.gray50)],
+ strokes: thinStroke(DEMO_COLORS.gray200),
clipsContent: true
})
const sidebarId = store.createShape('RECTANGLE', 0, 0, 56, 460, frameId)
graph.updateNode(sidebarId, {
name: 'Sidebar',
- fills: [solid(WHITE)],
- strokes: thinStroke(GRAY_200)
+ fills: [solid(DEMO_COLORS.white)],
+ strokes: thinStroke(DEMO_COLORS.gray200)
})
for (let i = 0; i < 5; i++) {
const dotId = store.createShape('ELLIPSE', 18, 20 + i * 40, 20, 20, frameId)
graph.updateNode(dotId, {
name: `Nav ${i + 1}`,
- fills: [solid(i === 0 ? BLUE : GRAY_200)]
+ fills: [solid(i === 0 ? DEMO_COLORS.blue : DEMO_COLORS.gray200)]
})
}
const headerId = store.createShape('FRAME', 56, 0, 464, 52, frameId)
graph.updateNode(headerId, {
name: 'Header',
- fills: [solid(WHITE)],
- strokes: thinStroke(GRAY_200),
+ fills: [solid(DEMO_COLORS.white)],
+ strokes: thinStroke(DEMO_COLORS.gray200),
layoutMode: 'HORIZONTAL',
primaryAxisSizing: 'FIXED',
counterAxisSizing: 'FIXED',
@@ -68,7 +55,7 @@ export function createAppPreviewSection(
fontSize: 16,
fontWeight: 600,
textAutoResize: 'WIDTH_AND_HEIGHT' as const,
- fills: [solid(BLACK)]
+ fills: [solid(DEMO_COLORS.black)]
})
const badgeInstance = graph.createInstance(badgeCompId, headerId)
@@ -77,9 +64,9 @@ export function createAppPreviewSection(
if (buttonInstance) graph.updateNode(buttonInstance.id, { x: 324, y: 6 })
const stats = [
- { title: 'Revenue', value: '$12,480', badge: '+14%', color: GREEN },
- { title: 'Users', value: '3,842', badge: '+8%', color: BLUE },
- { title: 'Orders', value: '1,249', badge: '-3%', color: RED }
+ { title: 'Revenue', value: '$12,480', badge: '+14%', color: DEMO_COLORS.green },
+ { title: 'Users', value: '3,842', badge: '+8%', color: DEMO_COLORS.blue },
+ { title: 'Orders', value: '1,249', badge: '-3%', color: DEMO_COLORS.red }
]
for (let i = 0; i < stats.length; i++) {
@@ -89,8 +76,8 @@ export function createAppPreviewSection(
graph.updateNode(cId, {
name: s.title,
cornerRadius: 10,
- fills: [solid(WHITE)],
- strokes: thinStroke(GRAY_200),
+ fills: [solid(DEMO_COLORS.white)],
+ strokes: thinStroke(DEMO_COLORS.gray200),
layoutMode: 'VERTICAL',
primaryAxisSizing: 'FIXED',
counterAxisSizing: 'FIXED',
@@ -108,7 +95,7 @@ export function createAppPreviewSection(
fontWeight: 500,
textAutoResize: 'HEIGHT',
layoutAlignSelf: 'STRETCH',
- fills: [solid(GRAY_500)]
+ fills: [solid(DEMO_COLORS.gray500)]
})
const valId = store.createShape('TEXT', 0, 0, 108, 24, cId)
graph.updateNode(valId, {
@@ -118,7 +105,7 @@ export function createAppPreviewSection(
fontWeight: 700,
textAutoResize: 'HEIGHT',
layoutAlignSelf: 'STRETCH',
- fills: [solid(BLACK)]
+ fills: [solid(DEMO_COLORS.black)]
})
const bId = store.createShape('TEXT', 0, 0, 108, 14, cId)
graph.updateNode(bId, {
@@ -136,8 +123,8 @@ export function createAppPreviewSection(
graph.updateNode(chartBg, {
name: 'Chart',
cornerRadius: 10,
- fills: [solid(WHITE)],
- strokes: thinStroke(GRAY_200)
+ fills: [solid(DEMO_COLORS.white)],
+ strokes: thinStroke(DEMO_COLORS.gray200)
})
const chartTitle = store.createShape('TEXT', 16, 16, 120, 18, chartBg)
graph.updateNode(chartTitle, {
@@ -145,7 +132,7 @@ export function createAppPreviewSection(
text: 'Revenue over time',
fontSize: 13,
fontWeight: 600,
- fills: [solid(BLACK)]
+ fills: [solid(DEMO_COLORS.black)]
})
const barHeights = [60, 90, 72, 110, 95, 130, 100, 80, 120, 140, 115, 88]
@@ -164,8 +151,8 @@ export function createAppPreviewSection(
cornerRadius: 4,
fills: [
gradient([
- { color: BLUE, position: 0 },
- { color: INDIGO, position: 1 }
+ { color: DEMO_COLORS.blue, position: 0 },
+ { color: DEMO_COLORS.indigo, position: 1 }
])
]
})
@@ -174,8 +161,8 @@ export function createAppPreviewSection(
const tableId = store.createShape('FRAME', 76, 400, 424, 40, frameId)
graph.updateNode(tableId, {
name: 'Table Header',
- fills: [solid(WHITE)],
- strokes: thinStroke(GRAY_200),
+ fills: [solid(DEMO_COLORS.white)],
+ strokes: thinStroke(DEMO_COLORS.gray200),
layoutMode: 'HORIZONTAL',
primaryAxisSizing: 'FIXED',
counterAxisSizing: 'HUG',
@@ -196,7 +183,7 @@ export function createAppPreviewSection(
fontSize: 12,
fontWeight: 600,
textAutoResize: 'WIDTH_AND_HEIGHT',
- fills: [solid(GRAY_500)]
+ fills: [solid(DEMO_COLORS.gray500)]
})
}
diff --git a/src/app/demo/sections/components.ts b/src/app/demo/sections/components.ts
index 8028d77f6..0d57eba4e 100644
--- a/src/app/demo/sections/components.ts
+++ b/src/app/demo/sections/components.ts
@@ -1,20 +1,4 @@
-import {
- BLACK,
- BLUE,
- GRAY_100,
- GRAY_200,
- GRAY_500,
- GREEN,
- INDIGO,
- ORANGE,
- PURPLE,
- RED,
- TEAL,
- WHITE,
- gradient,
- solid,
- thinStroke
-} from '@/app/demo/colors'
+import { DEMO_COLORS, gradient, solid, thinStroke } from '@/app/demo/colors'
import { makeComponent } from '@/app/demo/helpers'
import type { EditorStore } from '@/app/editor/session'
@@ -35,7 +19,7 @@ export function createComponentsSection(store: EditorStore) {
graph.updateNode(btnSurfaceId, {
name: 'Surface',
cornerRadius: 8,
- fills: [solid(BLUE)],
+ fills: [solid(DEMO_COLORS.blue)],
layoutMode: 'HORIZONTAL',
primaryAxisSizing: 'HUG',
counterAxisSizing: 'HUG',
@@ -53,7 +37,7 @@ export function createComponentsSection(store: EditorStore) {
fontSize: 14,
fontWeight: 600,
textAutoResize: 'WIDTH_AND_HEIGHT',
- fills: [solid(WHITE)]
+ fills: [solid(DEMO_COLORS.white)]
})
const btnCompId = makeComponent(store, [btnId])
@@ -68,8 +52,8 @@ export function createComponentsSection(store: EditorStore) {
graph.updateNode(btn2SurfaceId, {
name: 'Surface',
cornerRadius: 8,
- fills: [solid(WHITE)],
- strokes: thinStroke(GRAY_200),
+ fills: [solid(DEMO_COLORS.white)],
+ strokes: thinStroke(DEMO_COLORS.gray200),
layoutMode: 'HORIZONTAL',
primaryAxisSizing: 'HUG',
counterAxisSizing: 'HUG',
@@ -87,7 +71,7 @@ export function createComponentsSection(store: EditorStore) {
fontSize: 14,
fontWeight: 500,
textAutoResize: 'WIDTH_AND_HEIGHT',
- fills: [solid(BLACK)]
+ fills: [solid(DEMO_COLORS.black)]
})
const btn2CompId = makeComponent(store, [btn2Id])
@@ -120,7 +104,7 @@ export function createComponentsSection(store: EditorStore) {
fontSize: 12,
fontWeight: 500,
textAutoResize: 'WIDTH_AND_HEIGHT',
- fills: [solid(INDIGO)]
+ fills: [solid(DEMO_COLORS.indigo)]
})
makeComponent(store, [chipId])
@@ -129,8 +113,8 @@ export function createComponentsSection(store: EditorStore) {
name: 'Avatar',
fills: [
gradient([
- { color: PURPLE, position: 0 },
- { color: BLUE, position: 1 }
+ { color: DEMO_COLORS.purple, position: 0 },
+ { color: DEMO_COLORS.blue, position: 1 }
])
]
})
@@ -141,8 +125,8 @@ export function createComponentsSection(store: EditorStore) {
graph.updateNode(cardId, {
name: 'Card',
cornerRadius: 12,
- fills: [solid(WHITE)],
- strokes: thinStroke(GRAY_200),
+ fills: [solid(DEMO_COLORS.white)],
+ strokes: thinStroke(DEMO_COLORS.gray200),
layoutMode: 'VERTICAL',
primaryAxisSizing: 'FIXED',
counterAxisSizing: 'FIXED',
@@ -160,7 +144,7 @@ export function createComponentsSection(store: EditorStore) {
fontWeight: 600,
textAutoResize: 'HEIGHT',
layoutAlignSelf: 'STRETCH',
- fills: [solid(BLACK)]
+ fills: [solid(DEMO_COLORS.black)]
})
const cardDescId = store.createShape('TEXT', 0, 0, 240, 36, cardId)
graph.updateNode(cardDescId, {
@@ -170,13 +154,13 @@ export function createComponentsSection(store: EditorStore) {
fontWeight: 400,
textAutoResize: 'HEIGHT',
layoutAlignSelf: 'STRETCH',
- fills: [solid(GRAY_500)]
+ fills: [solid(DEMO_COLORS.gray500)]
})
const cardBarBg = store.createShape('RECTANGLE', 0, 0, 240, 8, cardId)
graph.updateNode(cardBarBg, {
name: 'Progress BG',
cornerRadius: 4,
- fills: [solid(GRAY_100)]
+ fills: [solid(DEMO_COLORS.gray100)]
})
const cardBar = store.createShape('RECTANGLE', 0, 0, 168, 8, cardId)
graph.updateNode(cardBar, {
@@ -184,8 +168,8 @@ export function createComponentsSection(store: EditorStore) {
cornerRadius: 4,
fills: [
gradient([
- { color: BLUE, position: 0 },
- { color: TEAL, position: 1 }
+ { color: DEMO_COLORS.blue, position: 0 },
+ { color: DEMO_COLORS.teal, position: 1 }
])
]
})
@@ -195,8 +179,8 @@ export function createComponentsSection(store: EditorStore) {
graph.updateNode(inputId, {
name: 'Input',
cornerRadius: 8,
- fills: [solid(WHITE)],
- strokes: thinStroke(GRAY_200),
+ fills: [solid(DEMO_COLORS.white)],
+ strokes: thinStroke(DEMO_COLORS.gray200),
layoutMode: 'HORIZONTAL',
primaryAxisSizing: 'FIXED',
counterAxisSizing: 'HUG',
@@ -215,7 +199,7 @@ export function createComponentsSection(store: EditorStore) {
fontWeight: 400,
textAutoResize: 'HEIGHT',
layoutAlignSelf: 'STRETCH',
- fills: [solid(GRAY_500)]
+ fills: [solid(DEMO_COLORS.gray500)]
})
makeComponent(store, [inputId])
@@ -238,7 +222,7 @@ export function createComponentsSection(store: EditorStore) {
const badgeDot = store.createShape('ELLIPSE', 0, 0, 6, 6, badgeId)
graph.updateNode(badgeDot, {
name: 'Dot',
- fills: [solid(GREEN)]
+ fills: [solid(DEMO_COLORS.green)]
})
const badgeText = store.createShape('TEXT', 0, 0, 28, 14, badgeId)
graph.updateNode(badgeText, {
@@ -247,18 +231,18 @@ export function createComponentsSection(store: EditorStore) {
fontSize: 11,
fontWeight: 600,
textAutoResize: 'WIDTH_AND_HEIGHT',
- fills: [solid(GREEN)]
+ fills: [solid(DEMO_COLORS.green)]
})
const badgeCompId = makeComponent(store, [badgeId])
const swatches = [
- { name: 'Blue', color: BLUE, x: 32 },
- { name: 'Indigo', color: INDIGO, x: 88 },
- { name: 'Purple', color: PURPLE, x: 144 },
- { name: 'Green', color: GREEN, x: 200 },
- { name: 'Teal', color: TEAL, x: 256 },
- { name: 'Orange', color: ORANGE, x: 312 },
- { name: 'Red', color: RED, x: 368 }
+ { name: 'Blue', color: DEMO_COLORS.blue, x: 32 },
+ { name: 'Indigo', color: DEMO_COLORS.indigo, x: 88 },
+ { name: 'Purple', color: DEMO_COLORS.purple, x: 144 },
+ { name: 'Green', color: DEMO_COLORS.green, x: 200 },
+ { name: 'Teal', color: DEMO_COLORS.teal, x: 256 },
+ { name: 'Orange', color: DEMO_COLORS.orange, x: 312 },
+ { name: 'Red', color: DEMO_COLORS.red, x: 368 }
]
for (const swatch of swatches) {
const id = store.createShape('ELLIPSE', swatch.x, 460, 44, 44, compSectionId)
diff --git a/src/app/demo/sections/effects.ts b/src/app/demo/sections/effects.ts
index 68e3e78fc..167b6532e 100644
--- a/src/app/demo/sections/effects.ts
+++ b/src/app/demo/sections/effects.ts
@@ -1,15 +1,4 @@
-import {
- BLACK,
- BLUE,
- GRAY_100,
- GRAY_500,
- INDIGO,
- PURPLE,
- WHITE,
- gradient,
- solid,
- thinStroke
-} from '@/app/demo/colors'
+import { DEMO_COLORS, gradient, solid, thinStroke } from '@/app/demo/colors'
import { blurEffect, dropShadow, innerShadow } from '@/app/demo/effects'
import type { EditorStore } from '@/app/editor/session'
@@ -19,7 +8,7 @@ export function createEffectsSection(store: EditorStore) {
const effectsSectionId = store.createShape('SECTION', 60, 840, 920, 480)
graph.updateNode(effectsSectionId, {
name: 'Effects',
- fills: [{ type: 'SOLID', color: { r: 1, g: 1, b: 1, a: 1 }, visible: true, opacity: 1 }]
+ fills: [solid(DEMO_COLORS.white)]
})
const shadowLabel = store.createShape('TEXT', 32, 48, 200, 20, effectsSectionId)
@@ -28,14 +17,14 @@ export function createEffectsSection(store: EditorStore) {
text: 'Drop Shadow',
fontSize: 13,
fontWeight: 600,
- fills: [solid(GRAY_500)]
+ fills: [solid(DEMO_COLORS.gray500)]
})
const shadowCard1 = store.createShape('FRAME', 32, 76, 160, 100, effectsSectionId)
graph.updateNode(shadowCard1, {
name: 'Subtle Shadow',
cornerRadius: 12,
- fills: [solid(WHITE)],
+ fills: [solid(DEMO_COLORS.white)],
effects: [dropShadow(0, 2, 8, 0, { r: 0, g: 0, b: 0, a: 0.08 })]
})
const s1Text = store.createShape('TEXT', 16, 40, 128, 20, shadowCard1)
@@ -44,14 +33,14 @@ export function createEffectsSection(store: EditorStore) {
text: 'Subtle',
fontSize: 13,
fontWeight: 500,
- fills: [solid(GRAY_500)]
+ fills: [solid(DEMO_COLORS.gray500)]
})
const shadowCard2 = store.createShape('FRAME', 220, 76, 160, 100, effectsSectionId)
graph.updateNode(shadowCard2, {
name: 'Medium Shadow',
cornerRadius: 12,
- fills: [solid(WHITE)],
+ fills: [solid(DEMO_COLORS.white)],
effects: [dropShadow(0, 4, 16, 0, { r: 0, g: 0, b: 0, a: 0.15 })]
})
const s2Text = store.createShape('TEXT', 16, 40, 128, 20, shadowCard2)
@@ -60,14 +49,14 @@ export function createEffectsSection(store: EditorStore) {
text: 'Medium',
fontSize: 13,
fontWeight: 500,
- fills: [solid(GRAY_500)]
+ fills: [solid(DEMO_COLORS.gray500)]
})
const shadowCard3 = store.createShape('FRAME', 408, 76, 160, 100, effectsSectionId)
graph.updateNode(shadowCard3, {
name: 'Heavy Shadow',
cornerRadius: 12,
- fills: [solid(WHITE)],
+ fills: [solid(DEMO_COLORS.white)],
effects: [dropShadow(0, 8, 24, 0, { r: 0, g: 0, b: 0, a: 0.2 })]
})
const s3Text = store.createShape('TEXT', 16, 40, 128, 20, shadowCard3)
@@ -76,14 +65,14 @@ export function createEffectsSection(store: EditorStore) {
text: 'Heavy',
fontSize: 13,
fontWeight: 500,
- fills: [solid(GRAY_500)]
+ fills: [solid(DEMO_COLORS.gray500)]
})
const shadowCard4 = store.createShape('FRAME', 596, 76, 160, 100, effectsSectionId)
graph.updateNode(shadowCard4, {
name: 'Spread Shadow',
cornerRadius: 12,
- fills: [solid(WHITE)],
+ fills: [solid(DEMO_COLORS.white)],
effects: [dropShadow(0, 4, 12, 8, { r: 0.23, g: 0.51, b: 0.96, a: 0.3 })]
})
const s4Text = store.createShape('TEXT', 16, 40, 128, 20, shadowCard4)
@@ -92,7 +81,7 @@ export function createEffectsSection(store: EditorStore) {
text: 'With Spread',
fontSize: 13,
fontWeight: 500,
- fills: [solid(BLUE)]
+ fills: [solid(DEMO_COLORS.blue)]
})
const innerLabel = store.createShape('TEXT', 32, 208, 200, 20, effectsSectionId)
@@ -101,14 +90,14 @@ export function createEffectsSection(store: EditorStore) {
text: 'Inner Shadow',
fontSize: 13,
fontWeight: 600,
- fills: [solid(GRAY_500)]
+ fills: [solid(DEMO_COLORS.gray500)]
})
const innerCard1 = store.createShape('FRAME', 32, 236, 160, 100, effectsSectionId)
graph.updateNode(innerCard1, {
name: 'Inset Light',
cornerRadius: 12,
- fills: [solid(GRAY_100)],
+ fills: [solid(DEMO_COLORS.gray100)],
effects: [innerShadow(0, 2, 6, 0, { r: 0, g: 0, b: 0, a: 0.12 })]
})
const i1Text = store.createShape('TEXT', 16, 40, 128, 20, innerCard1)
@@ -117,14 +106,14 @@ export function createEffectsSection(store: EditorStore) {
text: 'Inset',
fontSize: 13,
fontWeight: 500,
- fills: [solid(GRAY_500)]
+ fills: [solid(DEMO_COLORS.gray500)]
})
const innerCard2 = store.createShape('FRAME', 220, 236, 160, 100, effectsSectionId)
graph.updateNode(innerCard2, {
name: 'Inset with Spread',
cornerRadius: 12,
- fills: [solid(GRAY_100)],
+ fills: [solid(DEMO_COLORS.gray100)],
effects: [innerShadow(0, 2, 8, 4, { r: 0, g: 0, b: 0, a: 0.15 })]
})
const i2Text = store.createShape('TEXT', 16, 40, 128, 20, innerCard2)
@@ -133,7 +122,7 @@ export function createEffectsSection(store: EditorStore) {
text: 'Inset + Spread',
fontSize: 13,
fontWeight: 500,
- fills: [solid(GRAY_500)]
+ fills: [solid(DEMO_COLORS.gray500)]
})
const innerEllipse = store.createShape('ELLIPSE', 408, 236, 100, 100, effectsSectionId)
@@ -152,7 +141,7 @@ export function createEffectsSection(store: EditorStore) {
graph.updateNode(comboCard, {
name: 'Combined',
cornerRadius: 12,
- fills: [solid(WHITE)],
+ fills: [solid(DEMO_COLORS.white)],
effects: [
dropShadow(0, 4, 16, 0, { r: 0, g: 0, b: 0, a: 0.12 }),
innerShadow(0, 1, 2, 0, { r: 0, g: 0, b: 0, a: 0.06 })
@@ -164,7 +153,7 @@ export function createEffectsSection(store: EditorStore) {
text: 'Drop + Inner',
fontSize: 13,
fontWeight: 500,
- fills: [solid(GRAY_500)]
+ fills: [solid(DEMO_COLORS.gray500)]
})
const textFxLabel = store.createShape('TEXT', 32, 368, 200, 20, effectsSectionId)
@@ -173,7 +162,7 @@ export function createEffectsSection(store: EditorStore) {
text: 'Text Shadow & Blur',
fontSize: 13,
fontWeight: 600,
- fills: [solid(GRAY_500)]
+ fills: [solid(DEMO_COLORS.gray500)]
})
const textShadow = store.createShape('TEXT', 32, 400, 200, 36, effectsSectionId)
@@ -182,7 +171,7 @@ export function createEffectsSection(store: EditorStore) {
text: 'Glyph Shadow',
fontSize: 28,
fontWeight: 700,
- fills: [solid(BLACK)],
+ fills: [solid(DEMO_COLORS.black)],
effects: [dropShadow(2, 2, 4, 0, { r: 0.23, g: 0.51, b: 0.96, a: 0.5 })]
})
@@ -192,7 +181,7 @@ export function createEffectsSection(store: EditorStore) {
text: 'Inner Glow',
fontSize: 28,
fontWeight: 700,
- fills: [solid(INDIGO)],
+ fills: [solid(DEMO_COLORS.indigo)],
effects: [innerShadow(0, -1, 3, 0, { r: 1, g: 1, b: 1, a: 0.6 })]
})
@@ -202,8 +191,8 @@ export function createEffectsSection(store: EditorStore) {
cornerRadius: 10,
fills: [
gradient([
- { color: PURPLE, position: 0 },
- { color: BLUE, position: 1 }
+ { color: DEMO_COLORS.purple, position: 0 },
+ { color: DEMO_COLORS.blue, position: 1 }
])
],
effects: [blurEffect('LAYER_BLUR', 4)]
@@ -223,6 +212,6 @@ export function createEffectsSection(store: EditorStore) {
text: 'Glassmorphism',
fontSize: 14,
fontWeight: 600,
- fills: [solid(BLACK)]
+ fills: [solid(DEMO_COLORS.black)]
})
}
diff --git a/src/app/demo/sections/standalone.ts b/src/app/demo/sections/standalone.ts
index 82096f626..04a235308 100644
--- a/src/app/demo/sections/standalone.ts
+++ b/src/app/demo/sections/standalone.ts
@@ -1,17 +1,4 @@
-import {
- BLACK,
- BLUE,
- GRAY_200,
- GREEN,
- ORANGE,
- PURPLE,
- RED,
- TEAL,
- WHITE,
- gradient,
- solid,
- thinStroke
-} from '@/app/demo/colors'
+import { DEMO_COLORS, gradient, solid, thinStroke } from '@/app/demo/colors'
import type { EditorStore } from '@/app/editor/session'
export function createStandaloneShapes(store: EditorStore) {
@@ -35,7 +22,7 @@ export function createStandaloneShapes(store: EditorStore) {
text: 'Linear Gradient',
fontSize: 14,
fontWeight: 600,
- fills: [solid(WHITE)]
+ fills: [solid(DEMO_COLORS.white)]
})
const grad2 = store.createShape('FRAME', 260, 660, 180, 120)
@@ -55,7 +42,7 @@ export function createStandaloneShapes(store: EditorStore) {
text: 'Ocean Breeze',
fontSize: 14,
fontWeight: 600,
- fills: [solid(WHITE)]
+ fills: [solid(DEMO_COLORS.white)]
})
const grad3 = store.createShape('FRAME', 460, 660, 180, 120)
@@ -75,15 +62,15 @@ export function createStandaloneShapes(store: EditorStore) {
text: 'Warm Sunset',
fontSize: 14,
fontWeight: 600,
- fills: [solid(WHITE)]
+ fills: [solid(DEMO_COLORS.white)]
})
const typoFrame = store.createShape('FRAME', 700, 660, 300, 120)
graph.updateNode(typoFrame, {
name: 'Typography',
cornerRadius: 12,
- fills: [solid(WHITE)],
- strokes: thinStroke(GRAY_200),
+ fills: [solid(DEMO_COLORS.white)],
+ strokes: thinStroke(DEMO_COLORS.gray200),
layoutMode: 'VERTICAL',
primaryAxisSizing: 'FIXED',
counterAxisSizing: 'FIXED',
@@ -108,7 +95,7 @@ export function createStandaloneShapes(store: EditorStore) {
fontWeight: t.weight,
textAutoResize: 'HEIGHT',
layoutAlignSelf: 'STRETCH',
- fills: [solid(BLACK)]
+ fills: [solid(DEMO_COLORS.black)]
})
}
@@ -117,24 +104,24 @@ export function createStandaloneShapes(store: EditorStore) {
type: 'ELLIPSE' as const,
x: 1060,
fill: gradient([
- { color: PURPLE, position: 0 },
- { color: BLUE, position: 1 }
+ { color: DEMO_COLORS.purple, position: 0 },
+ { color: DEMO_COLORS.blue, position: 1 }
])
},
{
type: 'RECTANGLE' as const,
x: 1160,
fill: gradient([
- { color: GREEN, position: 0 },
- { color: TEAL, position: 1 }
+ { color: DEMO_COLORS.green, position: 0 },
+ { color: DEMO_COLORS.teal, position: 1 }
])
},
{
type: 'ELLIPSE' as const,
x: 1260,
fill: gradient([
- { color: ORANGE, position: 0 },
- { color: RED, position: 1 }
+ { color: DEMO_COLORS.orange, position: 0 },
+ { color: DEMO_COLORS.red, position: 1 }
])
}
]
diff --git a/src/app/demo/sections/variables.ts b/src/app/demo/sections/variables.ts
index 95233e185..8bb4d504c 100644
--- a/src/app/demo/sections/variables.ts
+++ b/src/app/demo/sections/variables.ts
@@ -1,16 +1,6 @@
import type { Color } from '@open-pencil/core/scene-graph'
-import {
- BLACK,
- BLUE,
- GRAY_100,
- GRAY_200,
- GRAY_50,
- GRAY_500,
- GREEN,
- RED,
- WHITE
-} from '@/app/demo/colors'
+import { DEMO_COLORS } from '@/app/demo/colors'
import type { EditorStore } from '@/app/editor/session'
export function createDemoVariables(store: EditorStore) {
@@ -33,40 +23,50 @@ export function createDemoVariables(store: EditorStore) {
light: Color
dark: Color
}> = [
- { id: 'var-white', name: 'White', light: WHITE, dark: { r: 0.12, g: 0.12, b: 0.13, a: 1 } },
- { id: 'var-black', name: 'Black', light: BLACK, dark: WHITE },
+ {
+ id: 'var-white',
+ name: 'White',
+ light: DEMO_COLORS.white,
+ dark: { r: 0.12, g: 0.12, b: 0.13, a: 1 }
+ },
+ { id: 'var-black', name: 'Black', light: DEMO_COLORS.black, dark: DEMO_COLORS.white },
{
id: 'var-gray-50',
name: 'Gray/50',
- light: GRAY_50,
+ light: DEMO_COLORS.gray50,
dark: { r: 0.1, g: 0.1, b: 0.11, a: 1 }
},
{
id: 'var-gray-100',
name: 'Gray/100',
- light: GRAY_100,
+ light: DEMO_COLORS.gray100,
dark: { r: 0.14, g: 0.14, b: 0.16, a: 1 }
},
{
id: 'var-gray-200',
name: 'Gray/200',
- light: GRAY_200,
+ light: DEMO_COLORS.gray200,
dark: { r: 0.22, g: 0.22, b: 0.24, a: 1 }
},
{
id: 'var-gray-500',
name: 'Gray/500',
- light: GRAY_500,
+ light: DEMO_COLORS.gray500,
dark: { r: 0.65, g: 0.65, b: 0.68, a: 1 }
},
- { id: 'var-blue', name: 'Blue', light: BLUE, dark: { r: 0.33, g: 0.61, b: 1, a: 1 } },
+ {
+ id: 'var-blue',
+ name: 'Blue',
+ light: DEMO_COLORS.blue,
+ dark: { r: 0.33, g: 0.61, b: 1, a: 1 }
+ },
{
id: 'var-green',
name: 'Green',
- light: GREEN,
+ light: DEMO_COLORS.green,
dark: { r: 0.23, g: 0.87, b: 0.52, a: 1 }
},
- { id: 'var-red', name: 'Red', light: RED, dark: { r: 1, g: 0.32, b: 0.32, a: 1 } }
+ { id: 'var-red', name: 'Red', light: DEMO_COLORS.red, dark: { r: 1, g: 0.32, b: 0.32, a: 1 } }
]
for (const c of primitiveColors) {