Skip to content

Commit ce53b64

Browse files
committed
refactor: enforce consistency and code quality (#198)
* refactor: replace interfaces with types for props * refactor: reorganize and rename context providers * refactor: rename authStore to auth-store for consistent kebab-case naming
1 parent 1dca564 commit ce53b64

72 files changed

Lines changed: 220 additions & 211 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/assets/custom/icon-dir.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { type SVGProps } from 'react'
22
import { cn } from '@/lib/utils'
3-
import { type Direction } from '@/context/direction-context'
3+
import { type Direction } from '@/context/direction-provider'
44

5-
interface Props extends SVGProps<SVGSVGElement> {
5+
type IconDirProps = SVGProps<SVGSVGElement> & {
66
dir: Direction
77
}
88

9-
export function IconDir({ dir, className, ...props }: Props) {
9+
export function IconDir({ dir, className, ...props }: IconDirProps) {
1010
return (
1111
<svg
1212
data-name={`icon-dir-${dir}`}

src/components/bulk-actions-toolbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
TooltipTrigger,
1212
} from '@/components/ui/tooltip'
1313

14-
interface BulkActionsToolbarProps<TData> {
14+
type BulkActionsToolbarProps<TData> = {
1515
table: Table<TData>
1616
entityName: string
1717
children: React.ReactNode

src/components/command-menu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react'
22
import { useNavigate } from '@tanstack/react-router'
33
import { ArrowRight, ChevronRight, Laptop, Moon, Sun } from 'lucide-react'
4-
import { useSearch } from '@/context/search-context'
5-
import { useTheme } from '@/context/theme-context'
4+
import { useSearch } from '@/context/search-provider'
5+
import { useTheme } from '@/context/theme-provider'
66
import {
77
CommandDialog,
88
CommandEmpty,

src/components/config-drawer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import { IconThemeDark } from '@/assets/custom/icon-theme-dark'
1212
import { IconThemeLight } from '@/assets/custom/icon-theme-light'
1313
import { IconThemeSystem } from '@/assets/custom/icon-theme-system'
1414
import { cn } from '@/lib/utils'
15-
import { useDirection } from '@/context/direction-context'
16-
import { type Collapsible, useLayout } from '@/context/layout-context'
17-
import { useTheme } from '@/context/theme-context'
15+
import { useDirection } from '@/context/direction-provider'
16+
import { type Collapsible, useLayout } from '@/context/layout-provider'
17+
import { useTheme } from '@/context/theme-provider'
1818
import { Button } from '@/components/ui/button'
1919
import {
2020
Sheet,

src/components/confirm-dialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
} from '@/components/ui/alert-dialog'
1111
import { Button } from '@/components/ui/button'
1212

13-
interface ConfirmDialogProps {
13+
type ConfirmDialogProps = {
1414
open: boolean
1515
onOpenChange: (open: boolean) => void
1616
title: React.ReactNode

src/components/date-picker.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
PopoverTrigger,
99
} from '@/components/ui/popover'
1010

11-
interface Props {
11+
type DatePickerProps = {
1212
selected: Date | undefined
1313
onSelect: (date: Date | undefined) => void
1414
placeholder?: string
@@ -18,7 +18,7 @@ export function DatePicker({
1818
selected,
1919
onSelect,
2020
placeholder = 'Pick a date',
21-
}: Props) {
21+
}: DatePickerProps) {
2222
return (
2323
<Popover>
2424
<PopoverTrigger asChild>

src/components/layout/app-sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useLayout } from '@/context/layout-context'
1+
import { useLayout } from '@/context/layout-provider'
22
import { Sidebar } from '@/components/ui/sidebar'
33

44
export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {

src/components/layout/authenticated-layout.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Outlet } from '@tanstack/react-router'
22
import { getCookie } from '@/lib/cookies'
33
import { cn } from '@/lib/utils'
4-
import { LayoutProvider } from '@/context/layout-context'
5-
import { SearchProvider } from '@/context/search-context'
4+
import { LayoutProvider } from '@/context/layout-provider'
5+
import { SearchProvider } from '@/context/search-provider'
66
import {
77
SidebarContent,
88
SidebarFooter,
@@ -18,11 +18,11 @@ import { NavGroup } from './nav-group'
1818
import { NavUser } from './nav-user'
1919
import { TeamSwitcher } from './team-switcher'
2020

21-
interface Props {
21+
type AuthenticatedLayoutProps = {
2222
children?: React.ReactNode
2323
}
2424

25-
export function AuthenticatedLayout({ children }: Props) {
25+
export function AuthenticatedLayout({ children }: AuthenticatedLayoutProps) {
2626
const defaultOpen = getCookie('sidebar_state') !== 'false'
2727
return (
2828
<SearchProvider>

src/components/layout/header.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import React from 'react'
1+
import { useEffect, useState } from 'react'
22
import { cn } from '@/lib/utils'
33
import { Separator } from '@/components/ui/separator'
44
import { SidebarTrigger } from '@/components/ui/sidebar'
55

6-
interface HeaderProps extends React.HTMLAttributes<HTMLElement> {
6+
type HeaderProps = React.HTMLAttributes<HTMLElement> & {
77
fixed?: boolean
88
ref?: React.Ref<HTMLElement>
99
}
1010

1111
export function Header({ className, fixed, children, ...props }: HeaderProps) {
12-
const [offset, setOffset] = React.useState(0)
12+
const [offset, setOffset] = useState(0)
1313

14-
React.useEffect(() => {
14+
useEffect(() => {
1515
const onScroll = () => {
1616
setOffset(document.body.scrollTop || document.documentElement.scrollTop)
1717
}

src/components/layout/main.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import React from 'react'
21
import { cn } from '@/lib/utils'
32

4-
interface MainProps extends React.HTMLAttributes<HTMLElement> {
3+
type MainProps = React.HTMLAttributes<HTMLElement> & {
54
fixed?: boolean
65
fluid?: boolean
76
ref?: React.Ref<HTMLElement>

0 commit comments

Comments
 (0)