@zyro-sec/ui 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +29 -0
- package/bunfig.toml +2 -0
- package/package.json +21 -114
- package/perf/motion.bench.ts +14 -0
- package/perf/motion.ts +16 -0
- package/script/build-oc2-v2-overrides.ts +38 -0
- package/script/colors.txt +288 -0
- package/script/generate-spinner.ts +121 -0
- package/script/pack.ts +5 -0
- package/script/tailwind.ts +24 -0
- package/src/actions/button/button.stories.tsx +158 -0
- package/src/actions/icon-button/icon-button.stories.tsx +122 -0
- package/src/actions/split-button/split-button.stories.tsx +59 -0
- package/src/assets/favicon/apple-touch-icon-v3.png +0 -0
- package/src/assets/favicon/apple-touch-icon.png +0 -0
- package/src/assets/favicon/favicon-96x96-v3.png +0 -0
- package/src/assets/favicon/favicon-96x96.png +0 -0
- package/src/assets/favicon/favicon-v3.ico +0 -0
- package/src/assets/favicon/favicon-v3.svg +7 -0
- package/src/assets/favicon/favicon.ico +0 -0
- package/src/assets/favicon/favicon.svg +7 -0
- package/src/assets/favicon/site.webmanifest +24 -0
- package/src/assets/favicon/web-app-manifest-192x192.png +0 -0
- package/src/assets/favicon/web-app-manifest-512x512.png +0 -0
- package/src/assets/icons/provider/302ai.svg +7 -0
- package/src/assets/icons/provider/abacus.svg +14 -0
- package/src/assets/icons/provider/aihubmix.svg +3 -0
- package/src/assets/icons/provider/alibaba-cn.svg +3 -0
- package/src/assets/icons/provider/alibaba-coding-plan-cn.svg +3 -0
- package/src/assets/icons/provider/alibaba-coding-plan.svg +3 -0
- package/src/assets/icons/provider/alibaba.svg +3 -0
- package/src/assets/icons/provider/amazon-bedrock.svg +3 -0
- package/src/assets/icons/provider/anthropic.svg +3 -0
- package/src/assets/icons/provider/azure-cognitive-services.svg +24 -0
- package/src/assets/icons/provider/azure.svg +3 -0
- package/src/assets/icons/provider/bailing.svg +3 -0
- package/src/assets/icons/provider/baseten.svg +3 -0
- package/src/assets/icons/provider/berget.svg +3 -0
- package/src/assets/icons/provider/cerebras.svg +4 -0
- package/src/assets/icons/provider/chutes.svg +24 -0
- package/src/assets/icons/provider/clarifai.svg +24 -0
- package/src/assets/icons/provider/claude-agent.svg +3 -0
- package/src/assets/icons/provider/cloudferro-sherlock.svg +5 -0
- package/src/assets/icons/provider/cloudflare-ai-gateway.svg +4 -0
- package/src/assets/icons/provider/cloudflare-workers-ai.svg +4 -0
- package/src/assets/icons/provider/cohere.svg +5 -0
- package/src/assets/icons/provider/cortecs.svg +24 -0
- package/src/assets/icons/provider/deepinfra.svg +4 -0
- package/src/assets/icons/provider/deepseek.svg +3 -0
- package/src/assets/icons/provider/digitalocean.svg +6 -0
- package/src/assets/icons/provider/dinference.svg +1 -0
- package/src/assets/icons/provider/drun.svg +8 -0
- package/src/assets/icons/provider/evroc.svg +3 -0
- package/src/assets/icons/provider/fastrouter.svg +3 -0
- package/src/assets/icons/provider/fireworks-ai.svg +3 -0
- package/src/assets/icons/provider/firmware.svg +18 -0
- package/src/assets/icons/provider/friendli.svg +3 -0
- package/src/assets/icons/provider/github-copilot.svg +3 -0
- package/src/assets/icons/provider/github-models.svg +3 -0
- package/src/assets/icons/provider/gitlab.svg +3 -0
- package/src/assets/icons/provider/google-vertex-anthropic.svg +24 -0
- package/src/assets/icons/provider/google-vertex.svg +10 -0
- package/src/assets/icons/provider/google.svg +3 -0
- package/src/assets/icons/provider/groq.svg +3 -0
- package/src/assets/icons/provider/helicone.svg +6 -0
- package/src/assets/icons/provider/huggingface.svg +3 -0
- package/src/assets/icons/provider/iflowcn.svg +3 -0
- package/src/assets/icons/provider/inception.svg +4 -0
- package/src/assets/icons/provider/inference.svg +3 -0
- package/src/assets/icons/provider/io-net.svg +5 -0
- package/src/assets/icons/provider/jiekou.svg +4 -0
- package/src/assets/icons/provider/kilo.svg +4 -0
- package/src/assets/icons/provider/kimi-for-coding.svg +3 -0
- package/src/assets/icons/provider/kuae-cloud-coding-plan.svg +3 -0
- package/src/assets/icons/provider/llama.svg +3 -0
- package/src/assets/icons/provider/lmstudio.svg +24 -0
- package/src/assets/icons/provider/lucidquery.svg +3 -0
- package/src/assets/icons/provider/meganova.svg +3 -0
- package/src/assets/icons/provider/meituan.svg +6 -0
- package/src/assets/icons/provider/meta.svg +3 -0
- package/src/assets/icons/provider/minimax-cn-coding-plan.svg +24 -0
- package/src/assets/icons/provider/minimax-cn.svg +3 -0
- package/src/assets/icons/provider/minimax-coding-plan.svg +24 -0
- package/src/assets/icons/provider/minimax.svg +3 -0
- package/src/assets/icons/provider/mistral.svg +3 -0
- package/src/assets/icons/provider/moark.svg +3 -0
- package/src/assets/icons/provider/modelscope.svg +5 -0
- package/src/assets/icons/provider/moonshotai-cn.svg +3 -0
- package/src/assets/icons/provider/moonshotai.svg +3 -0
- package/src/assets/icons/provider/morph.svg +24 -0
- package/src/assets/icons/provider/nano-gpt.svg +3 -0
- package/src/assets/icons/provider/nebius.svg +4 -0
- package/src/assets/icons/provider/nova.svg +3 -0
- package/src/assets/icons/provider/novita-ai.svg +10 -0
- package/src/assets/icons/provider/nvidia.svg +3 -0
- package/src/assets/icons/provider/ollama-cloud.svg +7 -0
- package/src/assets/icons/provider/openai.svg +3 -0
- package/src/assets/icons/provider/opencode-go.svg +3 -0
- package/src/assets/icons/provider/opencode.svg +3 -0
- package/src/assets/icons/provider/openrouter.svg +3 -0
- package/src/assets/icons/provider/ovhcloud.svg +3 -0
- package/src/assets/icons/provider/perplexity-agent.svg +3 -0
- package/src/assets/icons/provider/perplexity.svg +3 -0
- package/src/assets/icons/provider/poe.svg +7 -0
- package/src/assets/icons/provider/privatemode-ai.svg +5 -0
- package/src/assets/icons/provider/qihang-ai.svg +9 -0
- package/src/assets/icons/provider/qiniu-ai.svg +7 -0
- package/src/assets/icons/provider/reflection.svg +3 -0
- package/src/assets/icons/provider/requesty.svg +24 -0
- package/src/assets/icons/provider/sap-ai-core.svg +24 -0
- package/src/assets/icons/provider/scaleway.svg +5 -0
- package/src/assets/icons/provider/siliconflow-cn.svg +3 -0
- package/src/assets/icons/provider/siliconflow.svg +3 -0
- package/src/assets/icons/provider/stackit.svg +4 -0
- package/src/assets/icons/provider/stepfun.svg +16 -0
- package/src/assets/icons/provider/submodel.svg +3 -0
- package/src/assets/icons/provider/synthetic.svg +24 -0
- package/src/assets/icons/provider/tencent-coding-plan.svg +5 -0
- package/src/assets/icons/provider/tencent.svg +3 -0
- package/src/assets/icons/provider/thinkingmachines.svg +3 -0
- package/src/assets/icons/provider/togetherai.svg +4 -0
- package/src/assets/icons/provider/upstage.svg +24 -0
- package/src/assets/icons/provider/v0.svg +3 -0
- package/src/assets/icons/provider/venice.svg +4 -0
- package/src/assets/icons/provider/vercel.svg +3 -0
- package/src/assets/icons/provider/vivgrid.svg +4 -0
- package/src/assets/icons/provider/vultr.svg +6 -0
- package/src/assets/icons/provider/wandb.svg +24 -0
- package/src/assets/icons/provider/xai.svg +3 -0
- package/src/assets/icons/provider/xiaomi.svg +3 -0
- package/src/assets/icons/provider/zai-coding-plan.svg +3 -0
- package/src/assets/icons/provider/zai.svg +3 -0
- package/src/assets/icons/provider/zenmux.svg +4 -0
- package/src/assets/icons/provider/zhipuai-coding-plan.svg +3 -0
- package/src/assets/icons/provider/zhipuai.svg +3 -0
- package/src/assets/images/social-share-black.png +0 -0
- package/src/assets/images/social-share-zen.png +0 -0
- package/src/assets/images/social-share.png +0 -0
- package/src/components/animated-number-machine.test.ts +140 -0
- package/src/components/animated-number.stories.tsx +35 -0
- package/src/components/app-icon.stories.tsx +73 -0
- package/src/components/card.stories.tsx +101 -0
- package/src/components/collapsible.stories.tsx +76 -0
- package/src/components/context-menu.stories.tsx +150 -0
- package/src/components/diagram-preview.stories.tsx +62 -0
- package/src/components/dock-surface.stories.tsx +26 -0
- package/src/components/document-surface.stories.tsx +42 -0
- package/src/components/error-details.stories.tsx +72 -0
- package/src/components/favicon.stories.tsx +49 -0
- package/src/components/file-icon-machine.test.ts +52 -0
- package/src/components/file-icon.stories.tsx +93 -0
- package/src/components/file-icons/sprite.svg +11707 -0
- package/src/components/font.stories.tsx +48 -0
- package/src/components/hover-card.stories.tsx +79 -0
- package/src/components/image-flight-machine.test.ts +184 -0
- package/src/components/image-flight.test.ts +173 -0
- package/src/components/image-preview.stories.tsx +392 -0
- package/src/components/image-zoom-machine.test.ts +154 -0
- package/src/components/image-zoom.test.ts +96 -0
- package/src/components/list.stories.tsx +221 -0
- package/src/components/logo.stories.tsx +62 -0
- package/src/components/menu-scroll.stories.tsx +73 -0
- package/src/components/popover-machine.test.ts +150 -0
- package/src/components/popover.stories.tsx +84 -0
- package/src/components/preview-controls.stories.tsx +40 -0
- package/src/components/progress.stories.tsx +69 -0
- package/src/components/provider-icon.stories.tsx +75 -0
- package/src/components/resize-handle-machine.test.ts +164 -0
- package/src/components/resize-handle.stories.tsx +81 -0
- package/src/components/rolling-number.stories.tsx +23 -0
- package/src/components/scroll-view-machine.test.ts +141 -0
- package/src/components/scroll-view.stories.tsx +68 -0
- package/src/components/scroll-view.test.ts +114 -0
- package/src/components/spinner-radar.test.ts +61 -0
- package/src/components/spinner.stories.tsx +40 -0
- package/src/components/sticky-accordion-header.stories.tsx +64 -0
- package/src/components/text-field-machine.test.ts +99 -0
- package/src/components/text-field.stories.tsx +132 -0
- package/src/components/text-reveal-machine.test.ts +157 -0
- package/src/components/text-reveal.stories.tsx +363 -0
- package/src/components/text-strikethrough.stories.tsx +296 -0
- package/src/components/thinking-heading.stories.tsx +900 -0
- package/src/components/truncated-text.stories.tsx +37 -0
- package/src/components/typewriter-machine.test.ts +177 -0
- package/src/components/typewriter.stories.tsx +51 -0
- package/src/context/dialog-machine.test.ts +295 -0
- package/src/context/i18n.test.ts +89 -0
- package/src/context/marked-base.test.ts +75 -0
- package/src/context/marked-parser.test.ts +167 -0
- package/src/context/marked-regression.test.ts +12 -0
- package/src/data-display/accordion/accordion.stories.tsx +76 -0
- package/src/data-display/avatar/avatar.stories.tsx +48 -0
- package/src/data-display/badge/badge.stories.tsx +75 -0
- package/src/data-display/diff-changes/diff-changes.stories.tsx +63 -0
- package/src/data-display/keybind/keybind.stories.tsx +77 -0
- package/src/data-display/line-comment/line-comment.stories.tsx +288 -0
- package/src/data-display/line-comment/machine.test.ts +385 -0
- package/src/data-display/project-avatar/animation-machine.test.ts +134 -0
- package/src/data-display/project-avatar/generated.test.ts +50 -0
- package/src/data-display/project-avatar/procedural.test.ts +16 -0
- package/src/data-display/project-avatar/project-avatar.stories.tsx +102 -0
- package/src/data-display/project-avatar/project-avatar.test.ts +21 -0
- package/src/data-display/project-avatar/project-icon-styles.stories.tsx +772 -0
- package/src/feedback/activity-ring/activity-ring.stories.tsx +20 -0
- package/src/feedback/loader/loader.stories.tsx +44 -0
- package/src/feedback/progress-circle/progress-circle.stories.tsx +56 -0
- package/src/feedback/toast/description.test.ts +20 -0
- package/src/feedback/toast/machine.test.ts +106 -0
- package/src/feedback/toast/toast.stories.tsx +186 -0
- package/src/forms/checkbox/checkbox.stories.tsx +104 -0
- package/src/forms/field/field.stories.tsx +129 -0
- package/src/forms/inline-input/inline-input.stories.tsx +37 -0
- package/src/forms/radio/radio.stories.tsx +145 -0
- package/src/forms/redirect-paste/redirect-paste.stories.tsx +101 -0
- package/src/forms/search-list/navigation.test.ts +40 -0
- package/src/forms/search-list/search-list.stories.tsx +108 -0
- package/src/forms/select/machine.test.ts +105 -0
- package/src/forms/select/select.stories.tsx +208 -0
- package/src/forms/switch/switch.stories.tsx +97 -0
- package/src/forms/text-input/text-input.stories.tsx +220 -0
- package/src/forms/textarea/textarea.stories.tsx +137 -0
- package/src/forms/typeahead/machine.test.ts +143 -0
- package/src/forms/typeahead/typeahead.stories.tsx +113 -0
- package/src/hooks/auto-scroll-machine.test.ts +212 -0
- package/src/hooks/list-machine.test.ts +263 -0
- package/src/hooks/spin-phase.test.ts +32 -0
- package/src/hooks/use-filtered-list.test.ts +41 -0
- package/src/icons/icon/icon.stories.tsx +131 -0
- package/src/layout/divider/divider.stories.tsx +38 -0
- package/src/motion/README.md +113 -0
- package/src/motion/core.test.ts +328 -0
- package/src/motion-tuning-features.test.ts +129 -0
- package/src/motion-tuning.test.ts +68 -0
- package/src/navigation/menu/machine.test.ts +85 -0
- package/src/navigation/menu/menu.stories.tsx +328 -0
- package/src/navigation/menu/submenu-machine.test.ts +71 -0
- package/src/navigation/segmented-control/segmented-control.stories.tsx +115 -0
- package/src/navigation/segmented-control/segmented-control.test.ts +123 -0
- package/src/navigation/tab-state-indicator.stories.tsx +24 -0
- package/src/navigation/tabs/tabs.stories.tsx +193 -0
- package/src/overlays/dialog/dialog.stories.tsx +365 -0
- package/src/overlays/mcp-sign-in/machine.test.ts +215 -0
- package/src/overlays/tooltip/machine.test.ts +214 -0
- package/src/overlays/tooltip/tooltip.stories.tsx +155 -0
- package/src/styles/blue-tokens.stories.tsx +215 -0
- package/src/theme/desktop-theme.schema.json +168 -0
- package/src/theme/machine.test.ts +498 -0
- package/src/theme/v2/resolve.test.ts +120 -0
- package/src/typography/slash/slash.stories.tsx +26 -0
- package/src/typography/text-shimmer/machine.test.ts +117 -0
- package/src/typography/text-shimmer/text-shimmer.stories.tsx +64 -0
- package/src/typography/wordmark/wordmark.stories.tsx +19 -0
- package/test/solid-jsx.ts +20 -0
- package/tsconfig.build.json +14 -0
- package/tsconfig.json +23 -0
- package/vite.config.ts +61 -0
|
@@ -0,0 +1,772 @@
|
|
|
1
|
+
import { createEffect, createMemo, For, on, onCleanup, onMount, Show, type JSX } from "solid-js"
|
|
2
|
+
import { createStore } from "solid-js/store"
|
|
3
|
+
import { Icon as Glyph } from "../../icons/icon/icon"
|
|
4
|
+
import oc2 from "../../theme/themes/oc-2.json"
|
|
5
|
+
import type { DesktopTheme } from "../../theme/types"
|
|
6
|
+
import { resolveThemeV2, themeV2ToCss } from "../../theme/v2/resolve"
|
|
7
|
+
import { PROJECT_ICON_FAMILIES, PROJECT_ICON_STYLES, projectIconStyle, type ProjectIconStyle } from "./procedural"
|
|
8
|
+
import "./project-avatar.css"
|
|
9
|
+
|
|
10
|
+
const docs = `### Overview
|
|
11
|
+
Candidate procedural styles for the generated default project avatar, next to James's mesh. Each style resolves its
|
|
12
|
+
params once from a key, like the mesh, and draws on a 2D canvas clipped to the avatar's rounded tile.
|
|
13
|
+
|
|
14
|
+
### Gallery
|
|
15
|
+
- Rows are grouped by family; columns are fictional project names at 32, 20 and 16 px, then a large preview.
|
|
16
|
+
- The top shows the style in context, on the dark and light themes, at the sizes the app uses: the sidebar's session
|
|
17
|
+
tabs, the tab strip, the session header, Home's projects, the inbox (all 16 px) and project settings (32 px).
|
|
18
|
+
- Hover a row to show its style in context; click an icon to keep it there. Hover an icon to play its animation (off
|
|
19
|
+
with reduced motion). Click a row's star to keep it; stars persist in this browser.
|
|
20
|
+
|
|
21
|
+
### Controls
|
|
22
|
+
- \`style\` and \`family\`: one style, one family or all. \`starred\`: starred styles only.
|
|
23
|
+
- \`name\`: a seed of your own, shown in the first column. \`size\`: the large preview.
|
|
24
|
+
- \`surface\`: dark or light gallery. \`animate\`: hover animation.
|
|
25
|
+
`
|
|
26
|
+
|
|
27
|
+
const NAMES = [
|
|
28
|
+
"atlas",
|
|
29
|
+
"quill",
|
|
30
|
+
"harbor-api",
|
|
31
|
+
"nimbus",
|
|
32
|
+
"copperleaf",
|
|
33
|
+
"tern",
|
|
34
|
+
"lumen-ui",
|
|
35
|
+
"basalt",
|
|
36
|
+
"orchard",
|
|
37
|
+
"vesper",
|
|
38
|
+
"kiln",
|
|
39
|
+
"driftwood",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
// What each fictional project is doing in the mock app: its session title and Home's waiting and running counts.
|
|
43
|
+
const SESSIONS = [
|
|
44
|
+
"Fix flaky auth test",
|
|
45
|
+
"Draft release notes",
|
|
46
|
+
"Rate limit the webhooks",
|
|
47
|
+
"Port charts to canvas",
|
|
48
|
+
"Tidy the onboarding copy",
|
|
49
|
+
"Bump the SDK",
|
|
50
|
+
"Dark mode for settings",
|
|
51
|
+
"Investigate memory leak",
|
|
52
|
+
"Add CSV export",
|
|
53
|
+
"Refactor the queue",
|
|
54
|
+
"Kiln firing schedule",
|
|
55
|
+
"Sync offline edits",
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
const SIZES = [32, 20, 16]
|
|
59
|
+
|
|
60
|
+
const STARS_KEY = "opencode.lab.project-icon-styles.starred"
|
|
61
|
+
|
|
62
|
+
const SURFACES = {
|
|
63
|
+
dark: {
|
|
64
|
+
background: "#141414",
|
|
65
|
+
text: "#ededed",
|
|
66
|
+
muted: "#8a8a8a",
|
|
67
|
+
hairline: "rgba(255, 255, 255, 0.08)",
|
|
68
|
+
ring: "rgba(255, 255, 255, 0.85)",
|
|
69
|
+
},
|
|
70
|
+
light: {
|
|
71
|
+
background: "#fafafa",
|
|
72
|
+
text: "#171717",
|
|
73
|
+
muted: "#737373",
|
|
74
|
+
hairline: "rgba(0, 0, 0, 0.08)",
|
|
75
|
+
ring: "rgba(0, 0, 0, 0.8)",
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// The default theme's tokens for each scheme, so the in-context mocks show both at once whatever the lab shows.
|
|
80
|
+
const THEMES = (() => {
|
|
81
|
+
// SAFETY: this is the bundled desktop theme; JSON imports widen its hex palette values to strings.
|
|
82
|
+
const theme = resolveThemeV2(oc2 as DesktopTheme)
|
|
83
|
+
|
|
84
|
+
return { dark: themeV2ToCss(theme.dark), light: themeV2ToCss(theme.light) }
|
|
85
|
+
})()
|
|
86
|
+
|
|
87
|
+
type Args = {
|
|
88
|
+
style: string
|
|
89
|
+
family: string
|
|
90
|
+
starred: boolean
|
|
91
|
+
name: string
|
|
92
|
+
size: number
|
|
93
|
+
surface: keyof typeof SURFACES
|
|
94
|
+
animate: boolean
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export default {
|
|
98
|
+
title: "UI/ProjectIconStyles",
|
|
99
|
+
id: "ui-project-icon-styles",
|
|
100
|
+
parameters: {
|
|
101
|
+
layout: "fullscreen",
|
|
102
|
+
gridPreview: () => (
|
|
103
|
+
<div class="grid size-full grid-cols-4 place-content-center justify-items-center gap-6 p-8">
|
|
104
|
+
<For each={PROJECT_ICON_STYLES.slice(0, 12)}>
|
|
105
|
+
{(style) => <Icon style={style} name="atlas" size={88} animate={false} />}
|
|
106
|
+
</For>
|
|
107
|
+
</div>
|
|
108
|
+
),
|
|
109
|
+
docs: {
|
|
110
|
+
description: {
|
|
111
|
+
component: docs,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
argTypes: {
|
|
116
|
+
style: {
|
|
117
|
+
control: "select",
|
|
118
|
+
options: ["all", ...PROJECT_ICON_STYLES.map((style) => style.id)],
|
|
119
|
+
},
|
|
120
|
+
family: {
|
|
121
|
+
control: "select",
|
|
122
|
+
options: ["all", ...PROJECT_ICON_FAMILIES],
|
|
123
|
+
},
|
|
124
|
+
size: {
|
|
125
|
+
control: { type: "range", min: 48, max: 160, step: 8 },
|
|
126
|
+
},
|
|
127
|
+
surface: {
|
|
128
|
+
control: "select",
|
|
129
|
+
options: ["dark", "light"],
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
args: {
|
|
133
|
+
style: "all",
|
|
134
|
+
family: "all",
|
|
135
|
+
starred: false,
|
|
136
|
+
name: "",
|
|
137
|
+
size: 88,
|
|
138
|
+
surface: "dark",
|
|
139
|
+
animate: true,
|
|
140
|
+
} satisfies Args,
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export const Gallery = {
|
|
144
|
+
render: (args: Args) => <GalleryView args={args} />,
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export const ContactSheet = {
|
|
148
|
+
render: (args: Args) => <ContactSheetView args={args} />,
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function filteredStyles(args: Args, starred: readonly string[]) {
|
|
152
|
+
return PROJECT_ICON_STYLES.filter(
|
|
153
|
+
(style) =>
|
|
154
|
+
(args.style === "all" || style.id === args.style) &&
|
|
155
|
+
(args.family === "all" || style.family === args.family) &&
|
|
156
|
+
(!args.starred || starred.includes(style.id)),
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function GalleryView(props: { args: Args }) {
|
|
161
|
+
const surface = () => (props.args.surface === "light" ? SURFACES.light : SURFACES.dark)
|
|
162
|
+
const names = () => (props.args.name ? [props.args.name, ...NAMES.slice(1)] : NAMES)
|
|
163
|
+
|
|
164
|
+
const [state, setState] = createStore({
|
|
165
|
+
style: props.args.style === "all" ? "mesh" : props.args.style,
|
|
166
|
+
name: props.args.name || NAMES[0],
|
|
167
|
+
hover: "",
|
|
168
|
+
starred: readStars(),
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
createEffect(
|
|
172
|
+
on(
|
|
173
|
+
() => state.starred.length,
|
|
174
|
+
() => writeStars(state.starred),
|
|
175
|
+
{ defer: true },
|
|
176
|
+
),
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
const styles = createMemo(() => filteredStyles(props.args, state.starred))
|
|
180
|
+
|
|
181
|
+
const families = createMemo(() =>
|
|
182
|
+
PROJECT_ICON_FAMILIES.map((family) => ({
|
|
183
|
+
family,
|
|
184
|
+
styles: styles().filter((style) => style.family === family),
|
|
185
|
+
})).filter((group) => group.styles.length),
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
// A hovered row previews its style; leaving the gallery returns to the chosen one.
|
|
189
|
+
const spotlight = () => projectIconStyle(state.hover || state.style)
|
|
190
|
+
const starred = (style: ProjectIconStyle) => state.starred.includes(style.id)
|
|
191
|
+
|
|
192
|
+
const toggleStar = (style: ProjectIconStyle) =>
|
|
193
|
+
setState("starred", (list) =>
|
|
194
|
+
list.includes(style.id) ? list.filter((id) => id !== style.id) : [...list, style.id],
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
createEffect(
|
|
198
|
+
on(
|
|
199
|
+
() => props.args.name,
|
|
200
|
+
(name) => name && setState("name", name),
|
|
201
|
+
{ defer: true },
|
|
202
|
+
),
|
|
203
|
+
)
|
|
204
|
+
createEffect(
|
|
205
|
+
on(
|
|
206
|
+
() => props.args.style,
|
|
207
|
+
(style) => style !== "all" && setState("style", style),
|
|
208
|
+
{ defer: true },
|
|
209
|
+
),
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
const isSelected = (style: ProjectIconStyle, name: string) => state.style === style.id && state.name === name
|
|
213
|
+
|
|
214
|
+
// Fixed columns: a label, one 32 + 20 + 16 px trio per name, then the large preview.
|
|
215
|
+
const row = () => ({
|
|
216
|
+
display: "grid",
|
|
217
|
+
"grid-template-columns": `200px repeat(${names().length}, 80px) 48px`,
|
|
218
|
+
"column-gap": "24px",
|
|
219
|
+
"align-items": "center",
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
const tile = (style: ProjectIconStyle, name: string, size: number) => (
|
|
223
|
+
<Tile
|
|
224
|
+
style={style}
|
|
225
|
+
name={name}
|
|
226
|
+
size={size}
|
|
227
|
+
animate={props.args.animate}
|
|
228
|
+
selected={isSelected(style, name)}
|
|
229
|
+
ring={surface().ring}
|
|
230
|
+
onSelect={() => setState({ style: style.id, name, hover: "" })}
|
|
231
|
+
/>
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
return (
|
|
235
|
+
<div
|
|
236
|
+
style={{
|
|
237
|
+
// The lab's canvas is a flex column: without this the gallery shrinks to its height and the header stops sticking.
|
|
238
|
+
"flex-shrink": 0,
|
|
239
|
+
"min-height": "100%",
|
|
240
|
+
"min-width": "max-content",
|
|
241
|
+
padding: "0 24px 24px",
|
|
242
|
+
background: surface().background,
|
|
243
|
+
color: surface().text,
|
|
244
|
+
"font-size": "13px",
|
|
245
|
+
"line-height": "16px",
|
|
246
|
+
}}
|
|
247
|
+
>
|
|
248
|
+
<div style={{ position: "sticky", top: "0", "z-index": 1, background: surface().background }}>
|
|
249
|
+
<div style={{ display: "flex", gap: "24px", "align-items": "flex-start", padding: "24px 0 16px" }}>
|
|
250
|
+
<div style={{ display: "flex", "flex-direction": "column", gap: "12px", width: "200px", "flex-shrink": 0 }}>
|
|
251
|
+
<Icon style={spotlight()} name={state.name} size={props.args.size} animate={props.args.animate} />
|
|
252
|
+
<div style={{ display: "flex", "flex-direction": "column", gap: "4px" }}>
|
|
253
|
+
<div style={{ display: "flex", gap: "6px", "align-items": "center", "font-weight": 500 }}>
|
|
254
|
+
<span>{spotlight().name}</span>
|
|
255
|
+
<Star on={starred(spotlight())} muted={surface().muted} onToggle={() => toggleStar(spotlight())} />
|
|
256
|
+
</div>
|
|
257
|
+
<div style={{ color: surface().muted, "font-size": "12px" }}>
|
|
258
|
+
{spotlight().family} · {state.name}
|
|
259
|
+
</div>
|
|
260
|
+
<div style={{ color: surface().muted, "font-size": "12px" }}>{spotlight().label}</div>
|
|
261
|
+
<div style={{ color: surface().muted, "font-size": "12px", "padding-top": "8px" }}>
|
|
262
|
+
In context: 16 px in the tab strip, the sidebar's tabs, the session header, Home's projects and the
|
|
263
|
+
inbox; 32 px in project settings.
|
|
264
|
+
</div>
|
|
265
|
+
</div>
|
|
266
|
+
</div>
|
|
267
|
+
<InContext style={spotlight()} scheme="dark" animate={props.args.animate} />
|
|
268
|
+
<InContext style={spotlight()} scheme="light" animate={props.args.animate} />
|
|
269
|
+
</div>
|
|
270
|
+
<div style={{ ...row(), color: surface().muted, "font-size": "12px", "padding-bottom": "8px" }}>
|
|
271
|
+
<div>
|
|
272
|
+
{styles().length} styles
|
|
273
|
+
<Show when={state.starred.length}> · {state.starred.length} starred</Show>
|
|
274
|
+
</div>
|
|
275
|
+
<For each={names()}>
|
|
276
|
+
{(name) => (
|
|
277
|
+
<div style={{ "white-space": "nowrap", overflow: "hidden", "text-overflow": "ellipsis" }}>{name}</div>
|
|
278
|
+
)}
|
|
279
|
+
</For>
|
|
280
|
+
</div>
|
|
281
|
+
</div>
|
|
282
|
+
<div onPointerLeave={() => setState("hover", "")}>
|
|
283
|
+
<Show
|
|
284
|
+
when={families().length}
|
|
285
|
+
fallback={
|
|
286
|
+
<div style={{ padding: "24px 0", color: surface().muted }}>
|
|
287
|
+
No styles match. Star a style with the star beside its name.
|
|
288
|
+
</div>
|
|
289
|
+
}
|
|
290
|
+
>
|
|
291
|
+
<For each={families()}>
|
|
292
|
+
{(group) => (
|
|
293
|
+
<section>
|
|
294
|
+
<div
|
|
295
|
+
style={{
|
|
296
|
+
padding: "24px 0 8px",
|
|
297
|
+
color: surface().muted,
|
|
298
|
+
"font-size": "11px",
|
|
299
|
+
"font-weight": 500,
|
|
300
|
+
"letter-spacing": "0.06em",
|
|
301
|
+
"text-transform": "uppercase",
|
|
302
|
+
"border-bottom": `1px solid ${surface().hairline}`,
|
|
303
|
+
}}
|
|
304
|
+
>
|
|
305
|
+
{group.family} · {group.styles.length}
|
|
306
|
+
</div>
|
|
307
|
+
<For each={group.styles}>
|
|
308
|
+
{(style) => (
|
|
309
|
+
<div
|
|
310
|
+
data-style={style.id}
|
|
311
|
+
onPointerEnter={() => setState("hover", style.id)}
|
|
312
|
+
style={{
|
|
313
|
+
...row(),
|
|
314
|
+
padding: "12px 0",
|
|
315
|
+
"border-top": `1px solid ${surface().hairline}`,
|
|
316
|
+
background: state.hover === style.id ? surface().hairline : "transparent",
|
|
317
|
+
}}
|
|
318
|
+
>
|
|
319
|
+
<div style={{ display: "flex", gap: "8px", "align-items": "flex-start" }}>
|
|
320
|
+
<Star on={starred(style)} muted={surface().muted} onToggle={() => toggleStar(style)} />
|
|
321
|
+
<button
|
|
322
|
+
type="button"
|
|
323
|
+
onClick={() => setState({ style: style.id, hover: "" })}
|
|
324
|
+
style={{ ...reset, padding: "0", "text-align": "start", flex: 1 }}
|
|
325
|
+
>
|
|
326
|
+
<div style={{ "font-weight": 500 }}>{style.name}</div>
|
|
327
|
+
<div style={{ color: surface().muted, "font-size": "12px", "padding-top": "2px" }}>
|
|
328
|
+
{style.label}
|
|
329
|
+
</div>
|
|
330
|
+
</button>
|
|
331
|
+
</div>
|
|
332
|
+
<For each={names()}>
|
|
333
|
+
{(name) => (
|
|
334
|
+
<div style={{ display: "flex", gap: "6px", "align-items": "flex-end" }}>
|
|
335
|
+
<For each={SIZES}>{(size) => tile(style, name, size)}</For>
|
|
336
|
+
</div>
|
|
337
|
+
)}
|
|
338
|
+
</For>
|
|
339
|
+
{tile(style, state.name, 48)}
|
|
340
|
+
</div>
|
|
341
|
+
)}
|
|
342
|
+
</For>
|
|
343
|
+
</section>
|
|
344
|
+
)}
|
|
345
|
+
</For>
|
|
346
|
+
</Show>
|
|
347
|
+
</div>
|
|
348
|
+
</div>
|
|
349
|
+
)
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// A mock of the app's chrome built from the same layout values as the real surfaces (tab-nav.tsx, home/start,
|
|
353
|
+
// session-identity-header.tsx, inbox.tsx and settings/workspaces/project.tsx), with the style's icons for every project.
|
|
354
|
+
function InContext(props: { style: ProjectIconStyle; scheme: "dark" | "light"; animate: boolean }) {
|
|
355
|
+
const avatar = (name: string, size = 16) => (
|
|
356
|
+
<Icon style={props.style} name={name} size={size} animate={props.animate} />
|
|
357
|
+
)
|
|
358
|
+
|
|
359
|
+
const text = (color: string, extra: JSX.CSSProperties = {}) => ({
|
|
360
|
+
color: `var(--v2-text-text-${color})`,
|
|
361
|
+
"font-size": "13px",
|
|
362
|
+
"line-height": "16px",
|
|
363
|
+
"white-space": "nowrap" as const,
|
|
364
|
+
overflow: "hidden",
|
|
365
|
+
"text-overflow": "ellipsis",
|
|
366
|
+
...extra,
|
|
367
|
+
})
|
|
368
|
+
|
|
369
|
+
return (
|
|
370
|
+
<div data-scheme={props.scheme} style={`${THEMES[props.scheme]} color-scheme: ${props.scheme}; flex-shrink: 0;`}>
|
|
371
|
+
<div
|
|
372
|
+
style={{
|
|
373
|
+
width: "480px",
|
|
374
|
+
"border-radius": "10px",
|
|
375
|
+
overflow: "hidden",
|
|
376
|
+
background: "var(--v2-background-bg-deep)",
|
|
377
|
+
"box-shadow": "0 0 0 0.5px var(--v2-border-border-base), 0 8px 24px rgba(0, 0, 0, 0.18)",
|
|
378
|
+
"font-size": "13px",
|
|
379
|
+
}}
|
|
380
|
+
>
|
|
381
|
+
<div style={{ display: "flex", "align-items": "center", gap: "4px", height: "36px", padding: "0 8px" }}>
|
|
382
|
+
<div style={{ display: "flex", gap: "6px", padding: "0 8px 0 4px" }}>
|
|
383
|
+
<For each={[0, 1, 2]}>
|
|
384
|
+
{() => (
|
|
385
|
+
<span
|
|
386
|
+
style={{
|
|
387
|
+
width: "10px",
|
|
388
|
+
height: "10px",
|
|
389
|
+
"border-radius": "9999px",
|
|
390
|
+
background: "var(--v2-background-bg-layer-03)",
|
|
391
|
+
}}
|
|
392
|
+
/>
|
|
393
|
+
)}
|
|
394
|
+
</For>
|
|
395
|
+
</div>
|
|
396
|
+
<For each={[11, 3, 1, 6]}>
|
|
397
|
+
{(project, i) => (
|
|
398
|
+
<Tab active={i() === 1} width="96px">
|
|
399
|
+
{avatar(NAMES[project])}
|
|
400
|
+
<span style={text(i() === 1 ? "base" : "faint", { "font-weight": 500 })}>{SESSIONS[project]}</span>
|
|
401
|
+
</Tab>
|
|
402
|
+
)}
|
|
403
|
+
</For>
|
|
404
|
+
</div>
|
|
405
|
+
<div style={{ display: "grid", "grid-template-columns": "168px 1fr", height: "264px" }}>
|
|
406
|
+
<div
|
|
407
|
+
style={{ display: "flex", "flex-direction": "column", gap: "2px", padding: "4px 8px", overflow: "hidden" }}
|
|
408
|
+
>
|
|
409
|
+
<For each={["Home", "Search sessions"]}>
|
|
410
|
+
{(label, i) => (
|
|
411
|
+
<div style={{ display: "flex", "align-items": "center", gap: "6px", height: "28px", padding: "0 6px" }}>
|
|
412
|
+
<Glyph
|
|
413
|
+
name={i() === 0 ? "grid-plus" : "magnifying-glass"}
|
|
414
|
+
size="small"
|
|
415
|
+
style={{ color: "var(--v2-icon-icon-muted)", width: "16px" }}
|
|
416
|
+
/>
|
|
417
|
+
<span style={text("muted")}>{label}</span>
|
|
418
|
+
</div>
|
|
419
|
+
)}
|
|
420
|
+
</For>
|
|
421
|
+
<div style={{ height: "8px" }} />
|
|
422
|
+
<For each={NAMES.slice(0, 6)}>
|
|
423
|
+
{(name, i) => (
|
|
424
|
+
<Tab active={i() === 3}>
|
|
425
|
+
{avatar(name)}
|
|
426
|
+
<span
|
|
427
|
+
style={text(i() === 3 ? "base" : "faint", { "font-weight": 500, "text-transform": "uppercase" })}
|
|
428
|
+
>
|
|
429
|
+
{name}
|
|
430
|
+
</span>
|
|
431
|
+
</Tab>
|
|
432
|
+
)}
|
|
433
|
+
</For>
|
|
434
|
+
</div>
|
|
435
|
+
<div
|
|
436
|
+
style={{
|
|
437
|
+
display: "flex",
|
|
438
|
+
"flex-direction": "column",
|
|
439
|
+
gap: "8px",
|
|
440
|
+
padding: "8px 12px",
|
|
441
|
+
background: "var(--v2-background-bg-base)",
|
|
442
|
+
"border-top-left-radius": "8px",
|
|
443
|
+
"box-shadow": "0 0 0 0.5px var(--v2-border-border-muted)",
|
|
444
|
+
overflow: "hidden",
|
|
445
|
+
}}
|
|
446
|
+
>
|
|
447
|
+
<div style={{ display: "flex", "align-items": "center", gap: "6px", height: "24px", padding: "0 4px" }}>
|
|
448
|
+
{avatar(NAMES[3])}
|
|
449
|
+
<span style={text("muted", { "font-weight": 440 })}>{NAMES[3]}</span>
|
|
450
|
+
<span style={text("faint", { "font-size": "12px" })}>/ {SESSIONS[3]}</span>
|
|
451
|
+
</div>
|
|
452
|
+
<div style={{ display: "flex", "flex-direction": "column" }}>
|
|
453
|
+
<div style={{ ...text("muted", { "font-size": "12px", "font-weight": 500 }), padding: "6px 8px" }}>
|
|
454
|
+
Projects
|
|
455
|
+
</div>
|
|
456
|
+
<For each={NAMES.slice(4, 8)}>
|
|
457
|
+
{(name, i) => (
|
|
458
|
+
<div
|
|
459
|
+
style={{
|
|
460
|
+
display: "flex",
|
|
461
|
+
"align-items": "center",
|
|
462
|
+
gap: "8px",
|
|
463
|
+
height: "32px",
|
|
464
|
+
padding: "0 8px",
|
|
465
|
+
"border-radius": "6px",
|
|
466
|
+
background: i() === 0 ? "var(--v2-overlay-simple-overlay-hover)" : "transparent",
|
|
467
|
+
}}
|
|
468
|
+
>
|
|
469
|
+
{avatar(name)}
|
|
470
|
+
<span style={{ ...text("base"), flex: 1 }}>{name}</span>
|
|
471
|
+
<Show when={i() < 3}>
|
|
472
|
+
<span
|
|
473
|
+
style={text("faint", {
|
|
474
|
+
"font-size": "12px",
|
|
475
|
+
color: i() === 0 ? "var(--v2-state-fg-warning)" : "var(--v2-text-text-faint)",
|
|
476
|
+
})}
|
|
477
|
+
>
|
|
478
|
+
{[2, 1, 3][i()]}
|
|
479
|
+
</span>
|
|
480
|
+
</Show>
|
|
481
|
+
</div>
|
|
482
|
+
)}
|
|
483
|
+
</For>
|
|
484
|
+
</div>
|
|
485
|
+
<For each={NAMES.slice(8, 10)}>
|
|
486
|
+
{(name, i) => (
|
|
487
|
+
<div style={{ display: "flex", "align-items": "center", gap: "6px", height: "16px", padding: "0 8px" }}>
|
|
488
|
+
{avatar(name)}
|
|
489
|
+
<span style={{ ...text("faint", { "font-size": "12px" }), flex: 1 }}>{name}</span>
|
|
490
|
+
<span style={text("faint", { "font-size": "12px" })}>{["3m", "1h"][i()]}</span>
|
|
491
|
+
</div>
|
|
492
|
+
)}
|
|
493
|
+
</For>
|
|
494
|
+
</div>
|
|
495
|
+
</div>
|
|
496
|
+
<div
|
|
497
|
+
style={{
|
|
498
|
+
display: "flex",
|
|
499
|
+
"align-items": "center",
|
|
500
|
+
gap: "12px",
|
|
501
|
+
padding: "12px 16px",
|
|
502
|
+
background: "var(--v2-background-bg-base)",
|
|
503
|
+
"border-top": "0.5px solid var(--v2-border-border-muted)",
|
|
504
|
+
}}
|
|
505
|
+
>
|
|
506
|
+
{avatar(NAMES[10], 32)}
|
|
507
|
+
<div style={{ display: "flex", "flex-direction": "column", gap: "2px", "min-width": 0 }}>
|
|
508
|
+
<span style={text("base", { "font-size": "15px", "line-height": "20px", "font-weight": 530 })}>
|
|
509
|
+
{NAMES[10]}
|
|
510
|
+
</span>
|
|
511
|
+
<span style={text("faint", { "font-size": "12px" })}>Project settings</span>
|
|
512
|
+
</div>
|
|
513
|
+
</div>
|
|
514
|
+
</div>
|
|
515
|
+
</div>
|
|
516
|
+
)
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// The tab-nav tab: 28 px tall, 6 px radius and padding, a 16 px avatar slot, pressed overlay when active.
|
|
520
|
+
function Tab(props: { active: boolean; width?: string; children: JSX.Element }) {
|
|
521
|
+
return (
|
|
522
|
+
<div
|
|
523
|
+
style={{
|
|
524
|
+
display: "flex",
|
|
525
|
+
"align-items": "center",
|
|
526
|
+
gap: "6px",
|
|
527
|
+
height: "28px",
|
|
528
|
+
width: props.width,
|
|
529
|
+
"min-width": 0,
|
|
530
|
+
padding: "0 6px",
|
|
531
|
+
"border-radius": "6px",
|
|
532
|
+
background: props.active ? "var(--v2-overlay-simple-overlay-pressed)" : "transparent",
|
|
533
|
+
"flex-shrink": props.width ? 1 : 0,
|
|
534
|
+
}}
|
|
535
|
+
>
|
|
536
|
+
{props.children}
|
|
537
|
+
</div>
|
|
538
|
+
)
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
function Star(props: { on: boolean; muted: string; onToggle: () => void }) {
|
|
542
|
+
return (
|
|
543
|
+
<button
|
|
544
|
+
type="button"
|
|
545
|
+
aria-label={props.on ? "Unstar" : "Star"}
|
|
546
|
+
aria-pressed={props.on}
|
|
547
|
+
onClick={(event) => {
|
|
548
|
+
event.stopPropagation()
|
|
549
|
+
props.onToggle()
|
|
550
|
+
}}
|
|
551
|
+
style={{ ...reset, padding: "0", width: "16px", height: "16px", "flex-shrink": 0 }}
|
|
552
|
+
>
|
|
553
|
+
<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true">
|
|
554
|
+
<path
|
|
555
|
+
d="M8 1.8l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 11.6l-3.8 2 .7-4.3-3.1-3 4.3-.6z"
|
|
556
|
+
fill={props.on ? "#f5b301" : "none"}
|
|
557
|
+
stroke={props.on ? "#f5b301" : props.muted}
|
|
558
|
+
stroke-width="1.2"
|
|
559
|
+
stroke-linejoin="round"
|
|
560
|
+
/>
|
|
561
|
+
</svg>
|
|
562
|
+
</button>
|
|
563
|
+
)
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
function readStars(): string[] {
|
|
567
|
+
try {
|
|
568
|
+
const value: unknown = JSON.parse(localStorage.getItem(STARS_KEY) ?? "[]")
|
|
569
|
+
|
|
570
|
+
return Array.isArray(value)
|
|
571
|
+
? PROJECT_ICON_STYLES.filter((style) => value.includes(style.id)).map((style) => style.id)
|
|
572
|
+
: []
|
|
573
|
+
} catch {
|
|
574
|
+
return []
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
function writeStars(ids: readonly string[]) {
|
|
579
|
+
try {
|
|
580
|
+
localStorage.setItem(STARS_KEY, JSON.stringify(ids))
|
|
581
|
+
} catch {}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
// Every style × six names at 32, 20 and 16 px, in three columns: the proof still for review.
|
|
585
|
+
function ContactSheetView(props: { args: Args }) {
|
|
586
|
+
const surface = () => (props.args.surface === "light" ? SURFACES.light : SURFACES.dark)
|
|
587
|
+
const names = () => [props.args.name || NAMES[0], ...NAMES.slice(1, 6)]
|
|
588
|
+
const starred = readStars()
|
|
589
|
+
|
|
590
|
+
const columns = createMemo(() => {
|
|
591
|
+
const styles = filteredStyles(props.args, starred)
|
|
592
|
+
|
|
593
|
+
const third = Math.ceil(styles.length / 3)
|
|
594
|
+
|
|
595
|
+
return Array.from({ length: third ? Math.ceil(styles.length / third) : 0 }, (_, i) =>
|
|
596
|
+
styles.slice(i * third, (i + 1) * third),
|
|
597
|
+
)
|
|
598
|
+
})
|
|
599
|
+
|
|
600
|
+
return (
|
|
601
|
+
<div
|
|
602
|
+
data-slot="contact-sheet"
|
|
603
|
+
style={{
|
|
604
|
+
display: "inline-flex",
|
|
605
|
+
gap: "48px",
|
|
606
|
+
padding: "24px",
|
|
607
|
+
background: surface().background,
|
|
608
|
+
color: surface().text,
|
|
609
|
+
"font-size": "12px",
|
|
610
|
+
"line-height": "16px",
|
|
611
|
+
}}
|
|
612
|
+
>
|
|
613
|
+
<For each={columns()} fallback="No styles match.">
|
|
614
|
+
{(column) => (
|
|
615
|
+
<div style={{ display: "flex", "flex-direction": "column", gap: "10px" }}>
|
|
616
|
+
<For each={column}>
|
|
617
|
+
{(style) => (
|
|
618
|
+
<div style={{ display: "flex", "align-items": "flex-end", gap: "20px" }}>
|
|
619
|
+
<div style={{ width: "88px", "align-self": "center", "white-space": "nowrap" }}>{style.name}</div>
|
|
620
|
+
<For each={SIZES}>
|
|
621
|
+
{(size) => (
|
|
622
|
+
<div style={{ display: "flex", gap: "8px", "align-items": "flex-end" }}>
|
|
623
|
+
<For each={names()}>
|
|
624
|
+
{(name) => <Icon style={style} name={name} size={size} animate={props.args.animate} />}
|
|
625
|
+
</For>
|
|
626
|
+
</div>
|
|
627
|
+
)}
|
|
628
|
+
</For>
|
|
629
|
+
</div>
|
|
630
|
+
)}
|
|
631
|
+
</For>
|
|
632
|
+
</div>
|
|
633
|
+
)}
|
|
634
|
+
</For>
|
|
635
|
+
</div>
|
|
636
|
+
)
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
const reset = {
|
|
640
|
+
background: "none",
|
|
641
|
+
border: "0",
|
|
642
|
+
margin: "0",
|
|
643
|
+
color: "inherit",
|
|
644
|
+
font: "inherit",
|
|
645
|
+
cursor: "pointer",
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
function Tile(props: {
|
|
649
|
+
style: ProjectIconStyle
|
|
650
|
+
name: string
|
|
651
|
+
size: number
|
|
652
|
+
animate: boolean
|
|
653
|
+
selected: boolean
|
|
654
|
+
ring: string
|
|
655
|
+
onSelect: () => void
|
|
656
|
+
}) {
|
|
657
|
+
return (
|
|
658
|
+
<button
|
|
659
|
+
type="button"
|
|
660
|
+
title={`${props.style.name} · ${props.name}`}
|
|
661
|
+
onClick={props.onSelect}
|
|
662
|
+
style={{
|
|
663
|
+
...reset,
|
|
664
|
+
padding: "0",
|
|
665
|
+
display: "block",
|
|
666
|
+
"border-radius": `${Math.max(4, props.size * 0.22 + 2)}px`,
|
|
667
|
+
outline: props.selected ? `1.5px solid ${props.ring}` : "none",
|
|
668
|
+
"outline-offset": "2px",
|
|
669
|
+
}}
|
|
670
|
+
>
|
|
671
|
+
<Icon style={props.style} name={props.name} size={props.size} animate={props.animate} />
|
|
672
|
+
</button>
|
|
673
|
+
)
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
// The avatar's own markup and styles, so each style is clipped exactly as ProjectAvatar clips the mesh.
|
|
677
|
+
function Icon(props: { style: ProjectIconStyle; name: string; size: number; animate: boolean }) {
|
|
678
|
+
let canvas!: HTMLCanvasElement
|
|
679
|
+
|
|
680
|
+
onMount(() => {
|
|
681
|
+
const icon = () => props.style.generate(props.name)
|
|
682
|
+
let frame = 0
|
|
683
|
+
let time = 0
|
|
684
|
+
let hovering = false
|
|
685
|
+
let last = 0
|
|
686
|
+
|
|
687
|
+
const paint = (seconds: number) => {
|
|
688
|
+
const px = Math.max(1, Math.round(props.size * (window.devicePixelRatio || 1)))
|
|
689
|
+
|
|
690
|
+
if (canvas.width !== px) canvas.width = canvas.height = px
|
|
691
|
+
const ctx = canvas.getContext("2d")
|
|
692
|
+
|
|
693
|
+
if (!ctx) return
|
|
694
|
+
|
|
695
|
+
if (seconds > 0) return props.style.draw(ctx, px, icon(), seconds)
|
|
696
|
+
ctx.clearRect(0, 0, px, px)
|
|
697
|
+
ctx.drawImage(still(props.style, props.name, px), 0, 0)
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
// As in the app's avatars: play while hovered, then ease back to the static frame and stop.
|
|
701
|
+
const tick = (now: number) => {
|
|
702
|
+
const seconds = Math.min((now - last) / 1000, 0.1)
|
|
703
|
+
last = now
|
|
704
|
+
time = hovering ? time + seconds : time * Math.pow(0.002, seconds)
|
|
705
|
+
|
|
706
|
+
if (!hovering && time < 0.01) {
|
|
707
|
+
time = 0
|
|
708
|
+
frame = 0
|
|
709
|
+
paint(0)
|
|
710
|
+
|
|
711
|
+
return
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
paint(time)
|
|
715
|
+
frame = requestAnimationFrame(tick)
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
const enter = () => {
|
|
719
|
+
if (!props.animate || !props.style.animated || matchMedia("(prefers-reduced-motion: reduce)").matches) return
|
|
720
|
+
hovering = true
|
|
721
|
+
|
|
722
|
+
if (frame) return
|
|
723
|
+
last = performance.now()
|
|
724
|
+
frame = requestAnimationFrame(tick)
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
const leave = () => (hovering = false)
|
|
728
|
+
const target = canvas.closest("button") ?? canvas
|
|
729
|
+
|
|
730
|
+
target.addEventListener("pointerenter", enter)
|
|
731
|
+
target.addEventListener("pointerleave", leave)
|
|
732
|
+
onCleanup(() => {
|
|
733
|
+
cancelAnimationFrame(frame)
|
|
734
|
+
target.removeEventListener("pointerenter", enter)
|
|
735
|
+
target.removeEventListener("pointerleave", leave)
|
|
736
|
+
})
|
|
737
|
+
createEffect(() => {
|
|
738
|
+
props.style
|
|
739
|
+
props.name
|
|
740
|
+
props.size
|
|
741
|
+
|
|
742
|
+
if (!frame) paint(0)
|
|
743
|
+
})
|
|
744
|
+
})
|
|
745
|
+
|
|
746
|
+
return (
|
|
747
|
+
<div data-component="project-avatar-v2" style={{ width: `${props.size}px`, height: `${props.size}px` }}>
|
|
748
|
+
<div data-slot="project-avatar-surface" data-generated="">
|
|
749
|
+
<canvas ref={canvas} data-slot="project-avatar-generated" aria-hidden="true" />
|
|
750
|
+
</div>
|
|
751
|
+
</div>
|
|
752
|
+
)
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
const stills = new Map<string, HTMLCanvasElement>()
|
|
756
|
+
|
|
757
|
+
function still(style: ProjectIconStyle, name: string, px: number) {
|
|
758
|
+
const key = `${style.id}|${name}|${px}`
|
|
759
|
+
const cached = stills.get(key)
|
|
760
|
+
|
|
761
|
+
if (cached) return cached
|
|
762
|
+
|
|
763
|
+
if (stills.size > 4096) stills.clear()
|
|
764
|
+
const canvas = document.createElement("canvas")
|
|
765
|
+
canvas.width = canvas.height = px
|
|
766
|
+
const ctx = canvas.getContext("2d")
|
|
767
|
+
|
|
768
|
+
if (ctx) style.draw(ctx, px, style.generate(name), 0)
|
|
769
|
+
stills.set(key, canvas)
|
|
770
|
+
|
|
771
|
+
return canvas
|
|
772
|
+
}
|