Skip to content

Commit

Permalink
removed mui and emotion
Browse files Browse the repository at this point in the history
  • Loading branch information
jgentes committed Dec 29, 2023
1 parent c1d97e5 commit b634805
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 923 deletions.
1 change: 1 addition & 0 deletions app/components/layout/DarkModeButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Button, Tooltip } from '@nextui-org/react'
import { useTheme } from 'next-themes'
import { MoonIcon, SunIcon } from '~/components/icons'
import { errorHandler } from '~/utils/notifications'

const DarkMode = () => {
const { theme, setTheme } = useTheme()
Expand Down
2 changes: 1 addition & 1 deletion app/components/layout/LoginButton.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const LoginButton = () => {
size="xs"
onClose={() => setOpenAuth(false)}
>
<ModalContent className="bg-primary">
<ModalContent className="bg-primary-50">
<Auth
supabaseClient={supabase}
appearance={{
Expand Down
26 changes: 2 additions & 24 deletions app/root.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// this file establishes the root component that renders all subsequent / child routes
// it also injects top level styling, HTML meta tags, links, and javascript for browser rendering
import { Snackbar } from '@mui/joy'
import { NextUIProvider } from '@nextui-org/react'
import {
LinksFunction,
Expand All @@ -23,14 +22,14 @@ import { SupabaseClient } from '@supabase/supabase-js'
import { ThemeProvider as NextThemesProvider } from 'next-themes'
import posthog from 'posthog-js'
import { useEffect, useState } from 'react'
import { Toaster } from 'react-hot-toast'
import { createHead } from 'remix-island'
import { setAppState } from '~/api/db/appState'
import ConfirmModal from '~/components/ConfirmModal'
import { InitialLoader } from '~/components/Loader'
import { ErrorBoundary } from '~/errorBoundary'
import globalStyles from '~/global.css'
import tailwind from '~/tailwind.css'
import { Notification } from '~/utils/notifications'

// this is used to inject environment variables into the browser
export async function loader({ context }: LoaderFunctionArgs) {
Expand Down Expand Up @@ -84,7 +83,6 @@ const HtmlDoc = ({ children }: { children: React.ReactNode }) => {
const ThemeLoader = ({ error }: { error?: string }) => {
const data = error ? {} : useLoaderData<typeof loader>()
const [loading, setLoading] = useState(true)
const [notification, setNotification] = useState<Notification>()
const [supabase, setSupabase] = useState<SupabaseClient>()

useEffect(() => {
Expand All @@ -93,15 +91,6 @@ const ThemeLoader = ({ error }: { error?: string }) => {
setLoading(false)
}, 500)

// for snackbar notifications
const notify = (e: CustomEventInit) =>
setNotification({
message: e.detail.message,
color: e.detail.color || 'danger'
})

window.addEventListener('notify', notify)

// initalize posthog
posthog.init(data.ENV.REACT_APP_PUBLIC_POSTHOG_KEY, {
api_host: data.ENV.REACT_APP_PUBLIC_POSTHOG_HOST,
Expand Down Expand Up @@ -132,13 +121,11 @@ const ThemeLoader = ({ error }: { error?: string }) => {
posthog.capture('user logged out')
Sentry.setUser(null)
posthog.reset()
notify({ detail: { message: 'Logged out', color: 'success' } })
}
})

return () => {
clearTimeout(timer)
window.removeEventListener('notify', notify)
}
}, [data])

Expand All @@ -153,16 +140,7 @@ const ThemeLoader = ({ error }: { error?: string }) => {
<ConfirmModal />
</>
)}
<Snackbar
open={!!notification}
autoHideDuration={5000}
variant="soft"
color={notification?.color}
size="md"
onClose={() => setNotification(undefined)}
>
{notification?.message}
</Snackbar>
<Toaster toastOptions={{ duration: 5000 }} />
</NextThemesProvider>
</NextUIProvider>
)
Expand Down
100 changes: 0 additions & 100 deletions app/theme.tsx

This file was deleted.

16 changes: 2 additions & 14 deletions app/utils/notifications.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
import { SnackbarProps } from '@mui/joy'

type Notification = {
message: string
color?: SnackbarProps['color']
}
import toast from 'react-hot-toast'

const errorHandler = (error: Error | string) => {
const err = typeof error === 'string' ? Error(error) : error

console.error(err.message)

window.dispatchEvent(
new CustomEvent('notify', {
detail: { message: err?.message, color: 'danger' }
})
)
toast.error(err?.message)
}

export { errorHandler }
export type { Notification }
92 changes: 0 additions & 92 deletions global.d.ts

This file was deleted.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
"test": "playwright test"
},
"dependencies": {
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@fontsource/public-sans": "~4.5.11",
"@mui/joy": "^5.0.0-beta.15",
"@mui/material": "^5.14.18",
"@nextui-org/react": "^2.2.9",
"@remix-run/cloudflare": "^2.4.0",
"@remix-run/cloudflare-pages": "^2.4.0",
Expand All @@ -35,6 +31,7 @@
"posthog-js": "^1.94.4",
"react": "~18",
"react-dom": "~18",
"react-hot-toast": "^2.4.1",
"remix-island": "^0.1.2",
"teaful": "~0.11.1",
"use-count-up": "^3.0.1",
Expand Down
Loading

0 comments on commit b634805

Please sign in to comment.