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

Styles and stories for the event card #10

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
114 changes: 114 additions & 0 deletions src/nationalarchives/components/card/card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

&__heading {
order: 2;

&--has-highlight {
max-width: calc(100% - 5.125rem);
}
}

&__heading-link {
Expand Down Expand Up @@ -84,6 +88,28 @@
}
}

&__tags {
display: flex;
align-self: flex-start;
list-style-type: none;
flex-basis: 50%;
border: 2px solid colour.brand-colour("pastel-pink");
padding: 0;
order: 2;
}

&__tag {
@include typography.relative-font-size(14);
@include typography.detail-font;
text-transform: uppercase;
padding: 0 0.4rem;

&--event-type {
@include colour.fixed;
background-color: colour.brand-colour("pastel-pink");
}
}

&__actions {
margin-top: 2rem;

Expand All @@ -99,6 +125,35 @@
}
}

&__highlight {
@include typography.relative-font-size(14);
@include colour.fixed;
z-index: 1;
border-radius: 50%;
aspect-ratio: 1 / 1;
align-self: flex-end;
position: absolute;
right: 1.14rem;
top: 1.14rem;
display: flex;
align-items: center;
justify-content: center;
padding: 1rem;

@include media.on-larger-than-mobile {
right: 0;
top: auto;
}

&--yellow {
background-color: colour.brand-colour("pastel-orange");
}

&--blue {
background-color: colour.brand-colour("pastel-blue");
}
}

&--contrast,
&--accent {
.tna-card__inner {
Expand Down Expand Up @@ -156,6 +211,18 @@
}
}

&--horizontal-thirds {
@include media.on-larger-than-mobile {
.tna-card__inner {
margin-left: 33.33%;
}

.tna-card__image-container {
inset: 0 66.66% 0 0;
}
}
}

&--horizontal#{&}--contrast,
&--horizontal#{&}--accent {
@include media.on-mobile {
Expand Down Expand Up @@ -191,6 +258,53 @@
}
}

&--event {
.tna-card__inner {
padding-left: 1.5rem;
padding-right: 1.5rem;

@include media.on-larger-than-mobile {
padding: 1rem 2rem 1rem 2.5rem;
}
}

.tna-card__image-container {
margin-left: -1.5rem;
margin-right: -1.5rem;

@include media.on-larger-than-mobile {
margin-left: 0;
margin-right: 0;
}
}

.tna-card__heading {
margin-top: 0;
margin-bottom: 0.75rem;

@include media.on-larger-than-mobile {
@include typography.relative-font-size(30);
}
}

.tna-card__heading-link {
@include colour.colour-font("font-dark");
}

.tna-card__body {
@include typography.relative-font-size(16);
line-height: 1.5;
}

.tna-card__meta {
.fa-solid {
@include colour.fixed;
@include colour.colour-font("keyline");
@include typography.relative-font-size(24);
}
}
}

