Skip to content

Commit 2e4c37a

Browse files
authored
chore: release v0.1.2 (#7)
chore: release v0.1.2
2 parents 76a20d6 + aa1c8fb commit 2e4c37a

File tree

10 files changed

+581
-6
lines changed

10 files changed

+581
-6
lines changed

components/capitalise.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useCapitalise } from "@/hooks/use-capitalise";
1+
import { useCapitalise } from "@/lib/hooks/use-capitalise";
22

33
interface CapitaliseProps {
44
text: string

components/footer.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Capitalise } from "@/components/capitalise";
55
import { buttonVariants } from "@/components/ui/button";
66
import { getAProblemFirstQuote } from "@/data/problem-first-quote";
77
import type { SiteConfig } from "@/types";
8+
import { ThemeToggle } from "./theme-toggle";
89

910
interface FooterProps extends SiteConfig {}
1011

@@ -48,7 +49,10 @@ export function Footer({ title, author, links }: FooterProps) {
4849
</div>
4950
</div>
5051

51-
<p className="text-sm text-muted-foreground">© { (new Date).getFullYear() } { title }.</p>
52+
<div className="flex items-center justify-between">
53+
<p className="text-sm text-muted-foreground">© { (new Date).getFullYear() } { title }.</p>
54+
<ThemeToggle />
55+
</div>
5256
</div>
5357
</footer>
5458
)

components/icons.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import {
1212
Code2,
1313
Lightbulb,
1414
PencilRuler,
15-
ExternalLink
15+
ExternalLink,
16+
Sun,
17+
MoonStar,
18+
Laptop
1619
} from "lucide-react";
1720

