Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web 67 dark mode #51

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7f8072e
Add basic theme toggle + local storage persistance
archessmn Oct 7, 2023
bde9771
[WEB-67] Add basic dark theme toggle + persistence
archessmn Oct 7, 2023
e770d04
[WEB-67] Fix theming for fullcalendar header
archessmn Oct 8, 2023
9c99707
[WEB-67] CSS nesting + global dark: selector
archessmn Oct 9, 2023
c78c25f
[WEB-67] Fixed dark mode theming for mobile
archessmn Oct 9, 2023
8d5e087
[WEB-67] Ran yarn prettify because it complained.
archessmn Oct 9, 2023
54aae1b
[WEB-67] Fixed contrast on filled crew position
archessmn Oct 9, 2023
673ec21
[WEB-67] Remove unused imports
archessmn Oct 9, 2023
0f7e31b
[WEB-67] Move ModeToggle to dropdown user menu
archessmn Oct 9, 2023
9e4b728
[WEB-67] Prettify and label for accessibility
archessmn Oct 9, 2023
18ce606
[WEB-67] Re add separator on mobile month view
archessmn Oct 10, 2023
17842f3
[WEB-67] Hover effects for user menu
archessmn Oct 10, 2023
ca236ef
calendar spacer div instead of break + redundant layout changes removed
probablybenallen Oct 10, 2023
02478c1
update yark.lock to new patch
probablybenallen Oct 10, 2023
436aef9
adjust css to make div styles match old br + remove spacer border lines
probablybenallen Oct 10, 2023
b7cb4cf
Merge branch 'master' into web-67-dark-mode
probablybenallen Oct 10, 2023
b870fb5
Add basic theme toggle + local storage persistance
archessmn Oct 7, 2023
8c14e07
[WEB-67] Add basic dark theme toggle + persistence
archessmn Oct 7, 2023
1685fe6
[WEB-67] Fix theming for fullcalendar header
archessmn Oct 8, 2023
d6a58c7
[WEB-67] CSS nesting + global dark: selector
archessmn Oct 9, 2023
60300fb
[WEB-67] Fixed dark mode theming for mobile
archessmn Oct 9, 2023
f7a80e2
[WEB-67] Ran yarn prettify because it complained.
archessmn Oct 9, 2023
649a3ad
[WEB-67] Fixed contrast on filled crew position
archessmn Oct 9, 2023
d9fb3fc
[WEB-67] Remove unused imports
archessmn Oct 9, 2023
0e55a2e
[WEB-67] Move ModeToggle to dropdown user menu
archessmn Oct 9, 2023
a702c2e
[WEB-67] Prettify and label for accessibility
archessmn Oct 9, 2023
5c0acdf
[WEB-67] Re add separator on mobile month view
archessmn Oct 10, 2023
152a446
[WEB-67] Hover effects for user menu
archessmn Oct 10, 2023
b5130d9
calendar spacer div instead of break + redundant layout changes removed
probablybenallen Oct 10, 2023
2919152
update yark.lock to new patch
probablybenallen Oct 10, 2023
00209c1
adjust css to make div styles match old br + remove spacer border lines
probablybenallen Oct 10, 2023
60e5019
Merge remote-tracking branch 'origin/web-67-dark-mode' into web-67-da…
probablybenallen Oct 10, 2023
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
5 changes: 2 additions & 3 deletions app/(authenticated)/calendar/[eventID]/SignupSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function SignupSheet({
variant={"light"}
fullWidth
className={
"!h-auto min-h-[var(--button-height)] !select-text"
"!h-auto min-h-[var(--button-height)] !select-text dark:data-[disabled='true']:!bg-[--mantine-color-gray-filled] dark:data-[disabled='true']:text-[#888]"
}
justify={"left"}
disabled={readOnly}
Expand All @@ -126,10 +126,9 @@ function SignupSheet({
fullWidth
component={"div"}
className={
"!flex !h-auto min-h-[var(--button-height)] !cursor-default !select-text items-center !text-left active:!transform-none"
"!flex !h-auto min-h-[var(--button-height)] !cursor-default !select-text items-center !text-left !text-[--mantine-color-default-color] active:!transform-none"
}
justify={"left"}
color={"black"}
disabled={readOnly}
>
{crew.users
Expand Down
2 changes: 1 addition & 1 deletion app/(authenticated)/calendar/[eventID]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export default async function EventPage({
{event.is_tentative && (
<Alert
variant="light"
color="grey"
className="!bg-[#f3f3f4] !text-[--mantine-color-default-color] dark:!bg-[--mantine-color-gray-filled]"
title="Tentative Event"
icon={<TbInfoCircle />}
>
Expand Down
3 changes: 2 additions & 1 deletion app/(authenticated)/calendar/[eventID]/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export const CrewSchema = z.object({
ordering: z.number(),
locked: z.boolean().default(false),
user_id: z
.string().or(z.number())
.string()
.or(z.number())
.nullable()
.transform((v) => (v === "" ? null : v))
.pipe(z.coerce.number().nullable().default(null))
Expand Down
11 changes: 2 additions & 9 deletions app/(authenticated)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { UserProvider } from "@/components/UserContext";
import { mustGetCurrentUser } from "@/lib/auth/server";
import YSTVBreadcrumbs from "@/components/Breadcrumbs";
import * as Sentry from "@sentry/nextjs";
import { UserMenu } from "@/components/UserMenu";

export default async function AuthenticatedLayout({
children,
Expand All @@ -30,15 +31,7 @@ export default async function AuthenticatedLayout({
/>
</Link>
<div className="ml-auto space-x-1">
<Link href="/user/me">
<Image
src={user.avatar}
alt=""
width={96}
height={96}
className="max-h-[4.5rem] w-auto rounded-full py-2"
/>
</Link>
<UserMenu userAvatar={user.avatar} />
</div>
</nav>
<div className="mx-2 md:mx-6">
Expand Down
6 changes: 3 additions & 3 deletions app/(authenticated)/user/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ export default async function UserPage({ params }: { params: { id: string } }) {
<input
disabled
className="w-96"
value={`${
process.env.PUBLIC_URL
}/iCal/${await Calendar.encodeUserID(user.user_id)}`}
value={`${process.env.PUBLIC_URL}/iCal/${await Calendar.encodeUserID(
user.user_id,
)}`}
/>
</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default async function RootLayout({
<ColorSchemeScript />
</head>
<body className={inter.className}>
<MantineProvider theme={theme}>
<MantineProvider theme={theme} defaultColorScheme="light">
<ModalsProvider>
<PublicURLProvider value={process.env.PUBLIC_URL!}>
<DebugModeProvider value={debugMode}>
Expand Down
72 changes: 72 additions & 0 deletions components/UserMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"use client";

import Image from "next/image";
import {
Box,
Center,
Menu,
SegmentedControl,
useMantineColorScheme,
VisuallyHidden,
} from "@mantine/core";
import { LuLaptop, LuMoon, LuSun } from "react-icons/lu";

export function UserMenu({ userAvatar }: { userAvatar: string }) {
const { setColorScheme, colorScheme } = useMantineColorScheme();

return (
<Menu closeOnItemClick={false}>
<Menu.Target>
<Image
src={userAvatar}
alt=""
width={96}
height={96}
className="max-h-[4.5rem] w-auto rounded-full py-2"
aria-label="user menu"
/>
</Menu.Target>
<Menu.Dropdown className="right-2 -ml-1.5 mr-2 min-w-[150px]">
<Menu.Item component="a" href="/user/me">
Profile
</Menu.Item>
<Menu.Divider />
<Menu.Label>Theme</Menu.Label>
<SegmentedControl
value={colorScheme}
onChange={setColorScheme}
className="min-w-full"
data={[
{
value: "light",
label: (
<Center>
<LuSun className="scale-150" aria-label="light mode" />
<VisuallyHidden>Light Mode</VisuallyHidden>
</Center>
),
},
{
value: "auto",
label: (
<Center>
<LuLaptop className="scale-150" aria-label="auto mode" />
<VisuallyHidden>Auto Mode</VisuallyHidden>
</Center>
),
},
{
value: "dark",
label: (
<Center>
<LuMoon className="scale-150" aria-label="dark mode" />
<VisuallyHidden>Dark Mode</VisuallyHidden>
</Center>
),
},
]}
/>
</Menu.Dropdown>
</Menu>
);
}
25 changes: 25 additions & 0 deletions components/YSTVCalendar.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,28 @@
.fc-view {
--fc-today-bg-color: #3788d845;
}

/* Removes empty week separators on mobile month view */
tbody[role="presentation"] > br {
display: none;
}

/* Any theming inside this will only apply to dark color scheme. */
:is([data-mantine-color-scheme="dark"]) {
tbody[role="presentation"] > div > tr:not(:first-child) {
background-color: var(--mantine-color-body);
}

th.fc-col-header-cell > div,
.fc-list-day > th,
thead > tr[role="row"]:nth-child(1),
.fc-list-day-cushion,
.fc-daygrid-body,
tbody[role="presentation"] > div > tr:first-child > td {
background-color: var(--mantine-color-default) !important;
}

tr.fc-event:hover {
background-color: #000 !important;
}
}
2 changes: 1 addition & 1 deletion components/YSTVCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function getUoYWeekName(date: Date) {
if (!didLogAcademicYearError) {
Sentry.captureException(new Error("Failed to load academicYears"), {
extra: {
academicYears
academicYears,
},
});
didLogAcademicYearError = true;
Expand Down
2 changes: 1 addition & 1 deletion features/calendar/crew_positions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ export function getAllNonCustomCrewPositions(): Promise<CrewPositionType[]> {
},
where: {
is_custom: false,
}
},
});
}
1 change: 1 addition & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
plugins: {
"tailwindcss/nesting": {},
tailwindcss: {},
autoprefixer: {},
"postcss-preset-mantine": {},
Expand Down
1 change: 1 addition & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ module.exports = {
require("tailwindcss-animate"),
mantineVariantsPlugin,
],
darkMode: ["class", '[data-mantine-color-scheme="dark"]'],
};