From 0008d9e914f5650fe0e9f68f060644b2ff849ec6 Mon Sep 17 00:00:00 2001 From: Aditya Thakral Date: Fri, 27 Aug 2021 20:38:11 -0400 Subject: [PATCH 1/3] Misc css fixes --- components/Code.module.css | 2 +- components/EventCard.module.css | 7 +++---- components/EventCard.tsx | 33 ++++++++++++++++++++++----------- components/Image.module.css | 4 ++++ components/Image.tsx | 10 ++++++++-- components/Link.module.css | 1 + pages/_app.tsx | 2 ++ 7 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 components/Image.module.css diff --git a/components/Code.module.css b/components/Code.module.css index ba3d5b71..d317052c 100644 --- a/components/Code.module.css +++ b/components/Code.module.css @@ -2,5 +2,5 @@ padding: 0 calc(4rem / 16); background: var(--code-background); border-radius: calc(5rem / 16); - word-wrap: break-word; + overflow-wrap: break-word; } diff --git a/components/EventCard.module.css b/components/EventCard.module.css index 27393553..714c609a 100644 --- a/components/EventCard.module.css +++ b/components/EventCard.module.css @@ -15,13 +15,12 @@ margin-bottom: 1rem; } -.spacer { - margin-top: calc(76rem / 16); +.registerButton { + font-weight: bold; } -.registerButton { +.registerButtonWithPoster { display: block; - font-weight: bold; } .content > h1 { diff --git a/components/EventCard.tsx b/components/EventCard.tsx index eeae0997..193b8ff3 100644 --- a/components/EventCard.tsx +++ b/components/EventCard.tsx @@ -28,10 +28,28 @@ export function EventCard({ }: EventCardProps) { return (
- -
-

{name}

-

- -

-
{children}
); diff --git a/components/Image.module.css b/components/Image.module.css new file mode 100644 index 00000000..0e712845 --- /dev/null +++ b/components/Image.module.css @@ -0,0 +1,4 @@ +.image { + /* So that image doesn't overflow on mobile screens */ + max-width: 100%; +} diff --git a/components/Image.tsx b/components/Image.tsx index 8175af56..2ab05c22 100644 --- a/components/Image.tsx +++ b/components/Image.tsx @@ -1,8 +1,14 @@ import React, { ImgHTMLAttributes } from "react"; +import styles from "./Image.module.css"; + export function Image(props: ImgHTMLAttributes) { + const classes = props.className + ? [props.className, styles.image] + : [styles.image]; + if (props.src?.startsWith("http://") || props.src?.startsWith("https://")) { - return ; + return ; } const { src: relativeSrc = "" } = props; @@ -16,5 +22,5 @@ export function Image(props: ImgHTMLAttributes) { absoluteSrc += "/" + relativeSrc; } - return ; + return ; } diff --git a/components/Link.module.css b/components/Link.module.css index 8edbfa31..3ed8f8ac 100644 --- a/components/Link.module.css +++ b/components/Link.module.css @@ -3,6 +3,7 @@ transition-duration: 0.3s; text-decoration: none; white-space: normal; + overflow-wrap: anywhere; } .link:hover { diff --git a/pages/_app.tsx b/pages/_app.tsx index e705b5ec..71f1a530 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -8,6 +8,7 @@ import { Code } from "@/components/Code"; import { DefaultLayout } from "@/components/DefaultLayout"; import { Footer } from "@/components/Footer"; import { HorizontalLine } from "@/components/HorizontalLine"; +import { Image } from "@/components/Image"; import { Link } from "@/components/Link"; import { Navbar } from "@/components/Navbar"; import { Pre } from "@/components/Pre"; @@ -35,6 +36,7 @@ export default function App({ Component, pageProps }: AppProps): JSX.Element { button: Button, pre: Pre, inlineCode: Code, + img: Image, }} >
-- 2.39.2 From 8ed72bf61b0cedf1eeffbee657cc3b748d7d10f9 Mon Sep 17 00:00:00 2001 From: Aditya Thakral Date: Fri, 27 Aug 2021 23:30:42 -0400 Subject: [PATCH 2/3] Mobile event card --- components/EventCard.module.css | 70 ++++++++++++++++++++- components/EventCard.tsx | 23 ++++++- components/EventSetting.module.css | 2 +- components/playground.tsx | 24 ++++--- lib/events.ts | 10 ++- pages/events/[year]/[term]/[event].tsx | 1 + pages/events/[year]/[term]/index.module.css | 10 ++- pages/events/[year]/[term]/index.tsx | 1 + 8 files changed, 119 insertions(+), 22 deletions(-) diff --git a/components/EventCard.module.css b/components/EventCard.module.css index 714c609a..1fa1408e 100644 --- a/components/EventCard.module.css +++ b/components/EventCard.module.css @@ -2,7 +2,7 @@ display: flex; flex-direction: row; box-sizing: border-box; - padding: calc(24rem / 16); + padding: calc(20rem / 16) 0; } .card aside { @@ -12,10 +12,10 @@ .card aside img { width: 100%; - margin-bottom: 1rem; } .registerButton { + margin-top: 1rem; font-weight: bold; } @@ -44,3 +44,69 @@ font-size: 1rem; margin-bottom: calc(14rem / 16); } + +.mobileLearnMore { + display: none; +} + +@media only screen and (max-width: calc(768rem / 16)) { + .card { + flex-direction: column; + } + + .card aside { + margin: 0; + } + + .card aside img { + box-sizing: border-box; + border: calc(1rem / 16) solid var(--text); + } + + .content { + margin-top: 1rem; + } + + .content { + text-align: center; + } + + .content > h1, + .content > h2 { + font-size: 1rem; + line-height: calc(30 / 16); + } + + .content > h2 { + margin-bottom: 0; + } + + .mobileShowDescriptionContent { + text-align: unset; + } + + .mobileShowDescriptionContent > h1 { + font-size: calc(24rem / 16); + margin-bottom: calc(8rem / 16); + } + + .registerButton { + display: block; + } + + .mobileLearnMore { + display: unset; + } + + .mobileShowDescriptionContent .mobileLearnMore { + display: none; + } + + .children { + display: none; + } + + .mobileShowDescriptionContent .children { + display: unset; + } +} diff --git a/components/EventCard.tsx b/components/EventCard.tsx index 193b8ff3..e9e5eaec 100644 --- a/components/EventCard.tsx +++ b/components/EventCard.tsx @@ -3,10 +3,11 @@ import React, { ReactNode } from "react"; import { Button } from "./Button"; import { EventSetting } from "./EventSetting"; import { Image } from "./Image"; +import { Link } from "./Link"; import styles from "./EventCard.module.css"; -interface EventCardProps { +interface BaseProps { name: string; short: string; date: Date; @@ -17,7 +18,12 @@ interface EventCardProps { children: ReactNode; } +type EventCardProps = + | (BaseProps & { showDescription?: false; link: string }) + | (BaseProps & { showDescription: true; link?: string }); + export function EventCard({ + link, name, date, online, @@ -25,6 +31,7 @@ export function EventCard({ poster, registerLink, children, + showDescription = false, }: EventCardProps) { return (
@@ -43,12 +50,22 @@ export function EventCard({ )} )} -
+

{name}

-
{children}
+ {!showDescription && link && ( + + Learn more + + )} +
{children}
{!poster && registerLink && (