1821
export type Icon = LucideIcon;
@@ -30,6 +33,9 @@ export const Icons = {
3033
lightbulb: Lightbulb,
3134
tool: PencilRuler,
3235
externalLink: ExternalLink,
36+
sun: Sun,
37+
moon: MoonStar,
38+
laptop: Laptop,
3339
logo: ({ ...props }: LucideProps) => (
3440
<svg width="24" height="24" viewBox="0 0 190 190" version="1.1"
3541
style={{shapeRendering:"geometricPrecision", textRendering:"geometricPrecision", fillRule:"evenodd", clipRule:"evenodd"}}

components/mobile-nav.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { cn } from "@/lib/utils";
55
import { MainNavItem } from "@/types";
66
import { Icons } from "@/components/icons";
77
import { siteConfig } from "@/config/site";
8-
import { useLockBody } from "@/hooks/use-lock-body";
8+
import { useLockBody } from "@/lib/hooks/use-lock-body";
99

1010
interface MobileNavProps {
1111
items: MainNavItem[],

components/theme-toggle.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"use client"
2+
3+
import * as React from "react"
4+
import { useTheme } from "next-themes"
5+
6+
import { Button } from "@/components/ui/button"
7+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"
8+
import { Icons } from "@/components/icons"
9+
10+
export function ThemeToggle() {
11+
const { setTheme } = useTheme()
12+
13+
return (
14+
<DropdownMenu>
15+
<DropdownMenuTrigger asChild>
16+
<Button variant="ghost" size="sm" className="h-8 w-8 px-0">
17+
<Icons.sun className="rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
18+
<Icons.moon className="absolute rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
19+
<span className="sr-only">Toggle theme</span>
20+
</Button>
21+
</DropdownMenuTrigger>
22+
<DropdownMenuContent align="end">
23+
<DropdownMenuItem onClick={() => setTheme("light")}>
24+
<Icons.sun className="mr-2 h-4 w-4" />
25+
<span>Light</span>
26+
</DropdownMenuItem>
27+
<DropdownMenuItem onClick={() => setTheme("dark")}>
28+
<Icons.moon className="mr-2 h-4 w-4" />
29+
<span>Dark</span>
30+
</DropdownMenuItem>
31+
<DropdownMenuItem onClick={() => setTheme("system")}>
32+
<Icons.laptop className="mr-2 h-4 w-4" />
33+
<span>System</span>
34+
</DropdownMenuItem>
35+
</DropdownMenuContent>
36+
</DropdownMenu>
37+
)
38+
}

components/ui/dropdown-menu.tsx

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
"use client"
2+
3+
import * as React from "react"
4+
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
5+
import { Check, ChevronRight, Circle } from "lucide-react"
6+
7+
import { cn } from "@/lib/utils"
8+
9+
const DropdownMenu = DropdownMenuPrimitive.Root
10+
11+
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger
12+
13+
const DropdownMenuGroup = DropdownMenuPrimitive.Group
14+
15+
const DropdownMenuPortal = DropdownMenuPrimitive.Portal
16+
17+
const DropdownMenuSub = DropdownMenuPrimitive.Sub
18+
19+
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup
20+
21+
const DropdownMenuSubTrigger = React.forwardRef<
22+
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
23+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
24+
inset?: boolean
25+
}
26+
>(({ className, inset, children, ...props }, ref) => (
27+
<DropdownMenuPrimitive.SubTrigger
28+
ref={ref}
29+
className={cn(
30+
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
31+
inset && "pl-8",
32+
className
33+
)}
34+
{...props}
35+
>
36+
{children}
37+
<ChevronRight className="ml-auto h-4 w-4" />
38+
</DropdownMenuPrimitive.SubTrigger>
39+
))
40+
DropdownMenuSubTrigger.displayName =
41+
DropdownMenuPrimitive.SubTrigger.displayName
42+
43+
const DropdownMenuSubContent = React.forwardRef<
44+
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
45+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
46+
>(({ className, ...props }, ref) => (
47+
<DropdownMenuPrimitive.SubContent
48+
ref={ref}
49+
className={cn(
50+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
51+
className
52+
)}
53+
{...props}
54+
/>
55+
))
56+
DropdownMenuSubContent.displayName =
57+
DropdownMenuPrimitive.SubContent.displayName
58+
59+
const DropdownMenuContent = React.forwardRef<
60+
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
61+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
62+
>(({ className, sideOffset = 4, ...props }, ref) => (
63+
<DropdownMenuPrimitive.Portal>
64+
<DropdownMenuPrimitive.Content
65+
ref={ref}
66+
sideOffset={sideOffset}
67+
className={cn(
68+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
69+
className
70+
)}
71+
{...props}
72+
/>
73+
</DropdownMenuPrimitive.Portal>
74+
))
75+
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName
76+
77+
const DropdownMenuItem = React.forwardRef<
78+
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
79+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
80+
inset?: boolean
81+
}
82+
>(({ className, inset, ...props }, ref) => (
83+
<DropdownMenuPrimitive.Item
84+
ref={ref}
85+
className={cn(
86+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
87+
inset && "pl-8",
88+
className
89+
)}
90+
{...props}
91+
/>
92+
))
93+
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName
94+
95+
const DropdownMenuCheckboxItem = React.forwardRef<
96+
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
97+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
98+
>(({ className, children, checked, ...props }, ref) => (
99+
<DropdownMenuPrimitive.CheckboxItem
100+
ref={ref}
101+
className={cn(
102+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
103+
className
104+
)}
105+
checked={checked}
106+
{...props}
107+
>
108+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
109+
<DropdownMenuPrimitive.ItemIndicator>
110+
<Check className="h-4 w-4" />
111+
</DropdownMenuPrimitive.ItemIndicator>
112+
</span>
113+
{children}
114+
</DropdownMenuPrimitive.CheckboxItem>
115+
))
116+
DropdownMenuCheckboxItem.displayName =
117+
DropdownMenuPrimitive.CheckboxItem.displayName
118+
119+
const DropdownMenuRadioItem = React.forwardRef<
120+
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
121+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
122+
>(({ className, children, ...props }, ref) => (
123+
<DropdownMenuPrimitive.RadioItem
124+
ref={ref}
125+
className={cn(
126+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
127+
className
128+
)}
129+
{...props}
130+
>
131+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
132+
<DropdownMenuPrimitive.ItemIndicator>
133+
<Circle className="h-2 w-2 fill-current" />
134+
</DropdownMenuPrimitive.ItemIndicator>
135+
</span>
136+
{children}
137+
</DropdownMenuPrimitive.RadioItem>
138+
))
139+
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName
140+
141+
const DropdownMenuLabel = React.forwardRef<
142+
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
143+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
144+
inset?: boolean
145+
}
146+
>(({ className, inset, ...props }, ref) => (
147+
<DropdownMenuPrimitive.Label
148+
ref={ref}
149+
className={cn(
150+
"px-2 py-1.5 text-sm font-semibold",
151+
inset && "pl-8",
152+
className
153+
)}
154+
{...props}
155+
/>
156+
))
157+
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName
158+
159+
const DropdownMenuSeparator = React.forwardRef<
160+
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
161+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
162+
>(({ className, ...props }, ref) => (
163+
<DropdownMenuPrimitive.Separator
164+
ref={ref}
165+
className={cn("-mx-1 my-1 h-px bg-muted", className)}
166+
{...props}
167+
/>
168+
))
169+
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName
170+
171+
const DropdownMenuShortcut = ({
172+
className,
173+
...props
174+
}: React.HTMLAttributes<HTMLSpanElement>) => {
175+
return (
176+
<span
177+
className={cn("ml-auto text-xs tracking-widest opacity-60", className)}
178+
{...props}
179+
/>
180+
)
181+
}
182+
DropdownMenuShortcut.displayName = "DropdownMenuShortcut"
183+
184+
export {
185+
DropdownMenu,
186+
DropdownMenuTrigger,
187+
DropdownMenuContent,
188+
DropdownMenuItem,
189+
DropdownMenuCheckboxItem,
190+
DropdownMenuRadioItem,
191+
DropdownMenuLabel,
192+
DropdownMenuSeparator,
193+
DropdownMenuShortcut,
194+
DropdownMenuGroup,
195+
DropdownMenuPortal,
196+
DropdownMenuSub,
197+
DropdownMenuSubContent,
198+
DropdownMenuSubTrigger,
199+
DropdownMenuRadioGroup,
200+
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)