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

Introduce a Reset button #12

Merged
20 changes: 19 additions & 1 deletion src/components/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import {
AspectRatio,
SUPPORTED_ASPECT_RATIOS,
Settings as SettingsType,
defaultSettings,
} from "@config/defaults";
import { RotateCcw } from "lucide-react";
import { Button } from "./ui/Button";
import { Input } from "./ui/Input";
import { Label } from "./ui/Label";
import { RadioGroup, RadioGroupItem } from "./ui/RadioGroup";
Expand All @@ -24,13 +27,28 @@ export const Settings = ({
setInsetPadding: (v: SettingsType["insetPadding"]) => void;
setIsDark: (v: SettingsType["isDark"]) => void;
}) => {
const handleReset = () => {
setAspectRatio(defaultSettings.aspectRatio);
setPadding(defaultSettings.padding);
setInsetPadding(2);
};

return (
<div className="space-y-6">
<div className="space-y-3">
<div className="flex items-center justify-between">
<h2 className="text-lg font-semibold leading-none text-slate-100 peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
Settings
</h2>
<Button variant="ghost" className="px-3" onClick={() => handleReset()}>
<RotateCcw className="h-4 w-4" />
</Button>
</div>
<div className="space-y-3">
<Label htmlFor="aspect-settings">Aspect Ratio</Label>
<RadioGroup
id="aspect-settings"
defaultValue="aspect-video"
value={settings.aspectRatio}
onValueChange={(value) => setAspectRatio(value as AspectRatio)}
>
<div className="flex items-center space-x-2">
Expand Down
5 changes: 3 additions & 2 deletions src/components/ui/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { VariantProps, cva } from "class-variance-authority";
import { cn } from "@utils/cn";
import { VariantProps, cva } from "class-variance-authority";
import * as React from "react";

const buttonVariants = cva(
"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-100/25 focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none ring-offset-slate-900",
Expand All @@ -10,6 +10,7 @@ const buttonVariants = cva(
variant: {
default: "bg-slate-100 text-slate-900 hover:bg-slate-200/90",
secondary: "bg-slate-800 text-slate-100 hover:bg-slate-700/90",
ghost: "bg-slate-800 text-slate-100 hover:bg-red-800/90",
},
size: {
default: "h-10 py-2 px-4",
Expand Down