Skip to content

Commit

Permalink
Merge pull request #365 from danskernesdigitalebibliotek/DDFFORM-17-b…
Browse files Browse the repository at this point in the history
…eskrivelse

Add `EventDescription` component + Refactor `ListDescription` component
  • Loading branch information
kasperbirch1 authored Dec 7, 2023
2 parents 00ec24b + 58ed879 commit 89f3a1a
Show file tree
Hide file tree
Showing 10 changed files with 248 additions and 44 deletions.
1 change: 1 addition & 0 deletions base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
@import "./src/stories/Library/article-header/article-header";
@import "./src/stories/Library/event-header/event-header";
@import "./src/stories/Library/image-credited/image-credited";
@import "./src/stories/Library/event-description/event-description";

// Autosuggest block styling needs to be loaded before the rest of the scss for autosuggest
@import "./src/stories/Blocks/autosuggest/autosuggest";
Expand Down
74 changes: 74 additions & 0 deletions src/stories/Blocks/event-page/EventPage.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,80 @@ export default {
"https://plus.unsplash.com/premium_photo-1696886122527-e4303b76aa8f?q=80&w=5156&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
type: "string",
},
descriptionTitle: {
defaultValue: "Beskrivelse",
type: "string",
},
descriptionDescription: {
defaultValue: `Foreningen for Integreret Moderne Dans arbejder med at udvide
normalitetsbegrebet i scenekunsten. For hvad er normalt? Rosenreglen og
Mødrenes hus. I 2022 udgav hun også den stærkt politiske digtsamling Jeg
vil have en statsminister.`,
type: "string",
},
horizontalTermLineData: {
defaultValue: [
{
title: "I samme serie ",
linkList: [
{
text: "Litteratur & Aktivisme",
url: "/",
},
],
},
{
title: "Emneord",
linkList: [
{
text: "dans",
url: "/",
},
{
text: "contemporary",
url: "/",
},
{
text: "modern",
url: "/",
},
{
text: "scenekunst",
url: "/",
},
{
text: "digt",
url: "/",
},
{
text: "3-8 årige",
url: "/",
},
],
},
],
},
listDescriptionData: {
defaultValue: {
Tid: { value: ["19:30 — 21:00"], type: "standard" },
Standard: { value: ["65 kr."], type: "standard" },
Børn: { value: ["Gratis"], type: "standard" },
Sted: {
value: [
"Hovedbibliotek",
"Greve bibliotek",
"Hovedbibliotek",
"Greve bibliotek",
],
type: "link",
},
Adresse: {
value: ["Kampmanns Plads 2, 8000, Aarhus"],
type: "standard",
},
Målgruppe: { value: ["Alle"], type: "standard" },
},
},
},
parameters: {
design: {
Expand Down
21 changes: 19 additions & 2 deletions src/stories/Blocks/event-page/EventPage.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
import { FC } from "react";
import EventHeader from "../../Library/event-header/EventHeader";
import EventDescription, {
EventDescriptionProps,
} from "../../Library/event-description/EventDescription";

type EventPageProps = {
title: string;
date: string;
image: string;
};
} & EventDescriptionProps;

const EventPage: FC<EventPageProps> = ({ title, date, image }) => {
const EventPage: FC<EventPageProps> = ({
title,
date,
image,
descriptionTitle,
descriptionDescription,
horizontalTermLineData,
listDescriptionData,
}) => {
return (
<article className="event-page">
<EventHeader title={title} date={date} image={image} />
<EventDescription
descriptionTitle={descriptionTitle}
descriptionDescription={descriptionDescription}
horizontalTermLineData={horizontalTermLineData}
listDescriptionData={listDescriptionData}
/>
</article>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ const Template: ComponentStory<typeof MaterialMainfestationItem> = (args) => {
export const Item = Template.bind({});
Item.args = {
detailsData: {
Type: { value: "Bog", type: "standard" },
Sprog: { value: "Dansk", type: "standard" },
Bidragsydere: { value: "Karsten Sand Iversen", type: "link" },
Originaltitel: { value: "Ulysses (1922)", type: "standard" },
ISBN: { value: "9788763814584", type: "standard" },
Udgave: { value: "Udgave, 2. oplag (2015)", type: "standard" },
Omfang: { value: "795 sider", type: "standard" },
Forlag: { value: "Rosinante", type: "standard" },
Målgruppe: { value: "Voksenmateriale", type: "standard" },
Type: { value: ["Bog"], type: "standard" },
Sprog: { value: ["Dansk"], type: "standard" },
Bidragsydere: { value: ["Karsten Sand Iversen"], type: "link" },
Originaltitel: { value: ["Ulysses (1922)"], type: "standard" },
ISBN: { value: ["9788763814584"], type: "standard" },
Udgave: { value: ["Udgave, 2. oplag (2015)"], type: "standard" },
Omfang: { value: ["795 sider"], type: "standard" },
Forlag: { value: ["Rosinante"], type: "standard" },
Målgruppe: { value: ["Voksenmateriale"], type: "standard" },
},
};
17 changes: 11 additions & 6 deletions src/stories/Library/Lists/list-description/ListDescription.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Fragment } from "react";
import { generateId } from "../../horizontal-term-line/HorizontalTermLine";

export type ListData = {
[k: string]: { value: string; type: "standard" | "link" };
[k: string]: { value: string[]; type: "standard" | "link" };
};

const ListDescription: React.FC<{ data: ListData; className?: string }> = ({
Expand All @@ -13,11 +14,15 @@ const ListDescription: React.FC<{ data: ListData; className?: string }> = ({
{Object.keys(data).map((key, index) => {
const { value, type } = data[key as keyof ListData];
return (
<div key={generateId(index)}>
<dt>{key}:</dt>
<dd>
{type === "standard" && value}
{type === "link" && <span className="link-tag">{value}</span>}
<div className="list-description__item" key={generateId(index)}>
<dt className="list-description__key">{key}:</dt>
<dd className="list-description__value">
{value.map((val) => (
<Fragment key={val}>
{type === "standard" && <span>{val}</span>}
{type === "link" && <span className="link-tag">{val}</span>}
</Fragment>
))}
</dd>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { ListData } from "./ListDescription";

const fakeData: ListData = {
Type: { value: "Bog", type: "standard" },
Sprog: { value: "Dansk", type: "standard" },
Bidragsydere: { value: "Karsten Sand Iversen", type: "link" },
Originaltitel: { value: "Ulysses (1922)", type: "standard" },
ISBN: { value: "9788763814584", type: "standard" },
Udgave: { value: "Udgave, 2. oplag (2015)", type: "standard" },
Omfang: { value: "795 sider", type: "standard" },
Forlag: { value: "Rosinante", type: "standard" },
Målgruppe: { value: "Voksenmateriale", type: "standard" },
Type: { value: ["Bog"], type: "standard" },
Sprog: { value: ["Dansk"], type: "standard" },
Bidragsydere: { value: ["Karsten Sand Iversen"], type: "link" },
Originaltitel: { value: ["Ulysses (1922)"], type: "standard" },
ISBN: { value: ["9788763814584"], type: "standard" },
Udgave: { value: ["Udgave, 2. oplag (2015)"], type: "standard" },
Omfang: { value: ["795 sider"], type: "standard" },
Forlag: { value: ["Rosinante"], type: "standard" },
Målgruppe: { value: ["Voksenmateriale"], type: "standard" },
};

export default fakeData;
55 changes: 39 additions & 16 deletions src/stories/Library/Lists/list-description/list-description.scss
Original file line number Diff line number Diff line change
@@ -1,30 +1,53 @@
dl.list-description {
@extend %text-small-caption;

max-width: 420px;
color: $c-text-secondary-gray;
display: flex;
flex-flow: column;

& > div {
display: flex;
flex-flow: row wrap;
.list-description__item {
display: grid;
grid-template-columns: 1fr 2fr;
}

dt {
flex-basis: 18%;
.list-description__key,
.list-description__value {
padding: 2px 4px;
}

dd {
flex-basis: 72%;
flex-grow: 1;
margin: 0;
padding: 2px 4px;
.list-description__value {
display: grid;
@include breakpoint-s {
display: flex;
flex-wrap: wrap;
gap: $s-sm;
}
}
.link-tag {
@extend %text-small-caption;
color: $c-text-primary-black;
}
}

dl.list-description.list-description--event {
height: max-content;
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: $s-md;
align-items: start;

.list-description__item {
grid-template-columns: 1fr;
}

.list-description__value {
font-weight: bold;
}

.link-tag {
@extend %text-small-caption;
@include breakpoint-s {
grid-template-columns: 1fr;
gap: $s-xs;

color: $c-text-primary-black;
.list-description__item {
grid-template-columns: 1fr 2fr;
}
}
}
44 changes: 44 additions & 0 deletions src/stories/Library/event-description/EventDescription.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { FC } from "react";
import HorizontalTermLine, {
HorizontalTermLineProps,
generateId,
} from "../horizontal-term-line/HorizontalTermLine";
import ListDescription, {
ListData,
} from "../Lists/list-description/ListDescription";

export type EventDescriptionProps = {
descriptionTitle: string;
listDescriptionData: ListData;
horizontalTermLineData: HorizontalTermLineProps[];
descriptionDescription: string;
};

const EventDescription: FC<EventDescriptionProps> = ({
descriptionTitle,
descriptionDescription,
horizontalTermLineData,
listDescriptionData,
}) => {
return (
<section className="event-description">
<h2 className="event-description__title">{descriptionTitle}</h2>
<div className="event-description__content">
<p className="event-description__description">
{descriptionDescription}
</p>
<div className="event-description__links">
{horizontalTermLineData.map((item, index) => (
<HorizontalTermLine {...item} key={generateId(index)} />
))}
</div>
</div>
<ListDescription
className="event-description__info list-description--event"
data={listDescriptionData}
/>
</section>
);
};

export default EventDescription;
38 changes: 38 additions & 0 deletions src/stories/Library/event-description/event-description.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.event-description {
@include container(medium);
padding: $s-md;
@include breakpoint-s {
padding: $s-xl $s-4xl;
display: grid;
column-gap: $s-xl;
grid-template-columns: 2fr 1fr;
}
}

.event-description__title {
@extend %text-header-h4;
margin-bottom: $s-md;

@include breakpoint-s {
grid-column: 1 / -1;
margin-bottom: $s-lg;
}
}

.event-description__description {
@extend %text-body-large;
line-height: 24px;
margin-bottom: $s-md;

@include breakpoint-s {
line-height: 32px;
}
}

.event-description__links {
margin-bottom: $s-2xl;

@include breakpoint-s {
margin-bottom: 0;
}
}
6 changes: 4 additions & 2 deletions src/stories/Library/event-header/event-header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
}

.event-header__content {
padding-top: $s-md;
display: grid;
grid-template-columns: $s-3xl 1fr $s-3xl;
grid-template-areas:
Expand All @@ -29,16 +30,17 @@
"btn btn btn";

@include breakpoint-s {
padding-top: $s-3xl;
grid-template-columns: 1fr;
}
}

.event-header__tag {
grid-area: tag;
width: max-content;
margin: $s-md 0;
margin-bottom: $s-md;
@include breakpoint-s {
margin: $s-lg 0;
margin-bottom: $s-lg;
}
}

Expand Down

0 comments on commit 89f3a1a

Please sign in to comment.