Skip to content

Commit a266338

Browse files
LadyBluenoteslynnandtonicautofix-ci[bot]
authored
creating reusable components (#655)
* wip: Introduce FormInput and Badge components; refactor existing components to use them * feat: Replace status indicators with Badge component in submissions and users * feat: Replace input fields with FormInput component in moderation and feedback sections * feat: Replace button elements with Button component in various pages * feat: Add Button component with customizable styles and variants * Change ui.dev to Fireship (#654) * change ui.dev to Fireship * ci: apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * wip: Introduce FormInput and Badge components; refactor existing components to use them * Change ui.dev to Fireship (#654) * change ui.dev to Fireship * ci: apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * wip: Introduce FormInput and Badge components; refactor existing components to use them * Change ui.dev to Fireship (#654) * change ui.dev to Fireship * ci: apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * ci: apply automated fixes --------- Co-authored-by: Lynn Fisher <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 69a3065 commit a266338

Some content is hidden

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

73 files changed

+1101
-724
lines changed

src/components/AvatarCropModal.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as DialogPrimitive from '@radix-ui/react-dialog'
33
import Cropper from 'react-easy-crop'
44
import type { Area, Point } from 'react-easy-crop'
55
import { X } from 'lucide-react'
6+
import { Button } from '~/ui'
67

78
interface AvatarCropModalProps {
89
open: boolean
@@ -153,21 +154,20 @@ export function AvatarCropModal({
153154
</div>
154155

155156
<div className="mt-6 flex gap-3 justify-end">
156-
<button
157-
type="button"
157+
<Button
158+
variant="secondary"
159+
size="sm"
158160
onClick={() => onOpenChange(false)}
159-
className="px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-lg transition-colors"
160161
>
161162
Cancel
162-
</button>
163-
<button
164-
type="button"
163+
</Button>
164+
<Button
165+
size="sm"
165166
onClick={handleSave}
166167
disabled={isProcessing || !croppedAreaPixels}
167-
className="px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed rounded-lg transition-colors"
168168
>
169169
{isProcessing ? 'Processing...' : 'Save'}
170-
</button>
170+
</Button>
171171
</div>
172172
</DialogPrimitive.Content>
173173
</DialogPrimitive.Portal>

src/components/BottomCTA.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react'
22
import type { LinkProps } from '@tanstack/react-router'
33
import { Link } from '@tanstack/react-router'
4-
import { Button } from './Button'
4+
import { Button } from '~/ui'
55

66
type BottomCTAProps = {
77
linkProps: Omit<LinkProps, 'className' | 'children'>

src/components/Button.tsx

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/components/CookieConsent.tsx

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Link } from '@tanstack/react-router'
22
import { useEffect, useState } from 'react'
3-
import { Button } from './Button'
3+
import { Button } from '~/ui'
44

55
declare global {
66
interface Window {
@@ -184,22 +184,13 @@ export default function CookieConsent() {
184184
for details.
185185
</span>
186186
<div className="flex gap-2 flex-wrap items-center">
187-
<Button
188-
onClick={rejectAllCookies}
189-
className="bg-rose-500 border-rose-500 hover:bg-rose-600 text-white"
190-
>
187+
<Button color="red" onClick={rejectAllCookies}>
191188
Reject All
192189
</Button>
193-
<Button
194-
onClick={openSettings}
195-
className="bg-gray-500 border-gray-500 hover:bg-gray-600 text-white"
196-
>
190+
<Button color="gray" onClick={openSettings}>
197191
Customize
198192
</Button>
199-
<Button
200-
onClick={acceptAllCookies}
201-
className="bg-emerald-500 border-emerald-500 hover:bg-emerald-600 text-white"
202-
>
193+
<Button color="emerald" onClick={acceptAllCookies}>
203194
Accept All
204195
</Button>
205196
</div>
@@ -264,10 +255,7 @@ export default function CookieConsent() {
264255
</label>
265256
</div>
266257
<div className="mt-6">
267-
<Button
268-
onClick={closeSettings}
269-
className="bg-emerald-500 border-emerald-500 hover:bg-emerald-600 text-white"
270-
>
258+
<Button color="emerald" onClick={closeSettings}>
271259
Save
272260
</Button>
273261
</div>

src/components/CopyMarkdownButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useState, useTransition } from 'react'
44
import { type MouseEventHandler, useEffect, useRef } from 'react'
55
import { useToast } from '~/components/ToastProvider'
66
import { Check, Copy } from 'lucide-react'
7-
import { Button } from './Button'
7+
import { Button } from '~/ui'
88

99
export function useCopyButton(
1010
onCopy: () => void | Promise<void>,

src/components/CopyPageDropdown.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import * as React from 'react'
33
import { ChevronDown, Copy, Check } from 'lucide-react'
44
import { useToast } from '~/components/ToastProvider'
5-
import { Button } from './Button'
5+
import { Button } from '~/ui'
66
import { ButtonGroup } from './ButtonGroup'
77
import {
88
Dropdown,
@@ -242,7 +242,13 @@ export function CopyPageDropdown({
242242

243243
return (
244244
<ButtonGroup>
245-
<Button className="border-0 rounded-none" onClick={handleCopyPage}>
245+
<Button
246+
variant="ghost"
247+
size="xs"
248+
rounded="none"
249+
className="border-0"
250+
onClick={handleCopyPage}
251+
>
246252
{copied ? (
247253
<>
248254
<Check className="w-3 h-3" />
@@ -257,7 +263,12 @@ export function CopyPageDropdown({
257263
</Button>
258264
<Dropdown open={open} onOpenChange={setOpen}>
259265
<DropdownTrigger>
260-
<Button className="border-0 rounded-none px-1.5">
266+
<Button
267+
variant="ghost"
268+
size="xs"
269+
rounded="none"
270+
className="border-0 px-1.5"
271+
>
261272
<ChevronDown className="w-3 h-3" />
262273
</Button>
263274
</DropdownTrigger>

src/components/DefaultCatchBoundary.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from '@tanstack/react-router'
99
import * as Sentry from '@sentry/tanstackstart-react'
1010

11-
import { Button } from './Button'
11+
import { Button } from '~/ui'
1212
import { useEffect } from 'react'
1313

1414
// type DefaultCatchBoundaryType = {
@@ -67,26 +67,20 @@ export function DefaultCatchBoundary({ error }: ErrorComponentProps) {
6767
<ErrorComponent error={error} />
6868
<div className="flex gap-2 items-center flex-wrap">
6969
<Button
70+
color="gray"
7071
onClick={() => {
7172
router.invalidate()
7273
}}
73-
className="bg-gray-600 border-gray-600 hover:bg-gray-700 text-white"
7474
>
7575
Try Again
7676
</Button>
7777
{isRoot ? (
78-
<Button
79-
as={Link}
80-
to="/"
81-
className="bg-gray-600 border-gray-600 hover:bg-gray-700 text-white"
82-
>
78+
<Button as={Link} to="/" color="gray">
8379
TanStack Home
8480
</Button>
8581
) : (
8682
<Button
87-
as={Link}
88-
to="/"
89-
className="bg-gray-600 border-gray-600 hover:bg-gray-700 text-white"
83+
color="gray"
9084
onClick={(e: React.MouseEvent) => {
9185
e.preventDefault()
9286
window.history.back()

src/components/DocsCalloutQueryGG.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LogoQueryGGSmall } from '~/components/LogoQueryGGSmall'
1+
import { LogoQueryGG } from '~/ui'
22
import { useQueryGGPPPDiscount } from '~/hooks/useQueryGGPPPDiscount'
33

44
export function DocsCalloutQueryGG() {
@@ -15,7 +15,7 @@ export function DocsCalloutQueryGG() {
1515
<h6 className="text-[.7rem] uppercase font-black opacity-50">
1616
Want to Skip the Docs?
1717
</h6>
18-
<LogoQueryGGSmall className="w-full" />
18+
<LogoQueryGG size="small" className="w-full" />
1919

2020
<blockquote className="text-sm -indent-[.45em] pl-2">
2121
“If you’re serious about *really* understanding React Query, there’s

src/components/FeedbackModerationList.tsx

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import type { DocFeedback } from '~/db/types'
1616
import { calculatePoints } from '~/utils/docFeedback.client'
1717
import { Check, Lightbulb, TriangleAlert } from 'lucide-react'
1818
import { MessageSquare, X } from 'lucide-react'
19+
import { Badge, Button } from '~/ui'
1920

2021
interface FeedbackModerationListProps {
2122
data:
@@ -192,20 +193,18 @@ export function FeedbackModerationList({
192193
</Link>
193194
</TableCell>
194195
<TableCell>
195-
<span
196-
className={twMerge(
197-
'px-2 py-1 text-xs font-medium rounded-full',
198-
feedback.status === 'pending' &&
199-
'bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300',
200-
feedback.status === 'approved' &&
201-
'bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300',
202-
feedback.status === 'denied' &&
203-
'bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300',
204-
)}
196+
<Badge
197+
variant={
198+
feedback.status === 'pending'
199+
? 'warning'
200+
: feedback.status === 'approved'
201+
? 'success'
202+
: 'error'
203+
}
205204
>
206205
{feedback.status.charAt(0).toUpperCase() +
207206
feedback.status.slice(1)}
208-
</span>
207+
</Badge>
209208
</TableCell>
210209
<TableCell>
211210
<div>
@@ -238,20 +237,24 @@ export function FeedbackModerationList({
238237
<TableCell onClick={(e) => e.stopPropagation()}>
239238
{isPending && !isModeratingThis && (
240239
<div className="flex gap-2">
241-
<button
240+
<Button
241+
variant="icon"
242+
color="green"
243+
size="icon-sm"
242244
onClick={() => handleModerate(feedback.id, 'approve')}
243-
className="px-3 py-1 text-xs font-medium text-white bg-green-600 hover:bg-green-700 rounded transition-colors"
244245
title="Approve"
245246
>
246247
<Check />
247-
</button>
248-
<button
248+
</Button>
249+
<Button
250+
variant="icon"
251+
color="red"
252+
size="icon-sm"
249253
onClick={() => handleModerate(feedback.id, 'deny')}
250-
className="px-3 py-1 text-xs font-medium text-white bg-red-600 hover:bg-red-700 rounded transition-colors"
251254
title="Deny"
252255
>
253256
<X />
254-
</button>
257+
</Button>
255258
</div>
256259
)}
257260
{isModeratingThis && (

src/components/FeedbackModerationTopBar.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as React from 'react'
21
import { libraries } from '~/libraries'
32
import { DOC_FEEDBACK_STATUSES, type DocFeedbackStatus } from '~/db/types'
43
import {
@@ -9,6 +8,7 @@ import {
98
FilterCheckbox,
109
getFilterChipLabel,
1110
} from '~/components/FilterComponents'
11+
import { FormInput } from '~/ui'
1212

1313
interface FeedbackModerationTopBarProps {
1414
filters: {
@@ -169,14 +169,14 @@ export function FeedbackModerationTopBar({
169169
>
170170
From
171171
</label>
172-
<input
172+
<FormInput
173173
id="from"
174174
type="date"
175175
value={filters.dateFrom || ''}
176176
onChange={(e) =>
177177
onFilterChange({ dateFrom: e.target.value || undefined })
178178
}
179-
className="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500"
179+
className="text-sm"
180180
/>
181181
</div>
182182
<div>
@@ -186,14 +186,14 @@ export function FeedbackModerationTopBar({
186186
>
187187
To
188188
</label>
189-
<input
189+
<FormInput
190190
id="to"
191191
type="date"
192192
value={filters.dateTo || ''}
193193
onChange={(e) =>
194194
onFilterChange({ dateTo: e.target.value || undefined })
195195
}
196-
className="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500"
196+
className="text-sm"
197197
/>
198198
</div>
199199
</div>

0 commit comments

Comments
 (0)