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

Finish main page hero #112

Merged
merged 20 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 17 additions & 1 deletion src/components/common/Typography/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Link from 'next/link';
import { CSSProperties, HTMLAttributes, PropsWithChildren } from 'react';

// v1 variants
Expand Down Expand Up @@ -25,7 +26,7 @@ function isStandardVariant(variant: V2Variant): variant is V2StandardVariant {
// shared
type Variant = V1Variant | V2Variant;

type ComponentType = Heading | 'p' | 'span' | 'div' | 'a';
type ComponentType = Heading | 'p' | 'span' | 'div';

function isV1Variant(variant: Variant): variant is V1Variant {
return HEADINGS.some(h => h === variant.split('/')[0]);
Expand Down Expand Up @@ -232,6 +233,21 @@ const variantToCSS = (variant: Variant): CSSProperties => {
const Typography = (props: PropsWithChildren<TypographyProps>) => {
const { variant, component, style, children, ...restProps } = props;

if (restProps.href) {
return (
alexzhang1618 marked this conversation as resolved.
Show resolved Hide resolved
<Link
href={restProps.href}
style={{
...variantToCSS(variant),
...style, // other styles can be customized via style prop
}}
{...restProps}
>
{children}
</Link>
);
}

const Component = component || 'div';

return (
Expand Down
15 changes: 4 additions & 11 deletions src/components/home/Hero/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,14 @@ const Hero = ({ firstName, points, checkin }: HeroProps) => {
<div className={styles.header}>
<Typography variant="display/light/medium" className={styles.heading} component="span">
{'Welcome to ACM, '}
<Typography
variant="display/heavy/medium"
className={styles.heading}
component="a"
href={config.profileRoute}
>
{firstName}
</Typography>
<strong>
<Link href={config.profileRoute}>{firstName}</Link>
</strong>
!
</Typography>
<Typography variant="h4/regular" component="span" className={styles.subheading}>
{'You have '}
<Typography variant="h4/bold" component="span" className={styles.subheading}>
{points}
</Typography>
<strong>{points}</strong>
{' membership points.'}
</Typography>
</div>
Expand Down
6 changes: 0 additions & 6 deletions src/components/home/Hero/style.module.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
@use 'src/styles/vars.scss' as vars;

.inline {
display: inline;
}

@media screen and (width <= vars.$breakpoint-md) {
.subheading {
font-size: 1rem !important;
alexzhang1618 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -37,8 +33,6 @@
gap: 0.5rem;

.heading {
display: inline;

@media screen and (width <= vars.$breakpoint-md) {
font-size: 2rem !important;
line-height: 2.5rem !important;
Expand Down
1 change: 0 additions & 1 deletion src/components/home/Hero/style.module.scss.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export type Styles = {
heading: string;
hero: string;
image: string;
inline: string;
link: string;
mobile: string;
subheading: string;
Expand Down