Skip to content
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

experimental: add gradient controller to update color stops using ui #4159

Draft
wants to merge 28 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
12d8002
experimental: add gradient control for updating the color stops using ui
JayaKrishnaNamburu Sep 24, 2024
e9a0980
update stories to display the result
JayaKrishnaNamburu Sep 25, 2024
d5315fe
add comments for color-stop and hint behaviours
JayaKrishnaNamburu Sep 25, 2024
f62fdca
add interpolated color-stops when clicked in between the color stops
JayaKrishnaNamburu Sep 25, 2024
59d61cd
pass props when a thumb is selected on the radix slider
JayaKrishnaNamburu Sep 27, 2024
99bf5cd
Merge branch 'main' into add-gradient-control
JayaKrishnaNamburu Sep 27, 2024
aaebe2f
allow users to change the color of a color-stop
JayaKrishnaNamburu Sep 27, 2024
4076799
refactor and add comments for position calculation
JayaKrishnaNamburu Sep 28, 2024
c0e21cd
Merge branch 'main' into add-gradient-control
JayaKrishnaNamburu Sep 28, 2024
bd5958b
Merge branch 'main' into add-gradient-control
JayaKrishnaNamburu Oct 17, 2024
b3c6d7d
use slider instead of root from radix
JayaKrishnaNamburu Oct 17, 2024
6979a34
Merge branch 'main' into add-gradient-control
JayaKrishnaNamburu Nov 22, 2024
ab025c0
Merge branch 'main' into add-gradient-control
JayaKrishnaNamburu Dec 19, 2024
9a9d8cc
remove popover interaction for color stop change
JayaKrishnaNamburu Dec 20, 2024
598c902
Merge branch 'main' into add-gradient-control
JayaKrishnaNamburu Dec 20, 2024
4328303
update the slider import from @radix-ui/slider
JayaKrishnaNamburu Dec 20, 2024
4857c99
Merge branch 'main' into add-gradient-control
JayaKrishnaNamburu Dec 20, 2024
8caa73d
fix ts typechecks
JayaKrishnaNamburu Dec 20, 2024
42664ff
Merge branch 'main' into add-gradient-control
JayaKrishnaNamburu Dec 24, 2024
3dce8ff
Merge branch 'main' into add-gradient-control
JayaKrishnaNamburu Jan 2, 2025
f7f35c3
update @radix-ui/react-slider
JayaKrishnaNamburu Jan 2, 2025
2730ef7
add chevronbigiconup svg for color hints
JayaKrishnaNamburu Jan 3, 2025
5d07118
Merge branch 'main' into add-gradient-control
JayaKrishnaNamburu Jan 3, 2025
d1dd551
update icons, added filled chevron
kof Jan 3, 2025
8c6ffd9
use the right border color
kof Jan 3, 2025
b00e931
design change for handles
kof Jan 3, 2025
ca9043a
design changes
kof Jan 3, 2025
136f21c
remove experimental cursor
kof Jan 3, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import {
parseLinearGradient,
reconstructLinearGradient,
type ParsedGradient,
} from "@webstudio-is/css-data";
import { GradientControl } from "./gradient-control";
import { Flex, Text } from "@webstudio-is/design-system";
import { useState } from "react";

export default {
title: "Library/GradientControl",
};

export const GradientWithoutAngle = () => {
const gradientString = "linear-gradient(black 0%, white 100%)";
const [gradient, setGradient] = useState<string>(gradientString);

return (
<Flex direction="column" gap="4">
<GradientControl
gradient={parseLinearGradient(gradientString) as ParsedGradient}
onChange={(value) => {
setGradient(reconstructLinearGradient(value));
}}
onThumbSelected={() => {}}
/>
<Text>{gradient}</Text>
</Flex>
);
};

export const GradientWithAngleAndHints = () => {
const gradientString =
"linear-gradient(145deg, #ff00fa 0%, #00f497 34% 34%, #ffa800 56% 56%, #00eaff 100%)";
const [gradient, setGradient] = useState<string>(gradientString);

return (
<Flex direction="column" gap="4">
<GradientControl
gradient={parseLinearGradient(gradientString) as ParsedGradient}
onChange={(value) => {
setGradient(reconstructLinearGradient(value));
}}
onThumbSelected={() => {}}
/>
<Text>{gradient}</Text>
</Flex>
);
};

export const GradientWithSideOrCorner = () => {
const gradientString = "linear-gradient(to left top, blue 0%, red 100%)";

const [gradient, setGradient] = useState<string>(gradientString);

return (
<Flex direction="column" gap="4">
<GradientControl
gradient={parseLinearGradient(gradientString) as ParsedGradient}
onChange={(value) => {
setGradient(reconstructLinearGradient(value));
}}
onThumbSelected={() => {}}
/>
<Text>{gradient}</Text>
</Flex>
);
};
Loading
Loading