Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Commit

Permalink
Add CSS and stories for Article, ArticleHeader, ArrowLink, `Row…
Browse files Browse the repository at this point in the history
…Button`
  • Loading branch information
kasperbirch1 committed Nov 22, 2023
1 parent 66e24ba commit 50f8b30
Show file tree
Hide file tree
Showing 12 changed files with 295 additions and 0 deletions.
4 changes: 4 additions & 0 deletions base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@
@import "./src/stories/Library/multiselect/multiselect";
@import "./src/stories/Library/input-with-dropdown/input-with-dropdown";
@import "./src/stories/Library/button-box/button-box";
@import "./src/stories/Library/links/arrow-link/arrow-link";
@import "./src/stories/Library/Buttons/row-button/row-button";
@import "./src/stories/Library/article-header/article-header";

// Autosuggest block styling needs to be loaded before the rest of the scss for autosuggest
@import "./src/stories/Blocks/autosuggest/autosuggest";
Expand All @@ -110,6 +113,7 @@
@import "./src/stories/Blocks/status-userprofile/status-userprofile";
@import "./src/stories/Blocks/material-manifestation-item/material-manifestation-item";
@import "./src/stories/Blocks/advanced-search/advanced-search";
@import "./src/stories/Blocks/article/article";

@import "./src/styles/scss/shared";
@import "./src/styles/scss/internal";
Expand Down
39 changes: 39 additions & 0 deletions src/stories/Blocks/article/Article.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { ComponentStory, ComponentMeta } from "@storybook/react";
import { withDesign } from "storybook-addon-designs";
import Article from "./Article";

export default {
title: "Blocks / Article",
component: Article,
decorators: [withDesign],
argTypes: {
title: {
defaultValue: "Jesper Stein vinder Læsernes Bogpris for Rampen’",
},
subtitle: {
defaultValue:
"Jesper Stein har begået en hudløst ærlig og tankevækkende skildring af en skilsmisseramt familie. En selvbiografisk roman, som har ramt læserne i hjertet.",
},
library: {
defaultValue: "Af biblioteksformidler på Hovedbiblioteket",
},
author: {
defaultValue: "Lene Kuhlmann Frandsen",
},
date: {
defaultValue: "08. April 21",
},
},
parameters: {
design: {
type: "figma",
url: "https://www.figma.com/file/Zx9GrkFA3l4ISvyZD2q0Qi/Designsystem?type=design&node-id=7477%3A39048&mode=dev",
},
},
} as ComponentMeta<typeof Article>;

const Template: ComponentStory<typeof Article> = (args) => (
<Article {...args} />
);

export const Default = Template.bind({});
32 changes: 32 additions & 0 deletions src/stories/Blocks/article/Article.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { FC } from "react";
import ArticleHeader from "../../Library/article-header/ArticleHeader";

type ArticleProps = {
title: string;
subtitle: string;
library: string;
author: string;
date: string;
};

const Article: FC<ArticleProps> = ({
title,
subtitle,
library,
author,
date,
}) => {
return (
<article className="article">
<ArticleHeader
title={title}
subtitle={subtitle}
author={author}
library={library}
date={date}
/>
</article>
);
};

export default Article;
3 changes: 3 additions & 0 deletions src/stories/Blocks/article/article.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.article {
background-color: $c-global-primary;
}
37 changes: 37 additions & 0 deletions src/stories/Library/Buttons/row-button/RowButton.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { ComponentStory, ComponentMeta } from "@storybook/react";
import { withDesign } from "storybook-addon-designs";
import RowButton from "./RowButton";

export default {
title: "Library / Buttons / RowButton",
component: RowButton,
decorators: [withDesign],
argTypes: {
labels: {
defaultValue: ["Netmedier"],
},
},
parameters: {
design: {
type: "figma",
url: "https://www.figma.com/file/Zx9GrkFA3l4ISvyZD2q0Qi/Designsystem?type=design&node-id=7880%3A59070&mode=dev",
},
layout: "centered",
},
} as ComponentMeta<typeof RowButton>;

const Template: ComponentStory<typeof RowButton> = (args) => (
<RowButton {...args} />
);

export const Default = Template.bind({});

export const TwoButtons = Template.bind({});
TwoButtons.args = {
labels: ["Netmedier", "Licenser"],
};

export const ThreeAndMoreButtons = Template.bind({});
ThreeAndMoreButtons.args = {
labels: ["Netmedier", "Licenser", "This is hiddden"],
};
30 changes: 30 additions & 0 deletions src/stories/Library/Buttons/row-button/RowButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import clsx from "clsx";
import { FC } from "react";

