Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions configurator/src/components/inputs/TokenRow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,25 @@

function guessType(t: SlashedToken): "color" | "font" | "number" | "text" {
const n = t.name;
if (n.includes("color") || n.includes("source") || n.includes("-bg") || n.includes("-border")) return "color";
if (n.includes("font") || n.includes("family")) return "font";
const syntax = t.syntax?.toLowerCase() ?? "";
if (syntax.includes("number") || syntax.includes("length") || syntax.includes("integer")) return "number";

// Prefer the generated syntax metadata — it is authoritative and avoids the
// name-substring guessing that used to misfire (border shorthands / length
// scales / background shorthands wrongly getting a color picker).
if (syntax.includes("<color>")) return "color";
if (syntax.includes("number") || syntax.includes("length") || syntax.includes("integer") || syntax.includes("percentage")) return "number";

// Name-based fallback for tokens without a registered syntax. Deliberately
// narrow so compound / shorthand tokens are never treated as colors:
// • border shorthands (--sf-border, --sf-icon-box-border) and border-width
// length scales (--sf-border-width-*) must NOT get a color picker;
// • background shorthand parts (--sf-surface-bg-*, --sf-bg-layer-*) likewise.
// Genuine border/bg colors either live under the --sf-color-* namespace
// (matched by "color") or are single-value bg tokens ending in "-bg"
// (e.g. --sf-card-bg, --sf-icon-box-bg).
if (n.includes("color")) return "color";
if (n.endsWith("-bg")) return "color";
if (n.includes("font") || n.includes("family")) return "font";
return "text";
}

Expand Down
16 changes: 7 additions & 9 deletions configurator/src/components/panels/MiscPanel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import SliderRow from '../inputs/SliderRow.svelte';
import ColorInput from '../inputs/ColorInput.svelte';
import Section from '../inputs/Section.svelte';
import { SIZE_SCALE } from '../../lib/variableScales';

let { overrides, onSet, onReset, onBulkChange }: {
overrides: Record<string, string>;
Expand All @@ -27,7 +26,7 @@
{ label: "XS", token: "--sf-size-xs", default: 1.5 },
{ label: "S", token: "--sf-size-s", default: 2 },
{ label: "M", token: "--sf-size-m", default: 2.5 },
{ label: "L", token: "--sf-size-l", default: 2.75 },
{ label: "L", token: "--sf-size-l", default: 3 },
{ label: "XL", token: "--sf-size-xl", default: 3.5 },
];

Expand Down Expand Up @@ -64,12 +63,11 @@
<Section title="Touch target" bind:open={showTouchTarget}>
<SliderRow
label="Min touch size" value={touchTarget} min={32} max={64} step={1} unit="px"
help="--sf-touch-target — minimum tappable area for interactive elements (WCAG 2.5.5)"
help="--sf-touch-target — minimum tappable area for interactive elements (WCAG 2.5.5). Independent literal (2.75rem / 44px) — deliberately NOT an alias of the --sf-size-* scale, so retuning sizes never drops below the accessibility floor."
overridden={"--sf-touch-target" in overrides}
onChange={(v) => onSet("--sf-touch-target", `${v}px`)}
onReset={() => onReset("--sf-touch-target")}
Comment on lines 64 to 69

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Raw touch values are rewritten

When a persisted or imported --sf-touch-target override uses 2.75rem or var(--sf-size-l), this px-only control displays an out-of-range or fallback value and replaces the original expression with a clamped px literal when edited.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d33606b. Restored the raw-CSS escape hatch (currentRaw/onRawSet) with an honest independent literal default (2.75rem) instead of the misleading var(--sf-size-l) alias, and no scale picker. Persisted var()/calc()/clamp() overrides now surface as editable raw text via the </> toggle / expr auto-detect rather than being misread as an out-of-range px value and clobbered to px on edit. This still satisfies #685 (no --sf-size-* alias suggestion).

rawDefault="var(--sf-size-l)"
variableOptions={SIZE_SCALE}
rawDefault="2.75rem"
currentRaw={overrides["--sf-touch-target"]}
onRawSet={(v) => onSet("--sf-touch-target", v)}
/>
Expand All @@ -88,8 +86,8 @@
<!-- Z-INDEX -->
<Section title="Z-index layers" bind:open={showZIndex}>
<SliderRow
label="Base offset" value={zBaseOffset} min={0} max={1000} step={10}
help="--sf-z-base — added to all z-index tokens to avoid conflicts with existing stacking contexts"
label="Base" value={zBaseOffset} min={0} max={1000} step={10}
help="--sf-z-base — base local-stacking rung (default 0), consumed by the .sf-z-base utility. It is NOT added to the other rungs: every ladder step below is an independent literal."
overridden={"--sf-z-base" in overrides}
onChange={(v) => onSet("--sf-z-base", String(v))}
onReset={() => onReset("--sf-z-base")}
Comment on lines 88 to 93

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Narrowed range corrupts existing values

When a persisted theme contains a --sf-z-base value above 10, including values produced by the former control, the narrowed range renders it beyond the track and clamps it to 10 on the next interaction, overwriting the theme.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d33606b. Reverted the slider range back to the original 0–1000 (step 10), so themes with a --sf-z-base above 10 are no longer rendered off-track and clamped/overwritten on interaction. The range narrowing was incidental to my change; the actual #686 fix (relabel + accurate help clarifying that --sf-z-base is not added to the other rungs) is unchanged.

Expand Down Expand Up @@ -285,7 +283,7 @@
<!-- ICON SIZES -->
<Section title="Icon sizes" bind:open={showIconSizes}>
<p class="text-[10px] text-slate-400 dark:text-slate-600 leading-relaxed">
Icon scale tokens used by <span class="font-mono text-slate-600 dark:text-slate-400">.sf-icon-*</span> utilities. Values are in <span class="font-mono text-slate-600 dark:text-slate-400">em</span> units relative to surrounding text.
Icon scale tokens used by <span class="font-mono text-slate-600 dark:text-slate-400">.sf-icon--*</span> utilities. Values are in <span class="font-mono text-slate-600 dark:text-slate-400">em</span> units relative to surrounding text.
</p>
<div class="space-y-1.5">
{#each [
Expand All @@ -306,7 +304,7 @@
</div>
<SliderRow
label="Box padding" value={parseNum(overrides["--sf-icon-box-pad"]?.replace("em",""), 0.5)} min={0} max={2} step={0.125} unit="em"
help="--sf-icon-box-pad — padding around icon when using .sf-icon-box"
help="--sf-icon-box-pad — padding around icon when using .sf-icon--boxed"
overridden={"--sf-icon-box-pad" in overrides}
onChange={(v) => onSet("--sf-icon-box-pad", `${v}em`)}
onReset={() => onReset("--sf-icon-box-pad")}
Expand Down
2 changes: 1 addition & 1 deletion optional/legacy.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SLASHED — optional/legacy.css
@layer slashed.legacy
Fallbacks for older browser gaps: dynamic viewport units, focus-visible, scrollbar gutter, has(), dvh.
Fallbacks for older browser gaps: dynamic viewport units, focus-visible, scrollbar gutter.
Load only when legacy support is needed. */

@layer slashed.legacy {
Expand Down