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 15 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
35 changes: 7 additions & 28 deletions .yarn/patches/@fullcalendar-daygrid-npm-6.1.8-3f45184389.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/internal.js b/internal.js
index 26fee0cdcfd1d3da9ce40ae707a9dad54a3cbc99..f7be916bf4e694bb0f5047ee3b571401dc74c028 100644
index 26fee0cdcfd1d3da9ce40ae707a9dad54a3cbc99..a0f838b36bc0875aa0ddd63e717dcfec382faa8b 100644
--- a/internal.js
+++ b/internal.js
@@ -143,7 +143,6 @@ class TableCell extends DateComponent {
Expand All @@ -10,12 +10,8 @@ index 26fee0cdcfd1d3da9ce40ae707a9dad54a3cbc99..f7be916bf4e694bb0f5047ee3b571401
!renderProps.isDisabled &&
(props.showDayNumber || hasCustomDayCellContent(options) || props.forceDayTop) ? (createElement("div", { className: "fc-daygrid-day-top" },
createElement(InnerContent, { elTag: "a", elClasses: [
@@ -433,23 +432,41 @@ class TableRow extends DateComponent {
let mirrorSegsByCol = splitSegsByFirstCol(this.getMirrorSegs(), colCnt);
let { singleColPlacements, multiColPlacements, moreCnts, moreMarginTops } = computeFgSegPlacement(sortEventSegs(props.fgEventSegs, options.eventOrder), props.dayMaxEvents, props.dayMaxEventRows, options.eventOrderStrict, state.eventInstanceHeights, state.maxContentHeight, props.cells);
let isForcedInvisible = // TODO: messy way to compute this
- (props.eventDrag && props.eventDrag.affectedInstances) ||
+ (props.eventDrag && props.eventDrag.affectedInstances) ||
@@ -436,21 +435,37 @@ class TableRow extends DateComponent {
(props.eventDrag && props.eventDrag.affectedInstances) ||
(props.eventResize && props.eventResize.affectedInstances) ||
{};
- return (createElement("tr", { ref: this.rootElRef, role: "row" },
Expand All @@ -32,6 +28,7 @@ index 26fee0cdcfd1d3da9ce40ae707a9dad54a3cbc99..f7be916bf4e694bb0f5047ee3b571401
- this.renderFillSegs(businessHoursByCol[col], 'non-business'),
- this.renderFillSegs(bgEventSegsByCol[col], 'bg-event'))), minHeight: props.cellMinHeight }));
- })));
- }
+ /////////
+ // debugger;
+ let { dateEnv } = context
Expand All @@ -40,9 +37,7 @@ index 26fee0cdcfd1d3da9ce40ae707a9dad54a3cbc99..f7be916bf4e694bb0f5047ee3b571401
+ let num = dateEnv.computeWeekNumber(date) // TODO: somehow use for formatting as well?
+ let text = dateEnv.format(date, format)
+ let renderProps = { num, text, date }
+
+ /////////
+
+ return [createElement(options.dayHeaders ? "tr" : "div", { ref: this.rootElRef, role: options.dayHeaders ? "row" : "rowgroup", style: options.dayHeaders ? undefined : { display: "contents", fontSize: "110%" }},
+ (props.showWeekNumbers ? [createElement("td", {elClasses: ['fc-daygrid-day'], role: "gridcell", style: {fontWeight: 700, backgroundColor: !options.dayHeaders && "var(--fc-neutral-bg-color)", verticalAlign: options.dayHeaders && "middle", rotate: options.dayHeaders && "180deg", width: options.dayHeaders && "1.6em"}}, createElement("div", {style: {writingMode: options.dayHeaders && "vertical-rl", margin: options.dayHeaders ? ".6rem .1rem" : ".6rem", height: options.dayHeaders && "max-content"}}, options.weekNumberContent(renderProps)))] : []).concat(
+ props.cells.map((cell, col) => {
Expand All @@ -63,24 +58,8 @@ index 26fee0cdcfd1d3da9ce40ae707a9dad54a3cbc99..f7be916bf4e694bb0f5047ee3b571401
+ }, []).map((row, index) => {
+ return options.dayHeaders ? row : createElement("tr", { key: index, role: "row" }, row);
+ })
+ ), !options.dayHeaders && createElement("br")];
}
+ ), !options.dayHeaders && createElement("div", {elClasses: ["fc-daygrid-ystv-spacer"]})];
+ }
componentDidMount() {
this.updateSizing(true);
@@ -901,11 +918,11 @@ class TableView extends DateComponent {
key: 'header',
isSticky: stickyHeaderDates,
chunks: [{
- key: 'main',
- elRef: this.headerElRef,
- tableClassName: 'fc-col-header',
- rowContent: headerRowContent,
- }],
+ key: 'main',
+ elRef: this.headerElRef,
+ tableClassName: 'fc-col-header',
+ rowContent: headerRowContent,
+ }],
});
}
sections.push({
this.context.addResizeHandler(this.handleResize);
9 changes: 4 additions & 5 deletions app/(authenticated)/calendar/[eventID]/SignupSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ function SignupSheet({
)}
<table className="mt-4 border-collapse">
<tbody
className={"divide-x-0 divide-y-2 divide-dashed divide-gray-200"}
className={"divide-x-0 divide-y-2 divide-dashed divide-gray-200 dark:divide-[--mantine-color-placeholder]"}
>
{sheet.crews
.sort((a, b) => a.ordering - b.ordering)
.map((crew, index) => (
<tr
key={crew.crew_id}
className={
"divide-x-2 divide-y-0 divide-dashed divide-gray-200 text-sm font-semibold"
"divide-x-2 divide-y-0 divide-dashed divide-gray-200 dark:divide-[--mantine-color-placeholder] text-sm font-semibold"
}
>
<td className="px-3">
Expand All @@ -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
13 changes: 3 additions & 10 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 @@ -29,16 +30,8 @@ export default async function AuthenticatedLayout({
className="max-h-[4.5rem] w-auto py-2"
/>
</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>
<div className="ml-auto space-x-1 h-14 w-14">
<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={56}
height={56}
className="transition-all duration-50 max-h-14 max-w-14 rounded-[28px] hover:rounded-xl cursor-pointer border-solid border-0 hover:border-2 hover:border-slate-200"
aria-label="user menu"
/>
</Menu.Target>
<Menu.Dropdown className="right-2 -ml-1.5 mt-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>
);
}
34 changes: 34 additions & 0 deletions components/YSTVCalendar.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,37 @@
.fc-view {
--fc-today-bg-color: #3788d845;
}

.fc-daygrid-day-events-mobile-shrink.fc-dayGridMonth-view div[elClasses="fc-daygrid-ystv-spacer"] {
height: 3rem;
}

.fc-daygrid-day-events-mobile-shrink.fc-daygrid .fc-scrollgrid,
.fc-daygrid-day-events-mobile-shrink.fc-daygrid td[role="presentation"] {
border: 0;
}

.fc-daygrid-day-events-mobile-shrink.fc-daygrid .fc-scrollgrid table {
border-style: inherit;
}

/* 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),
.fc-dayGridMonth-view div[elClasses="fc-daygrid-ystv-spacer"] {
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"]'],
};
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2407,10 +2407,10 @@ __metadata:

"@fullcalendar/daygrid@patch:@fullcalendar/daygrid@npm%3A6.1.8#./.yarn/patches/@fullcalendar-daygrid-npm-6.1.8-3f45184389.patch::locator=hypothetical-new-internal-site%40workspace%3A.":
version: 6.1.8
resolution: "@fullcalendar/daygrid@patch:@fullcalendar/daygrid@npm%3A6.1.8#./.yarn/patches/@fullcalendar-daygrid-npm-6.1.8-3f45184389.patch::version=6.1.8&hash=eeec5d&locator=hypothetical-new-internal-site%40workspace%3A."
resolution: "@fullcalendar/daygrid@patch:@fullcalendar/daygrid@npm%3A6.1.8#./.yarn/patches/@fullcalendar-daygrid-npm-6.1.8-3f45184389.patch::version=6.1.8&hash=a8e1ec&locator=hypothetical-new-internal-site%40workspace%3A."
peerDependencies:
"@fullcalendar/core": ~6.1.8
checksum: 9b70e76b0ec96ef66daf3a6af1add86bf08ecc63fd70c4a2749af56aeb34539e325b5d48f8c3e3a3b737b571247ba252206ef1b364339290ebb6bd800ac4520e
checksum: cf8f4bc0046276b6eeff1567e1c5d95d89c13550211db85cab30284ca8c4e71c8eaeb62e8376708be724257ca62b71ba72c31522d7c4a10fece099abd5ddc0ce
languageName: node
linkType: hard

Expand Down