Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions web/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<script type="module" src="/src/main.tsx" defer></script>
</head>
<body class="w-screen h-screen bg-slate-200 overflow-hidden">
<div id="root" class="w-screen h-screen"></div>
<body>
<div id="root"></div>
</body>
</html>
23 changes: 4 additions & 19 deletions web/app/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
import { RouterProvider } from 'react-router'
import { ThemeRegistry } from '@/theme'

import * as colors from '@mui/material/colors'
import { ThemeProvider, createTheme } from '@mui/material/styles'
import { RouterProvider } from 'react-router'

import router from '@/router'

const theme = createTheme({
shape: {
borderRadius: 0,
},
palette: {
primary: {
main: colors.blue[800],
},
secondary: {
main: colors.teal[400],
},
},
})

const App = () => (
<ThemeProvider theme={theme}>
<ThemeRegistry>
<RouterProvider router={router} />
</ThemeProvider>
</ThemeRegistry>
)

export default App
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import NavBar from '@/components/NavBar'
import PageFooter from '@/components/PageFooter'
import ProfileProvider from '@/components/ProfileProvider'

import { StyledAppLayout } from './styles'

export const loader = async () => {
return await loginRequired(authApi.whoami)()
}
Expand All @@ -20,15 +22,15 @@ const AppLayout = () => {

return (
<ProfileProvider value={profile}>
<div className="h-full flex flex-col overflow-hidden">
<StyledAppLayout>
<NavBar />

<main className="grow shrink h-0">
<main>
<Outlet key={location.key} />
</main>

<PageFooter />
</div>
</StyledAppLayout>
</ProfileProvider>
)
}
Expand Down
14 changes: 14 additions & 0 deletions web/app/src/layouts/AppLayout/styles.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { styled } from '@mui/material'

export const StyledAppLayout = styled('div')`
height: 100%;
display: flex;
flex-direction: column;
overflow: hidden;

> main {
flex-grow: 1;
flex-shrink: 1;
height: 0px;
}
`
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ import { Outlet } from 'react-router'
import { DialogsProvider } from '@toolpad/core/useDialogs'
import { NotificationsProvider } from '@toolpad/core/useNotifications'

import { StyledBaseLayout } from './styles'

const BaseLayout = () => {
return (
<div className="h-full flex flex-col overflow-hidden">
<StyledBaseLayout>
<DialogsProvider>
<NotificationsProvider>
<LocalizationProvider dateAdapter={AdapterDayjs}>
<Outlet />
</LocalizationProvider>
</NotificationsProvider>
</DialogsProvider>
</div>
</StyledBaseLayout>
)
}

Expand Down
8 changes: 8 additions & 0 deletions web/app/src/layouts/BaseLayout/styles.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { styled } from '@mui/material'

