Skip to content
Open
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
39 changes: 39 additions & 0 deletions .github/workflows/close-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/github-workflow.json
---
name: Close linked issues

# GitHub only auto-closes issues on merges into the default branch (main), so close them on merges into dev.
on:
pull_request:
types:
- closed
branches:
- dev

permissions:
issues: write
pull-requests: read

jobs:
close-issues:
if: github.event.pull_request.merged

runs-on: ubuntu-latest

steps:
- name: Close issues referenced with closing keywords
uses: actions/github-script@v9
with:
script: |
const { body, number } = context.payload.pull_request;
// One keyword covers a whole list: "Closes #1, #2 and #3".
const lists = (body ?? "").matchAll(/\b(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?):?\s+#\d+\b(?:[ \t]*,?[ \t]*(?:(?:and|&)[ \t]*)?#\d+\b)*/gi);
const issues = new Set([...lists].flatMap(([list]) => list.match(/\d+/g)).map(Number));

for (const issue_number of issues) {
const { data: issue } = await github.rest.issues.get({ ...context.repo, issue_number });
if (issue.pull_request || issue.state === "closed") continue;

await github.rest.issues.createComment({ ...context.repo, issue_number, body: `Closed by #${number}, merged into dev.` });
await github.rest.issues.update({ ...context.repo, issue_number, state: "closed", state_reason: "completed" });
}
2 changes: 2 additions & 0 deletions apps/next/src/components/auth/sign-in-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export function SignInButton({
try {
const authUrl = await getSignInUrl(provider, {
returnUrl: `${window.location.pathname}${window.location.search}${window.location.hash}`,
// Without this, ICSSC auth reuses any existing session and ignores the chosen provider.
authorizationUrlParams: { prompt: "consent" },
});
window.location.href = authUrl;
} catch (error) {
Expand Down
67 changes: 58 additions & 9 deletions apps/next/src/components/ui/restaurant/header/desktop-tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Station } from "@api/index";
import { Tab, Tabs } from "@mui/material";
import { useRef } from "react";
import { useRestaurantUIStore } from "@/context/useRestaurantUIStore";
import { scrollToStation, toTitleCase } from "@/utils/funcs";

Expand All @@ -10,6 +11,54 @@ interface DesktopTabsProps {
stations: Station[];
}

// Width of the edge fade set in the Tabs className.
const FADE_PX = 40;

// Scroll a clicked tab out of the edge fade, selecting it once it is fully in
// view. Selecting a cut-off tab makes MUI first scroll it only to the edge.
// Returns a function that cancels the pending selection.
function scrollPastFade(tab: Element, select: () => void) {
const scroller = tab.closest(".MuiTabs-scroller");
if (!scroller) {
select();
return () => {};
}
// How far the tab sticks out past each side of the scroller.
const overhang = () => {
const tabRect = tab.getBoundingClientRect();
const scrollerRect = scroller.getBoundingClientRect();
return {
left: scrollerRect.left - tabRect.left,
right: tabRect.right - scrollerRect.right,
};
};
const { left, right } = overhang();
const target = Math.min(
Math.max(
0,
scroller.scrollLeft +
(left > -FADE_PX ? -left - FADE_PX : Math.max(0, right + FADE_PX)),
),
scroller.scrollWidth - scroller.clientWidth,
);
scroller.scrollTo({ left: target, behavior: "smooth" });

let frame = 0;
let framesLeft = 60;
const selectInView = () => {
const { left, right } = overhang();
if (
(left <= 0 && right <= 0) ||
Math.abs(scroller.scrollLeft - target) < 1 ||
framesLeft-- === 0
)
select();
else frame = requestAnimationFrame(selectInView);
};
selectInView();
return () => cancelAnimationFrame(frame);
}

export function DesktopTabs({
isDesktop,
isLoading,
Expand All @@ -18,6 +67,7 @@ export function DesktopTabs({
}: DesktopTabsProps) {
const selectedStation = useRestaurantUIStore((s) => s.selectedStation);
const setSelectedStation = useRestaurantUIStore((s) => s.setSelectedStation);
const cancelSelect = useRef<() => void>(undefined);

if (!isDesktop) return null;

Expand All @@ -26,25 +76,24 @@ export function DesktopTabs({
{!isLoading && !isError && stations.length > 0 && (
<Tabs
value={selectedStation || false}
onChange={(_event, value: string) => {
onChange={(event, value: string) => {
const val = value || "";
scrollToStation(val);
setSelectedStation(val);
cancelSelect.current?.();
cancelSelect.current = scrollPastFade(event.currentTarget, () =>
setSelectedStation(val),
);
}}
variant="scrollable"
scrollButtons="auto"
slotProps={{
startScrollButtonIcon: { fontSize: "medium" },
endScrollButtonIcon: { fontSize: "medium" },
}}
className="h-[52px] w-full rounded-lg bg-primary-accent/20 px-2 dark:bg-[var(--desktop-tabs-bg)] [&_.MuiTabs-flexContainer]:h-full [&_.MuiTabs-flexContainer]:justify-between [&_.MuiTabs-flexContainer]:gap-10 [&_.MuiTabs-indicator]:!bg-sky-700 dark:[&_.MuiTabs-indicator]:!bg-blue-300 [&_.MuiTabScrollButton-root]:!text-slate-600 dark:[&_.MuiTabScrollButton-root]:!text-slate-300 [&_.MuiTabScrollButton-root.Mui-disabled]:!opacity-30"
scrollButtons
className="h-[42px] min-h-0 w-full rounded-md bg-primary-accent/20 dark:bg-[var(--desktop-tabs-bg)] [&_.MuiTabs-flexContainer]:h-full [&_.MuiTabs-flexContainer]:justify-between [&_.MuiTabs-indicator]:!bg-[var(--primary-accent-hex)] dark:[&_.MuiTabs-indicator]:!bg-[var(--primary-accent-light)] [&_.MuiTabScrollButton-root]:!text-black dark:[&_.MuiTabScrollButton-root]:!text-slate-300 [&_.MuiTabScrollButton-root.Mui-disabled]:!opacity-[0.26] [&_.MuiTabs-scroller]:[mask-image:linear-gradient(to_right,transparent,black_var(--fade-l,0px),black_calc(100%_-_var(--fade-r,0px)),transparent)] [&_.MuiTabScrollButton-root:not(.Mui-disabled)~.MuiTabs-scroller]:[--fade-l:40px] [&_.MuiTabs-scroller:has(+.MuiTabScrollButton-root:not(.Mui-disabled))]:[--fade-r:40px]"
>
{stations.map((station) => (
<Tab
key={station.name}
value={station.name.toLowerCase()}
label={toTitleCase(station.name)}
className="!whitespace-nowrap !max-w-none !px-4!text-base !font-medium !text-black dark:!text-white !normal-case !min-h-0 aria-selected:!text-sky-700 dark:aria-selected:!text-blue-300"
className="!whitespace-nowrap !max-w-none !min-w-0 !px-3 !tracking-[0.4px] !font-medium !text-black dark:!text-white !normal-case !min-h-0 aria-selected:!font-semibold aria-selected:!text-[var(--primary-accent-hex)] dark:aria-selected:!text-[var(--primary-accent-light)]"
/>
))}
</Tabs>
Expand Down
Loading