Skip to content

Commit dba57a7

Browse files
committed
chore(refactor): extract notification wrapper
- organizing imports with star and removing `default`s
1 parent 8e0d4d4 commit dba57a7

File tree

15 files changed

+120
-115
lines changed

15 files changed

+120
-115
lines changed

apps/web/src/components/Avatar.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
import Image from "next/image"
22

3-
export default function Avatar({
4-
className,
5-
username,
6-
src,
7-
size = 36
8-
}: {
3+
interface AvatarProps {
94
className?: string
105
username?: string
116
src: string
127
size?: number
13-
}) {
8+
}
9+
10+
export function Avatar({ className, username, src, size = 36 }: AvatarProps) {
1411
return (
1512
<div
1613
data-avatar=""

apps/web/src/components/Containers/ItemIterator.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ export interface ItemIteratorType {
1414
matchStartingRoute?: boolean
1515
}
1616

17-
export default function ItemIterator({
18-
as: Component = "div",
19-
items,
20-
baseUrl = "/"
21-
}: {
17+
interface ItemIteratorProps {
2218
as?: keyof HTMLElementTagNameMap | React.ComponentType
2319
items: ItemIteratorType[]
2420
baseUrl?: string
25-
}) {
21+
}
22+
23+
export function ItemIterator({
24+
as: Component = "div",
25+
items,
26+
baseUrl = "/"
27+
}: ItemIteratorProps) {
2628
const path = usePathname()
2729

2830
return (

apps/web/src/components/Containers/TransitionWrapper.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Transition } from "@headlessui/react"
22

3-
export default function TransitionWrapper({
3+
export function TransitionWrapper({
44
children
55
}: {
66
children?: React.ReactNode
@@ -13,6 +13,7 @@ export default function TransitionWrapper({
1313
leave="transition duration-[200ms] ease"
1414
leaveTo="transform -translate-y-1 opacity-0"
1515
leaveFrom="transform translate-y-0 opacity-100"
16+
// @ts-expect-error: headlessui/react doesn't support this prop
1617
className="translate-x-0"
1718
>
1819
{children}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
export * from "./MarginClamp"
22
export * from "./GridResponsive"
33
export * from "./Field"
4+
export * from "./ItemIterator"
5+
export * from "./TransitionWrapper"

apps/web/src/components/Folders/FolderItem.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
LuFolderPlus as FolderPlus
1414
} from "react-icons/lu"
1515

16-
export default function FolderItem({
16+
export function FolderItem({
1717
children,
1818
name,
1919
open = false,
@@ -36,8 +36,8 @@ export default function FolderItem({
3636
const [isExpand, setIsExpand] = useState(expanded)
3737
const [expandedHeight, setExpandedHeight] = useState(0)
3838

39-
const collapsibleRef = useRef<React.ElementRef<"div">>(null)
40-
const toggleButtonRef = useRef<React.ElementRef<"button">>(null)
39+
const collapsibleRef = useRef<React.ComponentRef<"div">>(null)
40+
const toggleButtonRef = useRef<React.ComponentRef<"button">>(null)
4141

4242
const DynamicFolderIcon = children
4343
? !isExpand

apps/web/src/components/Folders/FolderShelf.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import {
77
LuPanelLeftClose as PanelLeftClose,
88
LuPanelLeftOpen as PanelLeftOpen
99
} from "react-icons/lu"
10-
import FolderItem from "./FolderItem"
10+
import { FolderItem } from "./FolderItem"
1111
import { useFolderViewContext } from "./FolderView"
1212

13-
export default function FolderShelf({
13+
export function FolderShelf({
1414
children,
1515
defaultName
1616
}: {

apps/web/src/components/Folders/FolderView.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,21 @@ import { createContext, useContext, useState } from "react"
55
const FolderViewContext = createContext<{
66
folderWidth: number
77
setFolderWidth: React.Dispatch<React.SetStateAction<number>>
8-
}>({
9-
folderWidth: 270,
10-
// biome-ignore lint/suspicious/noEmptyBlockStatements: <explanation>
11-
setFolderWidth: () => {}
12-
})
8+
} | null>(null)
139

1410
export function useFolderViewContext() {
1511
const ctx = useContext(FolderViewContext)
1612

1713
if (!ctx) {
1814
throw new Error(
19-
"The useFolderViewContext must be used within the FolderViewProvider, you dumbass"
15+
"The useFolderViewContext must be used within the FolderViewProvider"
2016
)
2117
}
2218

2319
return ctx
2420
}
2521

26-
export default function FolderView({
22+
export function FolderView({
2723
children
2824
}: {
2925
children?: React.ReactNode

apps/web/src/components/Folders/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"use client"
22

3-
import FolderItem from "./FolderItem"
4-
import FolderShelf from "./FolderShelf"
5-
import FolderView from "./FolderView"
3+
import { FolderItem } from "./FolderItem"
4+
import { FolderShelf } from "./FolderShelf"
5+
import { FolderView } from "./FolderView"
66

77
const FolderContents = ({ children }: { children: React.ReactNode }) => (
88
<div className="w-full">{children}</div>

apps/web/src/components/Forms/Checkbox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import cn from "@/utils/cn"
1+
import { cn } from "@/utils/cn"
22
import { kebabCase } from "lodash"
33

4-
export default function Checkbox({
4+
export function Checkbox({
55
inputName,
66
label,
77
checked,
Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Variants as NoteVariants, PartialRecord } from "@/types/utils"
1+
import type { PartialRecord } from "@/types/utils"
22
import { cn } from "@mav/shared/utils"
33
import type { IconType } from "react-icons"
44
import {
@@ -8,22 +8,20 @@ import {
88
LuXCircle
99
} from "react-icons/lu"
1010

11-
type NoteStatus = Extract<
12-
NoteVariants,
13-
"success" | "warning" | "error" | "info"
14-
>
11+
type NoteStatus = "success" | "warning" | "error" | "info"
1512

16-
export default function Note({
13+
interface NoteProps {
14+
type: NoteStatus
15+
heading?: string
16+
inline?: true
17+
}
18+
19+
export function Note({
1720
children,
1821
type,
1922
heading,
2023
inline
21-
}: {
22-
children?: React.ReactNode
23-
type: NoteStatus
24-
heading?: string
25-
inline?: boolean
26-
}) {
24+
}: React.PropsWithChildren<NoteProps>) {
2725
if (inline && heading) {
2826
throw new Error(
2927
"Can't use both `inline` and `heading` at the same time. Pass the message inside the element instead, otherwise, remove the `inline` prop."

0 commit comments

Comments
 (0)