export const StyledBaseLayout = styled('div')`
height: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
`
6 changes: 4 additions & 2 deletions web/app/src/router/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export default createBrowserRouter([
{
path: '/web/',
lazy: async () => {
const { default: Component } = await import('@/layouts/base')
const { default: Component } =
await import('@/layouts/BaseLayout/component')
return {
Component,
HydrateFallback: () => <LinearProgress />,
Expand All @@ -34,7 +35,8 @@ export default createBrowserRouter([
{
path: '',
lazy: async () => {
const { default: Component, loader } = await import('@/layouts/app')
const { default: Component, loader } =
await import('@/layouts/AppLayout/component')
return { Component, loader }
},
children: [
Expand Down
29 changes: 29 additions & 0 deletions web/app/src/theme/ThemeRegistry.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { CacheProvider } from '@emotion/react'

import { type ReactNode, useMemo } from 'react'

import CssBaseline from '@mui/material/CssBaseline'
import GlobalStyles from '@mui/material/GlobalStyles'
import { ThemeProvider } from '@mui/material/styles'

import { createEmotionCache } from './emotionCache'
import globalStyles from './globalStyles'
import theme from './theme'

interface ThemeRegistryProps {
children: ReactNode
}

export default function ThemeRegistry({ children }: ThemeRegistryProps) {

Check warning on line 17 in web/app/src/theme/ThemeRegistry.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Mark the props of the component as read-only.

See more on https://sonarcloud.io/project/issues?id=link-society_flowg&issues=AZ0Lpw74ZVYF3I7QIhof&open=AZ0Lpw74ZVYF3I7QIhof&pullRequest=1219
const cache = useMemo(() => createEmotionCache(), [])

return (
<CacheProvider value={cache}>
<ThemeProvider theme={theme}>
<CssBaseline />
<GlobalStyles styles={globalStyles} />
{children}
</ThemeProvider>
</CacheProvider>
)
}
5 changes: 5 additions & 0 deletions web/app/src/theme/emotionCache.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import createCache from '@emotion/cache'

export function createEmotionCache() {
return createCache({ key: 'css', prepend: true })
}
26 changes: 26 additions & 0 deletions web/app/src/theme/globalStyles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { GlobalStylesProps } from '@mui/material/GlobalStyles'

import { colors } from './tokens'

const globalStyles: GlobalStylesProps['styles'] = {
'html, body': {
margin: 0,
padding: 0,
width: '100vw',
height: '100vh',
backgroundColor: colors.backgroundBody,
overflow: 'hidden',
},
'#root': {
width: '100vw',
height: '100vh',
display: 'flex',
flexDirection: 'column',
},
a: {
textDecoration: 'none',
color: 'inherit',
},
}

export default globalStyles
3 changes: 3 additions & 0 deletions web/app/src/theme/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { default as ThemeRegistry } from './ThemeRegistry'
export { default as theme } from './theme'
export { createEmotionCache } from './emotionCache'
31 changes: 31 additions & 0 deletions web/app/src/theme/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { colors } from '@mui/material'

import { createTheme } from '@mui/material/styles'

import { type TokensType, tokens } from './tokens'

declare module '@mui/material/styles' {
interface Theme {
tokens: TokensType
}
interface ThemeOptions {
tokens?: TokensType
}
}

const theme = createTheme({
tokens,
shape: {
borderRadius: 0,
},
palette: {
primary: {
main: colors.blue[800],
},
secondary: {
main: colors.teal[400],
},
},
})

export default theme
19 changes: 19 additions & 0 deletions web/app/src/theme/tokens/breakpoints.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export type BreakpointsType = {
xs: string
sm: string
md: string
lg: string
xl: string
xxl: string
}

export const breakpoints: BreakpointsType = {
xs: '320px',
sm: '480px',
md: '768px',
lg: '1024px',
xl: '1280px',
xxl: '1536px',
}

export default breakpoints
11 changes: 11 additions & 0 deletions web/app/src/theme/tokens/colors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export type ColorsType = {
white: string
backgroundBody: string
}

export const colors: ColorsType = {
white: '#ffffff',
backgroundBody: '#e2e8f0',
}

export default colors
15 changes: 15 additions & 0 deletions web/app/src/theme/tokens/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import breakpoints, { BreakpointsType } from './breakpoints'
import colors, { ColorsType } from './colors'

export const tokens = {
breakpoints,
colors,
}

export type TokensType = {
breakpoints: BreakpointsType
colors: ColorsType
}

export { breakpoints, colors }
export type { BreakpointsType, ColorsType }

Check warning on line 15 in web/app/src/theme/tokens/index.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use `export…from` to re-export `ColorsType`.

See more on https://sonarcloud.io/project/issues?id=link-society_flowg&issues=AZ0Lpw4MZVYF3I7QIhoe&open=AZ0Lpw4MZVYF3I7QIhoe&pullRequest=1219

Check warning on line 15 in web/app/src/theme/tokens/index.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use `export…from` to re-export `BreakpointsType`.

See more on https://sonarcloud.io/project/issues?id=link-society_flowg&issues=AZ0Lpw4MZVYF3I7QIhod&open=AZ0Lpw4MZVYF3I7QIhod&pullRequest=1219
Loading