-
Notifications
You must be signed in to change notification settings - Fork 9
fix: default border token, dither-kit theme toggle + DialKit tweak panel #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
66bbb0b
fix: real default border color + dither-kit theme toggle
ripgrim 84b88fa
feat: swap the dither-kit tweak panel for DialKit
ripgrim 5ad4169
fix: DialKit closed on load, tweaks no longer replay the entrance
ripgrim f91cd7b
refactor: split the docs page + address review
ripgrim 3c16dc4
chore: format biome.json
ripgrim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,178 @@ | ||
| import type { | ||
| AreaVariant, | ||
| BloomInput, | ||
| ChartConfig, | ||
| } from "#/components/dither-kit" | ||
|
|
||
| /** Everything the dither-kit docs page renders from: install commands, demo | ||
| * data, the tweak model, and the live code snippets. */ | ||
|
|
||
| /** Where the registry lives once deployed. */ | ||
| export const HOST = "https://tripwire.sh" | ||
|
|
||
| /* ------------------------------------------------------- package manager */ | ||
|
|
||
| export const PMS = ["npm", "pnpm", "yarn", "bun"] as const | ||
| export type Pm = (typeof PMS)[number] | ||
|
|
||
| /** The runner each package manager uses for one-off CLIs. */ | ||
| const PM_RUNNER: Record<Pm, string> = { | ||
| npm: "npx", | ||
| pnpm: "pnpm dlx", | ||
| yarn: "yarn dlx", | ||
| bun: "bunx --bun", | ||
| } | ||
|
|
||
| export const addCmd = (pm: Pm, item: string): string => | ||
| `${PM_RUNNER[pm]} shadcn@latest add ${item}` | ||
|
|
||
| /* ------------------------------------------------------------------ data */ | ||
|
|
||
| const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug"] | ||
| export const series = MONTHS.map((month, i) => ({ | ||
| month, | ||
| desktop: Math.round(120 + 90 * Math.sin(i * 0.7) + i * 14), | ||
| mobile: Math.round(70 + 50 * Math.cos(i * 0.5) + i * 8), | ||
| })) | ||
| export const config: ChartConfig = { | ||
| desktop: { label: "Desktop", color: "blue" }, | ||
| mobile: { label: "Mobile", color: "purple" }, | ||
| } | ||
| export const pieData = [ | ||
| { browser: "chrome", visitors: 275 }, | ||
| { browser: "safari", visitors: 200 }, | ||
| { browser: "firefox", visitors: 187 }, | ||
| { browser: "edge", visitors: 120 }, | ||
| { browser: "other", visitors: 90 }, | ||
| ] | ||
| export const pieConfig: ChartConfig = { | ||
| chrome: { label: "Chrome", color: "blue" }, | ||
| safari: { label: "Safari", color: "green" }, | ||
| firefox: { label: "Firefox", color: "orange" }, | ||
| edge: { label: "Edge", color: "purple" }, | ||
| other: { label: "Other", color: "grey" }, | ||
| } | ||
| export const radarData = [ | ||
| { skill: "Speed", desktop: 186, mobile: 120 }, | ||
| { skill: "Power", desktop: 205, mobile: 98 }, | ||
| { skill: "Range", desktop: 137, mobile: 160 }, | ||
| { skill: "Defense", desktop: 173, mobile: 125 }, | ||
| { skill: "Magic", desktop: 160, mobile: 190 }, | ||
| { skill: "Luck", desktop: 144, mobile: 110 }, | ||
| ] | ||
|
|
||
| /* ---------------------------------------------------------- live tweaks */ | ||
|
|
||
| export const VARIANTS: AreaVariant[] = [ | ||
| "gradient", | ||
| "dotted", | ||
| "hatched", | ||
| "solid", | ||
| ] | ||
| export const BLOOM_PRESETS = ["off", "low", "high", "aura", "custom"] as const | ||
| export type BloomPreset = (typeof BLOOM_PRESETS)[number] | ||
|
|
||
| export type Tweaks = { | ||
| bloomPreset: BloomPreset | ||
| blur: number | ||
| brightness: number | ||
| opacity: number | ||
| saturate: number | ||
| primaryVariant: AreaVariant | ||
| secondaryVariant: AreaVariant | ||
| stacked: boolean | ||
| donutRadius: number // 0 = full pie | ||
| duration: number // entrance ms | ||
| } | ||
|
|
||
| export function bloomOf(t: Tweaks): BloomInput { | ||
| return t.bloomPreset === "custom" | ||
| ? { | ||
| blur: t.blur, | ||
| brightness: t.brightness, | ||
| opacity: t.opacity, | ||
| saturate: t.saturate, | ||
| } | ||
| : t.bloomPreset | ||
| } | ||
|
|
||
| /* ------------------------------------------------------------- snippets */ | ||
|
|
||
| /** How the current bloom reads in the code snippets. */ | ||
| function bloomAttr(t: Tweaks): string { | ||
| if (t.bloomPreset === "custom") { | ||
| return ` bloom={{ blur: ${t.blur}, brightness: ${t.brightness}, opacity: ${t.opacity}, saturate: ${t.saturate} }}` | ||
| } | ||
| return t.bloomPreset === "off" ? "" : ` bloom="${t.bloomPreset}"` | ||
| } | ||
|
|
||
| const stackAttr = (t: Tweaks): string => | ||
| t.stacked ? ' stackType="stacked"' : "" | ||
|
|
||
| /** Non-default entrance timing shows up in the copied code too. */ | ||
| const durationAttr = (t: Tweaks): string => | ||
| t.duration === 900 ? "" : ` animationDuration={${t.duration}}` | ||
|
|
||
| export const areaCode = (t: Tweaks): string => | ||
| `<AreaChart data={data} config={config}${stackAttr(t)}${bloomAttr(t)}${durationAttr(t)}> | ||
| <XAxis dataKey="month" /> | ||
| <YAxis /> | ||
| <Legend isClickable /> | ||
| <Tooltip labelKey="month" /> | ||
| <Area dataKey="desktop" variant="${t.primaryVariant}" /> | ||
| <Area dataKey="mobile" variant="${t.secondaryVariant}" /> | ||
| </AreaChart>` | ||
|
|
||
| export const barCode = (t: Tweaks): string => | ||
| `<BarChart data={data} config={config}${stackAttr(t)}${bloomAttr(t)}${durationAttr(t)}> | ||
| <XAxis dataKey="month" /> | ||
| <YAxis /> | ||
| <Legend isClickable /> | ||
| <Tooltip labelKey="month" /> | ||
| <Bar dataKey="desktop" variant="${t.primaryVariant}" /> | ||
| <Bar dataKey="mobile" variant="${t.secondaryVariant}" /> | ||
| </BarChart>` | ||
|
|
||
| export const lineCode = (t: Tweaks): string => | ||
| `// LineChart ships in the area-chart item (line = area + glow) | ||
| <LineChart data={data} config={config}${bloomAttr(t)}${durationAttr(t)}> | ||
| <XAxis dataKey="month" /> | ||
| <YAxis /> | ||
| <Legend isClickable /> | ||
| <Tooltip labelKey="month" /> | ||
| <Line dataKey="desktop" /> | ||
| <Line dataKey="mobile" strokeVariant="dashed" /> | ||
| </LineChart>` | ||
|
|
||
| export const pieCode = (t: Tweaks): string => | ||
| `<PieChart data={data} config={config} | ||
| dataKey="visitors" nameKey="browser"${ | ||
| t.donutRadius > 0 ? ` innerRadius={${t.donutRadius}}` : "" | ||
| }${bloomAttr(t)}${durationAttr(t)}> | ||
| <Legend isClickable align="center" /> | ||
| <Tooltip /> | ||
| <Pie variant="${t.primaryVariant}" /> | ||
| </PieChart>` | ||
|
|
||
| export const radarCode = (t: Tweaks): string => | ||
| `<RadarChart data={data} config={config} nameKey="skill"${bloomAttr(t)}${durationAttr(t)}> | ||
| <Legend isClickable align="center" /> | ||
| <Tooltip /> | ||
| <Radar dataKey="desktop" variant="${t.primaryVariant}" /> | ||
| <Radar dataKey="mobile" variant="${t.secondaryVariant}" /> | ||
| </RadarChart>` | ||
|
|
||
| export const PROPS: [string, string][] = [ | ||
| ["variant", '"gradient" | "dotted" | "hatched" | "solid"'], | ||
| [ | ||
| "bloom", | ||
| '"off" | "low" | "high" | "aura" | { blur, brightness, opacity, saturate }', | ||
| ], | ||
| ["stackType", '"default" | "stacked" | "percent"'], | ||
| ["colors", "green blue purple pink orange red grey"], | ||
| ["animate", "animationDuration + replayToken for entrance and replay"], | ||
| ["interactive", "false = decorative spark, no crosshair or tooltip"], | ||
| ] | ||
|
|
||
| export const SPARKLINE_CODE = `// tiny decorative spark — no axes, no tooltip | ||
| <Sparkline data={[3, 7, 5, 9, 8, 12]} color="green" bloom="aura" />` | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: bountydotnew/tripwire
Length of output: 7403
🏁 Script executed:
Repository: bountydotnew/tripwire
Length of output: 751
Keep the entrance duration default in one place.
apps/web/src/components/dither-kit-docs/content.tsandapps/web/src/routes/dither-kit.tsxboth hardcode900, so the generated snippet can drift from the live default. Extract a sharedDEFAULT_ENTRANCE_MSand use it in both spots.🤖 Prompt for AI Agents