Skip to content

Commit 3edb73a

Browse files
committed
types
1 parent 9344d3b commit 3edb73a

3 files changed

Lines changed: 65 additions & 2 deletions

File tree

apps/web/components/gradient-editor.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const gradientTypes = [
7373
{ label: "Nano", value: "nano" },
7474
{ label: "Mini", value: "mini" },
7575
{ label: "Pink", value: "pink" },
76+
{ label: "Conic", value: "conic" },
7677
];
7778

7879
export default function GradientEditor() {
@@ -98,6 +99,7 @@ export default function GradientEditor() {
9899
gradientType: "default",
99100
gradientWidth: 300,
100101
gradientHeight: 200,
102+
blurAmount: 0,
101103
});
102104

103105
const {
@@ -119,6 +121,7 @@ export default function GradientEditor() {
119121
gradientWidth,
120122
gradientHeight,
121123
gradientType,
124+
blurAmount,
122125
} = state;
123126

124127
// Load from localStorage on mount
@@ -178,7 +181,15 @@ export default function GradientEditor() {
178181
className="w-full px-2 border rounded-md"
179182
value={gradientType}
180183
name="gradientType"
181-
onChange={(e) => setStateValue(e.target.name, e.target.value)}
184+
onChange={(e) => {
185+
if (e.target.value === "conic") {
186+
setStateValue("blurAmount", 40);
187+
} else {
188+
setStateValue("blurAmount", 0);
189+
}
190+
setStateValue(e.target.name, e.target.value);
191+
192+
}}
182193
>
183194
{gradientTypes.map((type) => (
184195
<option key={type.value} value={type.value}>
@@ -187,6 +198,20 @@ export default function GradientEditor() {
187198
))}
188199
</select>
189200

201+
{/* Blur Amount */}
202+
<p>Blur Amount: {blurAmount}px</p>
203+
<input
204+
type="range"
205+
min="0"
206+
name="blurAmount"
207+
max="100"
208+
value={blurAmount || 0}
209+
onChange={(e) =>
210+
setStateValue(e.target.name, Number(e.target.value))
211+
}
212+
className="w-full"
213+
/>
214+
190215
<p>Title:</p>
191216
<input
192217
className="w-full px-2 border rounded-md"
@@ -409,6 +434,7 @@ export default function GradientEditor() {
409434
gradientWidth={gradientWidth}
410435
gradientHeight={gradientHeight}
411436
rounded={rounded}
437+
blurAmount={blurAmount}
412438
scale={scale}
413439
gradientType={gradientType}
414440
styles={{

apps/web/public/640.webp

3.88 KB
Loading

packages/ui/src/gradient-preview/gradient-preview.tsx

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ interface GradientPreviewProps {
1919
gradientWidth?: number;
2020
gradientHeight?: number;
2121
gradientType?: string;
22+
blurAmount?: number;
2223
}
2324

2425
export const GradientPreview: React.FC<GradientPreviewProps> = ({
@@ -34,6 +35,7 @@ export const GradientPreview: React.FC<GradientPreviewProps> = ({
3435
gradientWidth,
3536
gradientHeight,
3637
gradientType = "default",
38+
blurAmount = 0,
3739
}) => {
3840
return (
3941
<CardContainer
@@ -45,7 +47,10 @@ export const GradientPreview: React.FC<GradientPreviewProps> = ({
4547
lightMode={true}
4648
scale={scale}
4749
>
48-
{title && (
50+
<div style={{
51+
position: "relative",
52+
}}>
53+
{title && (
4954
<div
5055
className="roboto-flex mb-4 text-center font-bold"
5156
style={{
@@ -65,6 +70,7 @@ export const GradientPreview: React.FC<GradientPreviewProps> = ({
6570
width: "100%",
6671
height: gradientHeight ? gradientHeight : 200,
6772
marginBottom: "16px",
73+
filter: `blur(${blurAmount}px)`,
6874
}}
6975
>
7076
<PastelGradientCanvas
@@ -92,6 +98,7 @@ export const GradientPreview: React.FC<GradientPreviewProps> = ({
9298
width: gradientWidth ? gradientWidth + "px" : "100%",
9399
height: gradientHeight ? gradientHeight + "px" : "100%",
94100
borderRadius: rounded ? "15px" : "0",
101+
filter: `blur(${blurAmount}px)`,
95102
}}
96103
src="/gpt-5-nano-1.jpg"
97104
width={100}
@@ -117,6 +124,7 @@ export const GradientPreview: React.FC<GradientPreviewProps> = ({
117124
width: gradientWidth ? gradientWidth + "px" : "100%",
118125
height: gradientHeight ? gradientHeight + "px" : "100%",
119126
borderRadius: rounded ? "15px" : "0",
127+
filter: `blur(${blurAmount}px)`,
120128
}}
121129
src="/gpt-5-mini.jpg"
122130
width={100}
@@ -142,6 +150,7 @@ export const GradientPreview: React.FC<GradientPreviewProps> = ({
142150
width: gradientWidth ? gradientWidth + "px" : "100%",
143151
height: gradientHeight ? gradientHeight + "px" : "100%",
144152
borderRadius: rounded ? "15px" : "0",
153+
filter: `blur(${blurAmount}px)`,
145154
}}
146155
src="/gpt-5.jpg"
147156
width={100}
@@ -151,6 +160,33 @@ export const GradientPreview: React.FC<GradientPreviewProps> = ({
151160
</div>)}
152161

153162

163+
{gradientType === "conic" && (
164+
<div
165+
style={{
166+
display: "absolute",
167+
inset: 0,
168+
justifyContent: "center",
169+
alignItems: "center",
170+
width: "100%",
171+
height: gradientHeight ? gradientHeight : 200,
172+
marginBottom: "16px",
173+
}}
174+
>
175+
<img
176+
style={{
177+
objectFit: "cover",
178+
// mouse event none
179+
pointerEvents: "none",
180+
display: "inline-block",
181+
width: gradientWidth ? gradientWidth + "px" : "100%",
182+
height: gradientHeight ? gradientHeight + "px" : "100%",
183+
borderRadius: rounded ? "15px" : "0",
184+
filter: `blur(${blurAmount}px)`,
185+
}}
186+
src="/640.webp"
187+
alt="Background"
188+
/>
189+
</div>)}
154190

155191

156192
<div
@@ -171,6 +207,7 @@ export const GradientPreview: React.FC<GradientPreviewProps> = ({
171207
</div>
172208
)}
173209
</div>
210+
</div>
174211
</CardContainer>
175212
);
176213
};

0 commit comments

Comments
 (0)