Skip to content
Merged
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
6 changes: 4 additions & 2 deletions frontend/src/components/Navbar/BottomHeader.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
background: var(--mantine-color-body);
position: fixed;
top: 0;
left: 50%;
transform: translateX(-50%);
width: 100%;
z-index: var(--mantine-z-index-app);
/* box-shadow: var(--mantine-shadow-xs); */

/* Add a margin left equal to the width of the scorllbar, so the navbar doesn't
shift around depending on page length. A similar style is applied to the body.*/
padding-left: calc(100vw - 100%);

@mixin dark {
border-bottom: 2px solid var(--mantine-color-dark-6);
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Navbar/BottomHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const BottomHeader: React.FC<Props> = ({
return (
<>
<Box visibleFrom="md" className={classes.placeholder} />
<Container visibleFrom="md" className={classes.navbar} fluid={true}>
<Box visibleFrom="md" className={classes.navbar}>
<Container size={size ? size : "md"} className={classes.container}>
<Link to={""} className={classes.title}>
{uwu ? (
Expand Down Expand Up @@ -63,7 +63,7 @@ const BottomHeader: React.FC<Props> = ({
<ColorSchemeToggle/>
</Group>
</Container>
</Container>
</Box>
</>
);
};
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/components/category-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@ import { authenticated } from "../api/fetch-utils";
import { SearchResult } from "../hooks/useSearch";
import { CategoryMetaData } from "../interfaces";
import { highlight } from "../utils/search-utils";
import clsx from "clsx";
import clsx, { ClassValue } from "clsx";
import classes from "../utils/focus-outline.module.css";
import { useMutation } from "../api/hooks";
import { addNewFavourite, removeFavourite } from "../api/favourite";

interface Props {
category: SearchResult<CategoryMetaData> | CategoryMetaData;
onFavouriteToggle: () => void;
className?: ClassValue;
}

const pluralize = (count: number, noun: string) =>
`${count} ${noun}${count !== 1 ? "s" : ""}`;

const CategoryCard: React.FC<Props> = ({ category, onFavouriteToggle: refresh }) => {
const CategoryCard: React.FC<Props> = ({ category, className, onFavouriteToggle: refresh }) => {
const history = useHistory();
const handleKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {
if (e.code === "Enter") {
Expand Down Expand Up @@ -83,7 +84,7 @@ const CategoryCard: React.FC<Props> = ({ category, onFavouriteToggle: refresh })
withBorder
px="lg"
py="md"
className={clsx(classes.focusOutline, classes.hoverShadow)}
className={clsx(classes.focusOutline, classes.hoverShadow, className)}
tabIndex={0}
onKeyDown={handleKeyDown}
>
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/components/secondary-container.module.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
.contentContainer {
.unOffsetFullWidth {
/* Use to reverse the margin-left applied on <main> to counter scroll bar */
margin-left: calc(100% - 100vw);
padding-left: calc(100vw - 100%);
}

.fullWidthContentContainer {
@mixin light {
background-color: var(--mantine-color-gray-0);
box-shadow: inset var(--mantine-color-gray-2) 0px 0px 10px;
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/components/secondary-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ const ContentContainer: React.FC<ContentContainerProps> = ({
}) => {
return (
<>
<Divider mt="lg" {...others} />
<Divider mt="lg" className={classes.unOffsetFullWidth} {...others} />
<Box
py="md"
px={0}
className={`${classes.contentContainer} ${
className={`${classes.fullWidthContentContainer} ${classes.unOffsetFullWidth} ${
className ? ` ${className}` : ""
}`}
>
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@
width: 18px;
height: 18px;
}

main {
/* Add a margin left equal to the width of the scorllbar, so the content doesn't
shift around depending on page length. A similar style is applied to the navbar.*/
margin-left: calc(100vw - 100%);
}
5 changes: 5 additions & 0 deletions frontend/src/pages/home-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { IconPlus, IconSearch} from "@tabler/icons-react";
import { useDisclosure } from "@mantine/hooks";
import KawaiiBetterInformatics from "../assets/kawaii-betterinformatics.svg?react";
import { getFavourites } from "../api/favourite";
import classes from "../utils/fade-in-order.module.css";
import { EditMeta1, EditMeta2 } from "../components/edit-meta-categories";

const displayNameGetter = (data: CategoryMetaData) => data.displayname;
Expand Down Expand Up @@ -305,6 +306,7 @@ export const CategoryList: React.FC<{}> = () => {
<CategoryCard
category={category}
key={category.slug}
className={filter.length === 0 && classes.fadeInOrder}
onFavouriteToggle={onFavouriteToggle}
/>
))}
Expand Down Expand Up @@ -346,6 +348,7 @@ export const CategoryList: React.FC<{}> = () => {
<CategoryCard
category={category}
key={category.slug}
className={classes.fadeInOrder}
onFavouriteToggle={onFavouriteToggle}
/>
))}
Expand All @@ -364,6 +367,7 @@ export const CategoryList: React.FC<{}> = () => {
<CategoryCard
category={category}
key={category.slug}
className={classes.fadeInOrder}
onFavouriteToggle={onFavouriteToggle}
/>
))}
Expand All @@ -390,6 +394,7 @@ export const CategoryList: React.FC<{}> = () => {
<CategoryCard
category={category}
key={category.slug}
className={classes.fadeInOrder}
onFavouriteToggle={onFavouriteToggle}
/>
))
Expand Down
21 changes: 21 additions & 0 deletions frontend/src/utils/fade-in-order.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

.fadeInOrder {
/* Browser support for sibling-index is limited, only try staggering fade-in
if the browser says it supports it. */
@supports (animation-delay: calc(sibling-index() * 25ms)) {
/* Stagger animation should only be used if the user hasn't preferred a
reduced-motion version of the page and they're not printing it */
@media screen and (prefers-reduced-motion: no-preference) {
opacity: 0;
transform: translateY(5px);
animation: fade-in-below 100ms linear calc(sibling-index() * 25ms) forwards;
}

@keyframes fade-in-below {
100% {
opacity: 1;
transform: translateY(0);
}
}
}
}