@include colour.on-high-contrast {
@include colour.colour-border("keyline-dark", 1px);

Expand Down
58 changes: 58 additions & 0 deletions src/nationalarchives/components/card/card.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@ const argTypes = {
htmlElement: { control: "text" },
classes: { control: "text" },
attributes: { control: "object" },
event: { control: "boolean" },
eventType: {
control: "inline-radio",
options: ["Exhibition", "Display", "Talk", "Tour", "Event"],
},
accessDescriptor: {
control: "inline-radio",
options: [
"Speech to text",
"British Sign Language",
"Accessible",
"Autism-friendly",
"",
],
},
highlight: {
control: "inline-radio",
options: ["Sold out", "Opening soon", "Last chance"],
},
highlightColor: { control: "inline-radio", options: ["yellow", "blue"] },
};

Object.keys(argTypes).forEach((argType) => {
Expand Down Expand Up @@ -58,6 +78,11 @@ const Template = ({
htmlElement,
classes,
attributes,
event,
eventType,
accessDescriptor,
highlight,
highlightColor,
}) =>
Card({
params: {
Expand All @@ -81,6 +106,11 @@ const Template = ({
htmlElement,
classes,
attributes,
event,
eventType,
accessDescriptor,
highlight,
highlightColor,
},
});

Expand Down Expand Up @@ -290,6 +320,34 @@ WithoutImage.args = {
classes: "tna-card--demo",
};

export const Event = Template.bind({});
Event.args = {
title: "Behind the Scenes Tours",
href: "#",
headingLevel: 2,
headingSize: "l",
imageSrc:
"https://www.nationalarchives.gov.uk/wp-content/uploads/sites/24/2023/07/tna-building-compress.jpg",
imageAlt: "The National Archives office",
imageWidth: 400,
imageHeight: 243,
label: "",
body: "<p>We are opening the doors of The National Archives’ repositories to offer you the chance to go behind the scenes.</p>",
highlight: "Sold out",
highlightColor: "yellow",
meta: [
{ text: "24th September 2023", icon: "calendar" },
{ text: "From £16", icon: "ticket" },
{ text: "Online", icon: "location-dot" },
],
horizontal: true,
event: true,
eventType: "Exhibition",
accessDescriptor: "Autism-friendly",
htmlElement: "article",
classes: "tna-card--event tna-card--horizontal-thirds",
};

const GridTemplate = ({
title,
supertitle,
Expand Down
19 changes: 18 additions & 1 deletion src/nationalarchives/components/card/template.njk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@
{%- endif -%}
<{{ htmlElement }} class="tna-card {{ containerClasses | join(' ') }}" data-module="tna-card" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
<div class="tna-card__inner">
{%- if params.event -%}
{%- if params.eventType or params.accessDescriptor -%}
<ul class="tna-card__tags">
{%- if params.eventType -%}
<li class="tna-card__tag tna-card__tag--event-type">{{ params.eventType }}</li>
{%- endif -%}
{%- if params.accessDescriptor -%}
<li class="tna-card__tag tna-card__tag--access">{{ params.accessDescriptor }}</li>
{%- endif -%}
</ul>
{%- endif -%}
{%- endif -%}
{%- if params.supertitle -%}
<hgroup class="tna-hgroup tna-hgroup--{{ params.headingSize or 'm' }} tna-card__heading">
<h{{ params.headingLevel }} class="tna-hgroup__title">
Expand All @@ -22,14 +34,19 @@
</h{{ params.headingLevel }}>
</hgroup>
{%- else -%}
<h{{ params.headingLevel }} class=" tna-heading tna-heading--{{ params.headingSize or 'm' }} tna-card__heading">
<h{{ params.headingLevel }} class=" tna-heading tna-heading--{{ params.headingSize or 'm' }} tna-card__heading {% if params.highlight %}tna-card__heading--has-highlight{% endif %}" >
{%- if params.href -%}
<a href="{{ params.href }}" class="tna-card__heading-link">{{ params.title }}</a>
{%- else -%}
{{ params.title }}
{%- endif -%}
</h{{ params.headingLevel }}>
{%- endif -%}
{%- if params.highlight and params.highlightColor -%}
<div class="tna-card__highlight tna-card__highlight--{{ params.highlightColor }}">
{{ params.highlight }}
</div>
{%- endif -%}
{%- if params.imageSrc -%}
{%- if params.href -%}
<a href="{{ params.href }}" class="tna-card__image-container" tabindex="-1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,30 @@ const Template = ({ theme, accent }) => {
...cardDefaultOptions,
horizontal: true,
style: "accent",
classes: "tna-!--margin-bottom-m",
},
})}
</div>
<div class="tna-column tna-column--width-2-3 tna-column--full-medium tna-column--full-small tna-column--full-tiny">
${Card({
params: {
...cardDefaultOptions,
highlight: "Sold out",
highlightColor: "yellow",
meta: [
{ text: "24th September 2023", icon: "calendar" },
{ text: "From £16", icon: "ticket" },
{ text: "Online", icon: "location-dot" },
],
horizontal: true,
event: true,
eventType: "Exhibition",
accessDescriptor: "Autism-friendly",
htmlElement: "article",
classes: "tna-card--event tna-card--horizontal-thirds",
supertitle: "",
actions: [],
label: "",
},
})}
</div>
Expand Down