type RowButtonProps = {
labels: string[];
className?: string;
};

const RowButton: FC<RowButtonProps> = ({ labels, className }) => (
<div className={clsx("row-buttons", className)}>
{labels.slice(0, 2).map((label) => (
<button
className="row-button text-tags row-button__text capitalize-all"
type="button"
>
{label}
</button>
))}
{labels.length > 2 && (
<button
className="row-button text-tags row-button__text capitalize-all"
type="button"
>
...
</button>
)}
</div>
);

export default RowButton;
20 changes: 20 additions & 0 deletions src/stories/Library/Buttons/row-button/row-button.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.row-buttons {
display: flex;
flex-direction: row;
}

.row-button {
height: 40px;
background-color: $c-global-secondary;
padding: 9px $s-md;
display: flex;
align-items: center;

& + .row-button {
margin-left: $s-sm;
}

&:hover {
cursor: pointer;
}
}
37 changes: 37 additions & 0 deletions src/stories/Library/article-header/ArticleHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { FC } from "react";
import RowButton from "../Buttons/row-button/RowButton";
import ArrowLink from "../links/arrow-link/ArrowLink";

type ArticleHeaderProps = {
title: string;
subtitle: string;
library: string;
author: string;
date: string;
};

const ArticleHeader: FC<ArticleHeaderProps> = ({
title,
subtitle,
library,
author,
date,
}) => {
return (
<header className="article-header">
<ArrowLink label="Go back" className="article-header__back-link" />
<h1 className="text-header-h1 article-header__title">{title}</h1>
<p className="text-subtitle article-header__subtitle">{subtitle}</p>
<p className="article-header__info text-body-small-regular">
<span>{library}</span>
<a href="/">
<span className="link-tag text-body-small-regular">{author}</span>
</a>
<span className="article-header__info__date">{date}</span>
</p>
<RowButton labels={["Netmedier", "Licenser", "This is hiddden"]} />
</header>
);
};

export default ArticleHeader;
38 changes: 38 additions & 0 deletions src/stories/Library/article-header/article-header.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.article-header {
display: grid;
gap: $s-xl;
padding: $s-4xl $s-xl;
position: relative;

@include breakpoint-s {
padding: $s-4xl $s-7xl;
}

&__back-link {
position: absolute;
left: $s-md;
top: $s-sm;

@include breakpoint-s {
left: $s-2xl;
top: $s-lg;
}
}

&__title,
&__subtitle {
@include breakpoint-s {
max-width: 897px;
}
}

&__info {
display: flex;
align-items: baseline;
gap: $s-xs;

&__date {
margin-left: $s-xs;
}
}
}
27 changes: 27 additions & 0 deletions src/stories/Library/links/arrow-link/ArrowLink.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { ComponentStory, ComponentMeta } from "@storybook/react";
import { withDesign } from "storybook-addon-designs";
import ArrowLink from "./ArrowLink";

export default {
title: "Library / Links / ArrowLink",
component: ArrowLink,
decorators: [withDesign],
argTypes: {
label: {
defaultValue: "Go back",
},
},
parameters: {
design: {
type: "figma",
url: "https://www.figma.com/file/Zx9GrkFA3l4ISvyZD2q0Qi/Designsystem?type=design&node-id=7477%3A39098&mode=dev",
},
layout: "centered",
},
} as ComponentMeta<typeof ArrowLink>;

const Template: ComponentStory<typeof ArrowLink> = (args) => (
<ArrowLink {...args} />
);

export const Default = Template.bind({});
21 changes: 21 additions & 0 deletions src/stories/Library/links/arrow-link/ArrowLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import clsx from "clsx";
import { ReactComponent as ArrowSmallLeft } from "../../Arrows/icon-arrow-ui/icon-arrow-ui-small-left.svg";

type ArrowLinkProps = {
label: string;
className: string;
};

const ArrowLink: React.FC<ArrowLinkProps> = ({ label, className }) => {
return (
<a
href="/"
className={clsx("arrow arrow__hover--left-small arrow-link", className)}
>
<div className="text-links arrow-link__text">{label}</div>
<ArrowSmallLeft />
</a>
);
};

export default ArrowLink;
7 changes: 7 additions & 0 deletions src/stories/Library/links/arrow-link/arrow-link.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.arrow-link {
display: block;
text-decoration: none;
&__text {
margin-bottom: -5px;
}
}

0 comments on commit 50f8b30

Please sign in to comment.