Skip to content

Commit

Permalink
Rebuild demo
Browse files Browse the repository at this point in the history
  • Loading branch information
exogen committed Oct 11, 2024
1 parent c36911e commit 815f151
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 12 deletions.
2 changes: 2 additions & 0 deletions demo/app/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export function ColorConvert() {
<div className={styles.ColorConvert}>
<div className={styles.ColorSelect}>
<ColorSlider
label="Select grayscale color"
scaleImage={`${basePath}/grayscale.png`}
value={value}
onChange={setValue}
Expand Down Expand Up @@ -54,6 +55,7 @@ export function ColorConvert() {
</div>
<div className={styles.ColorSelect}>
<ColorSlider
label="Select Turbo color"
scaleImage={`${basePath}/turbo.png`}
value={value}
onChange={setValue}
Expand Down
4 changes: 2 additions & 2 deletions demo/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ const DemoPage = () => {
Snap arbitrary colors to the indexed Turbo palette. This can yield
surprising results with much of the sRGB color space; it’s mostly
useful for interpreting visual&shy;izations exported with an
approx&shy;imation of Turbo or a lossy format like JPEG, where the
colors won’t be in the Turbo lookup table.
approx&shy;imation of Turbo or a lossy format like JPEG, where not
every pixel will be in the Turbo lookup table.
</p>
<p className={styles.Description}>
The nearest color is determined by simple Euclidian distance using a
Expand Down
8 changes: 6 additions & 2 deletions demo/src/ColorSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ const toGradientStops = (colorStops: Color[]) => {
};

export default function ColorSlider({
label = "Select color",
className,
colorStops,
scaleImage,
value: valueFromProps,
onChange,
}: {
label?: string;
className?: string;
colorStops?: Color[];
scaleImage?: string;
Expand All @@ -35,18 +37,20 @@ export default function ColorSlider({
return {
"--color-gradient": `url("${scaleImage}")`,
} as React.CSSProperties;
} else {
} else if (colorStops) {
const colorString = toGradientStops(colorStops).join(", ");
return {
"--color-gradient": `linear-gradient(to right, ${colorString})`,
} as React.CSSProperties;
} else {
return {};
}
}, [colorStops, scaleImage]);

return (
<div className={`${styles.Container} ${className ?? ""}`}>
<Range
label="Select your value"
label={label}
step={1}
min={0}
max={255}
Expand Down
2 changes: 1 addition & 1 deletion docs/404.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/404/index.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/_next/static/chunks/app/page-a093ff4dc3a3e529.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 815f151

Please sign in to comment.