Skip to content

Commit

Permalink
feat: added inner shadow
Browse files Browse the repository at this point in the history
  • Loading branch information
vwh committed Sep 25, 2024
1 parent 4b7f2f1 commit 8c136e8
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ const App: React.FC = () => {
const svgStyle = useMemo(
() => ({
position: "absolute" as const,
transform: `rotate(${svgSettings.rotation}deg) scale(${svgSettings.scale})`
transform: `rotate(${svgSettings.rotation}deg) scale(${svgSettings.scale})`,
filter: `drop-shadow(${svgSettings.innerShadowX}px ${svgSettings.innerShadowY}px ${svgSettings.innerShadowBlur}px ${svgSettings.innerShadowColor})`
}),
[svgSettings]
);
Expand Down
6 changes: 5 additions & 1 deletion src/components/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ const Navbar: React.FC = () => {
bgColor: randomIconColor(),
svgColor: randomIconColor(),
fillColor: randomIconColor(),
fillOpacity: Math.random() > 0.5 ? 1 : 0
fillOpacity: Math.random() > 0.5 ? 1 : 0,
innerShadowColor: "#0A0B0B",
innerShadowBlur: Math.floor(Math.random() * 4),
innerShadowX: 2,
innerShadowY: 3
});
};

Expand Down
33 changes: 33 additions & 0 deletions src/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,39 @@ function IconControlGroup() {
value={[svgSettings.iconBlur]}
onValueChange={(value) => updateSvgSetting("iconBlur", value[0])}
/>
<ControlGroup label="Inner Shadow">
<ControlColor
label="Inner Shadow Color"
value={svgSettings.innerShadowColor}
onChange={(color) => updateSvgSetting("innerShadowColor", color)}
/>
<ControlSlider
label="Inner Shadow Blur"
min={0}
max={20}
step={1}
value={[svgSettings.innerShadowBlur]}
onValueChange={(value) =>
updateSvgSetting("innerShadowBlur", value[0])
}
/>
<ControlSlider
label="Shadow Offset X"
min={-20}
max={20}
step={1}
value={[svgSettings.innerShadowX]}
onValueChange={(value) => updateSvgSetting("innerShadowX", value[0])}
/>
<ControlSlider
label="Inner Shadow Offset Y"
min={-20}
max={20}
step={1}
value={[svgSettings.innerShadowY]}
onValueChange={(value) => updateSvgSetting("innerShadowY", value[0])}
/>
</ControlGroup>
<ControlGroup label="Icon Dimensions">
<ControlSlider
label="Icon Size"
Expand Down
6 changes: 5 additions & 1 deletion src/store/useStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ export const defaultSvgSettings: SvgSettings = {
skewX: 0,
skewY: 0,
iconBlur: 0,
backgroundBlur: 0
backgroundBlur: 0,
innerShadowColor: "#0A0B0B",
innerShadowBlur: 3,
innerShadowX: 2,
innerShadowY: 3
};

const initialState: State = {
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ export type SvgSettings = {
skewY: number;
iconBlur: number;
backgroundBlur: number;
innerShadowColor: string;
innerShadowBlur: number;
innerShadowX: number;
innerShadowY: number;
};

0 comments on commit 8c136e8

Please sign in to comment.