Skip to content

Commit

Permalink
bring over latest improvements from the workshops
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Aug 14, 2023
1 parent eab3f01 commit 5cb5110
Show file tree
Hide file tree
Showing 141 changed files with 7,462 additions and 5,431 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ SESSION_SECRET="super-duper-s3cret"
INTERNAL_COMMAND_TOKEN="some-made-up-token"
RESEND_API_KEY="re_blAh_blaHBlaHblahBLAhBlAh"
SENTRY_DSN="your-dsn"

# the mocks and some code rely on these two being prefixed with "MOCK_"
# if they aren't then the real github api will be attempted
GITHUB_CLIENT_ID="MOCK_GITHUB_CLIENT_ID"
GITHUB_CLIENT_SECRET="MOCK_GITHUB_CLIENT_SECRET"
5 changes: 3 additions & 2 deletions .prettierrc.cjs → .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
/** @type {import("prettier").Options} */
export default {
arrowParens: 'avoid',
bracketSameLine: false,
bracketSpacing: true,
Expand All @@ -25,5 +26,5 @@ module.exports = {
},
},
],
plugins: [require('prettier-plugin-tailwindcss')],
plugins: ['prettier-plugin-tailwindcss'],
}
11 changes: 4 additions & 7 deletions app/components/confetti.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import { Index as ConfettiShower } from 'confetti-react'
import { ClientOnly } from 'remix-utils'

/**
* confetti is a unique random identifier which re-renders the component
*/
export function Confetti({ confetti }: { confetti?: string }) {
if (!confetti) return null
export function Confetti({ id }: { id?: string | null }) {
if (!id) return null

return (
<ClientOnly>
{() => (
<ConfettiShower
key={confetti}
run={Boolean(confetti)}
key={id}
run={Boolean(id)}
recycle={false}
numberOfPieces={500}
width={window.innerWidth}
Expand Down
4 changes: 2 additions & 2 deletions app/components/search-bar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Form, useSearchParams, useSubmit } from '@remix-run/react'
import { useDebounce, useIsSubmitting } from '~/utils/misc.tsx'
import { useDebounce, useIsPending } from '~/utils/misc.tsx'
import { Icon } from './ui/icon.tsx'
import { Input } from './ui/input.tsx'
import { Label } from './ui/label.tsx'
Expand All @@ -16,7 +16,7 @@ export function SearchBar({
}) {
const [searchParams] = useSearchParams()
const submit = useSubmit()
const isSubmitting = useIsSubmitting({
const isSubmitting = useIsPending({
formMethod: 'GET',
formAction: '/users',
})
Expand Down
22 changes: 22 additions & 0 deletions app/components/toaster.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { useEffect } from 'react'
import { Toaster, toast as showToast } from 'sonner'
import { type Toast } from '~/utils/toast.server.ts'

export function EpicToaster({ toast }: { toast?: Toast | null }) {
return (
<>
<Toaster closeButton position="top-center" />
{toast ? <ShowToast toast={toast} /> : null}
</>
)
}

function ShowToast({ toast }: { toast: Toast }) {
const { id, type, title, description } = toast
useEffect(() => {
setTimeout(() => {
showToast[type](title, { id, description })
}, 0)
}, [description, id, title, type])
return null
}
2 changes: 1 addition & 1 deletion app/components/ui/status-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const StatusButton = React.forwardRef<
className={cn('flex justify-center gap-4', className)}
{...props}
>
{children}
<div>{children}</div>
{message ? (
<TooltipProvider>
<Tooltip>
Expand Down
47 changes: 18 additions & 29 deletions app/components/ui/toaster.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
import {
Toast,
ToastClose,
ToastDescription,
ToastProvider,
ToastTitle,
ToastViewport,
} from '~/components/ui/toast.tsx'
import { useToast } from '~/components/ui/use-toast.ts'

export function Toaster() {
const { toasts } = useToast()
import { useEffect } from 'react'
import { Toaster, toast as showToast } from 'sonner'
import { type Toast } from '~/utils/toast.server.ts'

export function EpicToaster({ toast }: { toast?: Toast | null }) {
return (
<ToastProvider>
{toasts.map(function ({ id, title, description, action, ...props }) {
return (
<Toast key={id} {...props}>
<div className="grid gap-1">
{title && <ToastTitle>{title}</ToastTitle>}
{description && (
<ToastDescription>{description}</ToastDescription>
)}
</div>
{action}
<ToastClose />
</Toast>
)
})}
<ToastViewport />
</ToastProvider>
<>
<Toaster closeButton position="top-center" />
{toast ? <ShowToast toast={toast} /> : null}
</>
)
}

function ShowToast({ toast }: { toast: Toast }) {
const { id, type, title, description } = toast
useEffect(() => {
setTimeout(() => {
showToast[type](title, { id, description })
}, 0)
}, [description, id, title, type])
return null
}
189 changes: 0 additions & 189 deletions app/components/ui/use-toast.ts

This file was deleted.

3 changes: 0 additions & 3 deletions app/entry.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import { RemixBrowser } from '@remix-run/react'
import { startTransition } from 'react'
import { hydrateRoot } from 'react-dom/client'

if (ENV.MODE === 'development') {
import('~/utils/devtools.tsx').then(({ init }) => init())
}
if (ENV.MODE === 'production' && ENV.SENTRY_DSN) {
import('~/utils/monitoring.client.tsx').then(({ init }) => init())
}
Expand Down
Loading

0 comments on commit 5cb5110

Please sign in to comment.