Skip to content

Commit

Permalink
chore(storefront): add CSS tokens and clean code for layouts (#796)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thunear authored and Magnusrm committed Sep 27, 2023
1 parent bfb6591 commit 2f0e914
Show file tree
Hide file tree
Showing 18 changed files with 220 additions and 449 deletions.
102 changes: 54 additions & 48 deletions storefront/components/MdxContent/MdxContent.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,15 @@
}

.content > p {
font-size: 18px;
line-height: 1.55em;
margin-bottom: 20px;
font: var(--fds-typography-paragraph-medium);
margin-bottom: var(--fds-spacing-5);
}

/* A <p> tag that comes directly after <h1> will be treated as an ingress */
.content h1 + p {
font-size: 24px;
line-height: 1.7em;
margin-bottom: 36px;
}

.content > h2 {
margin-top: 40px;
margin-bottom: 16px;
line-height: 1.3em;
font-size: 28px;
}

.content > h3 {
margin-top: 40px;
margin-bottom: 16px;
line-height: 1.3em;
font-size: 24px;
}

.content > h4 {
margin-top: 40px;
margin-bottom: 16px;
line-height: 1.3em;
font-size: 20px;
font: var(--fds-typography-ingress-medium);
margin-top: 0;
margin-bottom: var(--fds-spacing-8);
}

/* Heading styling with anchor link */
Expand All @@ -53,6 +32,32 @@
margin-left: -26px;
}

.content > h2,
.content > h3,
.content > h4 {
margin-top: var(--fds-spacing-10);
margin-bottom: var(--fds-spacing-3);
}

.content > h1 {
margin-top: 0;
margin-bottom: var(--fds-spacing-4);
font: var(--fds-typography-heading-xlarge);
}

.content > h2 {
font: var(--fds-typography-heading-large);
}

.content > h3 {
font: var(--fds-typography-heading-medium);
}

.content > h4 {
font: var(--fds-typography-heading-small);
}

/* Anchor link styling */
.content > h1 a,
.content > h2 a,
.content > h3 a,
Expand All @@ -65,20 +70,23 @@
transition: 0.08s all;
}

/* Anchor link styling for <h1> */
.content > h1 a {
height: 24px;
width: 24px;
margin-top: -2px;
left: -4px;
}

/* Styling for links */
.content > p > a,
.content > ul > li a,
.content > ol > li a {
color: #0062ba;
color: var(--fds-semantic-text-action-default);
text-underline-offset: 4px;
}

/* Anchor links appear on heading hover */
.content > h1:hover a,
.content > h2:hover a,
.content > h3:hover a,
Expand All @@ -88,26 +96,26 @@

.content img {
width: 100%;
margin: 24px 0;
border-radius: 2px;
box-shadow: 0 2px 4px rgba(0 0 0 / 0.1);
margin: var(--fds-spacing-5) 0;
border-radius: var(--fds-border_radius-medium);
box-shadow: var(--fds-shadow-medium);
}

.content strong {
margin-top: 8px;
display: inline-block;
margin-top: var(--fds-spacing-1);
font-weight: 500;
}

.content > ul > li,
.content > ol > li {
font-size: 18px;
font: var(--fds-typography-paragraph-medium);
line-height: 1.9em;
}

.content > ul > li > ol,
.content > ol > li > ul {
margin-top: 8px;
margin-top: var(--fds-spacing-1);
}

.content > p > a:hover,
Expand All @@ -117,35 +125,33 @@
}

.content pre {
background-color: #f4f4f4;
padding: 20px;
border-radius: 4px;
margin: 32px 0;
background-color: var(--fds-semantic-background-subtle);
padding: var(--fds-spacing-5);
margin: var(--fds-spacing-7) 0;
border-radius: var(--fds-border_radius-medium);
}

.content > iframe {
box-shadow: 0 2px 4px rgba(0 0 0 / 0.2);
border-radius: 4px;
margin: 24px 0;
box-shadow: var(--fds-shadow-medium);
margin: var(--fds-spacing-5);
border-radius: var(--fds-border_radius-medium);
}

.content > table {
border-collapse: collapse;
width: 100%;
margin: 32px 0;
margin: var(--fds-spacing-7) 0;
border-collapse: collapse;
}

.content > table td,
.content > table th {
border: 1px solid #ddd;
padding: 16px;
padding: var(--fds-spacing-4);
border: 1px solid var(--fds-semantic-border-neutral-subtle);
}

.content > table th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #f4f4f4;
background-color: var(--fds-semantic-background-subtle);
font-weight: 600;
}

