Skip to content

Commit

Permalink
Adjusted side nav (#1524)
Browse files Browse the repository at this point in the history
* Changed nav and side to be sticky

* Centered calendar

* Adjusted top padding

* Added firefox scrollbar styling

* Adjusted scroll colors to fit theme

* Somehow this broke?? 😭

* Fix lint

* Adjust calendar padding

---------

Co-authored-by: hfcRed <[email protected]>
Co-authored-by: Kalle <[email protected]>
  • Loading branch information
3 people authored Oct 21, 2023
1 parent 580274a commit 3bfa182
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 37 deletions.
49 changes: 28 additions & 21 deletions app/components/Main.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { useCatch } from "@remix-run/react";
import { useCatch, useLocation } from "@remix-run/react";
import clsx from "clsx";
import type * as React from "react";
import { useMatches } from "react-router";
import { useUser } from "~/modules/auth";
import type { RootLoaderData } from "~/root";
import { SideNav } from "app/components/layout/SideNav";

export const Main = ({
children,
Expand All @@ -25,28 +26,34 @@ export const Main = ({
const user = useUser();
const showLeaderboard = data?.publisherId && !user?.patronTier && !caught;

const location = useLocation();
const isFrontPage = location.pathname === "/";

return (
<main
className={
classNameOverwrite
? clsx(classNameOverwrite, {
"half-width": halfWidth,
"pt-8-forced": showLeaderboard,
})
: clsx(
"layout__main",
"main",
{
<div className="layout__main-container">
{!isFrontPage ? <SideNav /> : null}
<main
className={
classNameOverwrite
? clsx(classNameOverwrite, {
"half-width": halfWidth,
bigger,
"pt-8-forced": showLeaderboard,
},
className,
)
}
style={style}
>
{children}
</main>
})
: clsx(
"layout__main",
"main",
{
"half-width": halfWidth,
bigger,
"pt-8-forced": showLeaderboard,
},
className,
)
}
style={style}
>
{children}
</main>
</div>
);
};
2 changes: 1 addition & 1 deletion app/components/layout/SideNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function SideNav() {
{navItems.map((item) => {
return (
<Link
to={item.url}
to={`/${item.url}`}
key={item.name}
prefetch={item.prefetch ? "render" : undefined}
>
Expand Down
2 changes: 0 additions & 2 deletions app/components/layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type { Breadcrumb, SendouRouteHandle } from "~/utils/remix";
import { Footer } from "./Footer";
import { useTranslation } from "~/hooks/useTranslation";
import { Image } from "../Image";
import { SideNav } from "./SideNav";
import { UserItem } from "./UserItem";
import { LanguageChanger } from "./LanguageChanger";
import { ThemeChanger } from "./ThemeChanger";
Expand Down Expand Up @@ -110,7 +109,6 @@ export const Layout = React.memo(function Layout({
{!isErrored ? <UserItem /> : null}
</div>
</header>
{!isFrontPage ? <SideNav /> : null}
{showLeaderboard ? <MyRampUnit /> : null}
{children}
<Footer patrons={data?.patrons} />
Expand Down
2 changes: 1 addition & 1 deletion app/routes/calendar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export default function CalendarPage() {
: data.events;

return (
<Main classNameOverwrite="stack lg layout__main">
<Main classNameOverwrite="stack lg main layout__main">
<WeekLinks />
<EventsToReport />
<div className="stack md">
Expand Down
3 changes: 2 additions & 1 deletion app/styles/calendar.css
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@
.calendar__event {
display: flex;
flex-direction: column;
padding-top: var(--s-4);
padding-top: var(--s-3);
font-size: var(--fonts-lg);
padding-inline: var(--s-4);
}

.calendar__event + .calendar__event {
Expand Down
70 changes: 59 additions & 11 deletions app/styles/layout.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.layout__container {
display: flex;
height: 100%;
flex-direction: column;
width: 100%;
min-height: 100vh;
}

.layout__breadcrumb-container {
Expand Down Expand Up @@ -36,9 +37,7 @@
}

.layout__header {
position: fixed;
z-index: 501;
top: 0;
display: flex;
width: 100%;
align-items: center;
Expand All @@ -50,6 +49,8 @@
font-weight: bold;
padding-block: var(--s-2);
padding-inline: var(--s-4);
position: sticky;
top: 0;
}

.layout__avatar {
Expand Down Expand Up @@ -107,9 +108,14 @@
margin: 0 auto;
}

.layout__main-container {
display: flex;
flex-direction: row;
}

.layout__main {
padding-block-end: var(--s-32);
padding-block-start: var(--s-16);
padding-block-start: var(--s-4);
}

.layout__log-in-button {
Expand Down Expand Up @@ -244,18 +250,60 @@
}

.layout__side-nav {
--top-size: calc(var(--item-size) + 2 * var(--s-2));

position: fixed;
top: var(--top-size);
background: black;
display: flex;
height: calc(100vh - var(--top-size));
flex-direction: column;
justify-content: flex-start;
gap: var(--s-6);
overflow-y: auto;
padding-block: var(--s-3);
padding-inline: var(--s-4);
width: fit-content;
-webkit-backdrop-filter: var(--backdrop-filter);
backdrop-filter: var(--backdrop-filter);
background-color: transparent;
overflow-y: auto;
overflow-x: hidden;
direction: rtl;
position: sticky;

/*
Top pixel count needs to be the same as nav height
Max height is calculated using the viewport height minus the nav height
This is unfortunately needed to avoid the sidebar from overflowing the viewport or navbar
Without this, the sidebar would be cut off at the bottom or top or clip into it
Will return if a better solution is found that doesnt require a hard coded value
*/
top: 47px;
max-height: calc(100vh - 47px);
scrollbar-color: rgb(83 65 91) transparent;
scrollbar-width: thin;
scrollbar-gutter: stable;
}

/*
Works on literally every browser except Firefox
Firefox scrollbar styling is above in .layout__side-nav
*/
.layout__side-nav::-webkit-scrollbar {
width: 4px;
}

.layout__side-nav::-webkit-scrollbar-track {
background: black;
background-color: transparent;
}

.layout__side-nav::-webkit-scrollbar-corner {
background: black;
background-color: transparent;
}

.layout__side-nav::-webkit-scrollbar-thumb {
background-color: rgb(83 65 91);
border-radius: 4px;
}

.layout__side-nav::-webkit-scrollbar-thumb:hover {
background-color: rgb(62 49 68);
}

.layout__side-nav-image-container {
Expand Down

0 comments on commit 3bfa182

Please sign in to comment.