Skip to content

Commit a088948

Browse files
committed
Update styles and add background images
1 parent 27930d8 commit a088948

28 files changed

+156
-38
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
45 KB
Loading
42.4 KB
Loading
78.8 KB
Loading

src/components/App/App.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
mdiCheck,
55
mdiCogOutline,
66
mdiDockLeft,
7+
mdiImage,
78
mdiListStatus,
89
mdiNoteTextOutline,
910
} from '@mdi/js'
@@ -26,6 +27,7 @@ import { AppThemeSwitcher } from './AppThemeSwitcher'
2627
import { useCustomizeMode } from './useCustomizeMode'
2728
import { useSearchMode } from './useSearchMode'
2829
import { useTheme } from './useTheme'
30+
import { useToggleBackground } from './useToggleBackground'
2931
import { useToggleDescriptions } from './useToggleDescriptions'
3032
import { useToggleJumpLinks } from './useToggleJumpLinks'
3133

@@ -34,15 +36,16 @@ export const WebdevHome: FC = () => {
3436
const searchMode = useSearchMode()
3537
const toggleDescriptions = useToggleDescriptions()
3638
const toggleJumpLinks = useToggleJumpLinks()
39+
const toggleBackground = useToggleBackground()
3740
const isCurrentAppMode = useIsCurrentAppMode()
3841

3942
useTheme()
4043

4144
function handleScrollTopClick() {
42-
const htmlEl = document.children.item(0)
43-
if (htmlEl === null) return
45+
const mainContentElement = document.getElementById('main-content')
46+
if (mainContentElement === null) return
4447

45-
htmlEl.scrollTo({ top: 0, behavior: 'smooth' })
48+
mainContentElement.scrollTo({ top: 0, behavior: 'smooth' })
4649
}
4750

4851
return (
@@ -110,6 +113,12 @@ export const WebdevHome: FC = () => {
110113
selected={toggleDescriptions.showDescriptions}
111114
action={toggleDescriptions.toggle}
112115
/>
116+
<AppMenuItem
117+
label="Show background"
118+
icon={<MdiIcon path={mdiImage} />}
119+
selected={toggleBackground.showBackground}
120+
action={toggleBackground.toggle}
121+
/>
113122

114123
<AppThemeSwitcher />
115124
<AppInfo />

src/components/App/AppLayout.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import classNames from 'classnames'
22
import { FC, PropsWithChildren, ReactElement, ReactNode } from 'react'
3+
import { useToggleBackground } from './useToggleBackground'
34

45
type Props = {
56
header: ReactElement
@@ -11,19 +12,27 @@ export const AppLayout: FC<PropsWithChildren<Props>> = ({
1112
header,
1213
sidebar,
1314
}) => {
15+
const toggleBackground = useToggleBackground()
16+
1417
return (
1518
<div
1619
className={classNames(
1720
'fixed inset-0',
1821
'grid grid-cols-1 grid-rows-[auto,1fr]',
1922
'lg:grid-cols-[auto,1fr]',
2023
'overflow-hidden',
21-
'bg-white dark:bg-gray-700',
24+
{
25+
'bg-page-light dark:bg-page-dark bg-cover bg-center':
26+
toggleBackground.showBackground,
27+
'bg-white dark:bg-gray-800': !toggleBackground.showBackground,
28+
},
2229
)}
2330
>
24-
<div className="col-span-2">{header}</div>
31+
<div className="lg:col-span-2">{header}</div>
2532
<div className="overflow-auto">{sidebar}</div>
26-
<div className="overflow-auto">{children}</div>
33+
<div className="overflow-auto" id="main-content">
34+
{children}
35+
</div>
2736
</div>
2837
)
2938
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { useCallback } from 'react'
2+
import { useAppDispatch, useAppSelector } from '../../stores'
3+
import { setDisplayBackground } from '../../stores/appSettings/appSettingsActions'
4+
5+
type UseToggleBackgroundResult = {
6+
showBackground: boolean
7+
toggle: () => void
8+
}
9+
10+
export function useToggleBackground(): UseToggleBackgroundResult {
11+
const dispatch = useAppDispatch()
12+
13+
const showBackground = useAppSelector(
14+
(state) => state.appSettings.showBackground,
15+
)
16+
17+
const toggle = useCallback(() => {
18+
dispatch(setDisplayBackground(!showBackground))
19+
}, [dispatch, showBackground])
20+
21+
return { showBackground, toggle }
22+
}

src/components/Header/AppAction.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ export const AppAction: FC<Props> = ({
2525
'rounded-md',
2626
'select-none',
2727
{
28-
'hover:bg-gray-300 active:bg-gray-400': !active && !highlight,
28+
'hover:bg-black/10 active:bg-black/15': !active && !highlight,
2929
'bg-brand-500 hover:bg-brand-600 active:bg-brand-700':
3030
active && !highlight,
3131
'bg-brand-500/15 hover:bg-brand-500/25 active:bg-brand-500/35':
3232
highlight,
33-
'dark:hover:bg-gray-600 dark:active:bg-gray-500':
33+
'dark:hover:bg-white/10 dark:active:bg-white/15':
3434
!active && !highlight,
3535
'dark:hover:bg-brand-600 dark:active:bg-brand-700':
3636
active && !highlight,

src/components/Header/AppHeader.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,21 @@ export const AppHeader: FC<Props> = ({ centerItems, actions }) => {
1212
<div
1313
className={classNames(
1414
'grid items-center',
15-
'grid-cols-[1fr,auto,1fr]',
15+
'grid-cols-[1fr,auto] grid-rows-[auto,auto] md:grid-cols-[1fr,auto,1fr] md:grid-rows-1',
1616
'px-page',
17+
'bg-white/20 dark:bg-black/20',
1718
)}
1819
>
1920
<Logo />
2021

2122
{centerItems !== null ? (
22-
<div className="flex items-center gap-x-1 py-2">{centerItems}</div>
23+
<div className="col-span-2 row-start-2 flex items-center gap-x-1 justify-self-center py-2 md:col-span-1 md:col-start-2 md:row-start-1">
24+
{centerItems}
25+
</div>
2326
) : null}
2427

2528
{actions !== null ? (
26-
<div className="flex gap-x-1 place-self-end py-2">
27-
{actions}
28-
</div>
29+
<div className="flex gap-x-1 place-self-end py-2">{actions}</div>
2930
) : null}
3031
</div>
3132
)

src/components/Header/AppMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const AppMenu: FC<PropsWithChildren<Props>> = ({
2525
'flex flex-col gap-y-px',
2626
'bg-white dark:bg-gray-600',
2727
'border border-gray-300 dark:border-gray-400',
28-
'rounded-md',
28+
'rounded-md shadow-lg',
2929
)}
3030
>
3131
{children}

0 commit comments

Comments
 (0)