Expand Down
1 change: 1 addition & 0 deletions storefront/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
--grid-gap: var(--spacing-5);
--page-spacing-top: var(--spacing-7);
--page-spacing-bottom: var(--spacing-7);
--page-gap: var(--fds-spacing-7);
--preview-min-height: 81px;
}

Expand Down
23 changes: 0 additions & 23 deletions storefront/layouts/FrontpageLayout/FrontpageLayout.module.css

This file was deleted.

67 changes: 5 additions & 62 deletions storefront/layouts/FrontpageLayout/FrontpageLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,68 +1,11 @@
import React from 'react';

import {
Section,
NavigationCard,
Banner,
ImageSection,
} from '../../components';
import type { NavigationCardProps, ImageSectionProps } from '../../components';

interface FrontpageLayoutProps {
Content: React.ReactNode;
data: FrontpageData;
}

interface FrontpageData {
title: string;
description: string;
navigationCards: {
title: string;
description: string;
items: [];
};
contributeSection: ImageSectionProps;
}

const FrontpageLayout = ({ Content, data }: FrontpageLayoutProps) => {
return (
<main id='main'>
{Content}
<div className='max-width-container main'>
<Banner
title={data.title}
desc={data.description}
/>

<Section title={data.navigationCards.title}>
{data.navigationCards.items.map(
(item: NavigationCardProps, index: number) => (
<NavigationCard
key={index}
url={item.url}
title={item.title}
color={item.color}
icon={item.icon}
description={item.description}
/>
),
)}
</Section>
type FrontpageLayoutProps = {
content: React.ReactNode;
};

<ImageSection
title={data.contributeSection.title}
description={data.contributeSection.description}
imgSrc={data.contributeSection.imgSrc}
imgAlt={data.contributeSection.imgAlt}
headingLevel={data.contributeSection.headingLevel}
imgWidth={data.contributeSection.imgWidth}
imgHeight={data.contributeSection.imgHeight}
buttons={data.contributeSection.buttons}
/>
</div>
</main>
);
const FrontpageLayout = ({ content }: FrontpageLayoutProps) => {
return <main id='main'>{content}</main>;
};

export { FrontpageLayout };
export type { FrontpageData };
54 changes: 19 additions & 35 deletions storefront/layouts/MenuPageLayout/MenuPageLayout.module.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.page {
margin-top: var(--page-spacing-top);
margin-bottom: var(--page-spacing-bottom);
display: flex;
justify-content: space-between;
flex-wrap: wrap;
gap: var(--spacing-5);
gap: var(--page-gap);
margin-top: var(--page-spacing-top);
margin-bottom: var(--page-spacing-bottom);
}

.left {
Expand All @@ -17,56 +17,40 @@
flex-grow: 500;
}

.title {
font-size: 36px;
margin-bottom: 0;
line-height: 1.3em;
}

.desc {
font-size: 18px;
line-height: 1.6em;
margin-bottom: -10px;
}

.header {
padding: 32px;
margin-bottom: 32px;
background-color: #f4f4f4;
border-radius: 8px;
width: 100%;
position: relative;
overflow: hidden;
margin-bottom: var(--fds-spacing-6);
padding: var(--fds-spacing-7);
width: 100%;
border-radius: var(--fds-border_radius-large);
background-color: var(--fds-semantic-background-subtle);
}

.header::after {
content: '';
position: absolute;
right: -0;
bottom: -200px;
transform: rotate(25deg);
content: '';
opacity: 0.2;
height: 250px;
width: 250px;
border-radius: 8px;
border: 8px solid #1e98f5;
opacity: 0.15;
border-radius: var(--fds-border_radius-large);
border: 8px solid var(--fds-brand-tertiary-600);
}

.date {
margin-top: 12px;
font-size: 16px;
.title {
margin-bottom: 0;
font: var(--fds-typography-heading-xlarge);
}

.content {
position: relative;
display: flex;
width: 100%;
.date {
margin-top: var(--fds-spacing-3);
}

.content aside {
position: sticky;
top: 0;
height: 400px;
.content {
padding: var(--fds-spacing-4) var(--fds-spacing-7) 0 var(--fds-spacing-7);
}

@media (max-width: 576px) {
Expand Down
5 changes: 2 additions & 3 deletions storefront/layouts/MenuPageLayout/MenuPageLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import { Container, SidebarMenu, MdxContent } from '../../components';

import classes from './MenuPageLayout.module.css';

interface PageLayoutProps {
type PageLayoutProps = {
content: React.ReactNode;
data: PageLayoutData;
}
};

type PageLayoutData = {
title: string;
date: string;
showMenu: boolean;
};

const MenuPageLayout = ({ content, data }: PageLayoutProps) => {
Expand Down
Loading

0 comments on commit 2f0e914

Please sign in to comment.