Skip to content

Commit

Permalink
Add card & tag components
Browse files Browse the repository at this point in the history
  • Loading branch information
ediblecode committed Nov 24, 2017
1 parent 996ae71 commit cb3352b
Show file tree
Hide file tree
Showing 12 changed files with 301 additions and 50 deletions.
30 changes: 30 additions & 0 deletions server/views/components/card.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% extends "layouts/_layout.njk" %}
{% set title = "CTA bar" %}
{% from "card/card.njk" import card %}

{% block body %}

<div class="container">

<h1>Card</h1>

{{ card({ heading: { text: "This is a card heading" }, href: "https://www.nice.org.uk/", metadata: [ { key: "Published date", value: "March 2015", datetime: "2015-03" }, { key: "Metadata key", value: "Metadata value" } ] }) }}

<h2>Card with tag</h2>

{{ card({ heading: { text: "This is another heading" }, href: "https://www.nice.org.uk/", tag: { modifier: "new", label: "New" }, metadata: [ { key: "Published date", value: "March 2015", datetime: "2015-03" }, { key: "Metadata key", value: "Metadata value" } ] }) }}

<h2>List of cards</h1>

<ul class="list list--unstyled">
<li>
{{ card({ heading: { text: "This is a card heading" }, href: "https://www.nice.org.uk/", metadata: [ { key: "Published date", value: "March 2015", datetime: "2015-03" }, { key: "Metadata key", value: "Metadata value" } ] }) }}
</li>
<li>
{{ card({ heading: { text: "This is a card heading" }, href: "https://www.nice.org.uk/", metadata: [ { key: "Published date", value: "March 2015", datetime: "2015-03" }, { key: "Metadata key", value: "Metadata value" } ] }) }}
</li>
</ul>

</div>

{% endblock %}
9 changes: 9 additions & 0 deletions server/views/components/cta-bar.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% extends "layouts/_layout.njk" %}
{% set title = "CTA bar" %}
{% from "cta-bar/cta-bar.njk" import ctaBar %}

{% block body %}

{{ ctaBar({ title: "This is a title", body: "This is some body copy", cta: { text: "Button text", href: "/button-href" } }) }}

{% endblock %}
2 changes: 1 addition & 1 deletion server/views/components/phase.njk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<p class="phase-banner">
<span class="phase-banner__tag">
<strong class="phase-tag phase-tag--alpha">ALPHA</strong>
<strong class="tag tag--impact tag--alpha">ALPHA</strong>
</span>
<span class="phase-banner__label">
This site is in development. This means there it isn't feature complete and there will be issues. Find any? Please, <a href="#">let us know</a>!
Expand Down
24 changes: 24 additions & 0 deletions server/views/components/tag.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% extends "layouts/_layout.njk" %}
{% set title = "Tag" %}

{% block body %}

<div class="container">

<h1>Tag</h1>

<h2>Types of tag</h2>

<ul>
<li>Tag <span class="tag">Tag</span></li>
<li>New <span class="tag tag--new">New</span></li>
<li>Updated <span class="tag tag--updated">Updated</span></li>
<li>Alpha <span class="tag tag--alpha">Alpha</span></li>
<li>Beta <span class="tag tag--beta">Beta</span></li>
<li>Live <span class="tag tag--live">Live</span></li>
<li>Impact <span class="tag tag--impact">Impact</span></li>
</ul>

</div>

{% endblock %}
4 changes: 4 additions & 0 deletions server/views/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<ul>
<li><a href="/components/breadcrumbs/">Breadcrumbs</a></li>
<li><a href="/components/buttons/">Buttons</a></li>
<li><a href="/components/card/">Card</a></li>
<li><a href="/components/cta-bar/">CTA bar</a></li>
<li><a href="/components/footer/">Footer</a></li>
<li><a href="/components/grid/">Grid</a></li>
<li><a href="/components/hero/">Hero</a></li>
Expand All @@ -22,6 +24,7 @@
<li><a href="/components/phase/">Phase banners</a></li>
<li><a href="/components/quote/">Quote</a></li>
<li><a href="/components/stacked-nav/">Stacked nav</a></li>
<li><a href="/components/tag/">Tag</a></li>
<li><a href="/components/tabs/">Tabs</a></li>
<li><a href="/components/typography/">Typography</a></li>
</ul>
Expand All @@ -47,6 +50,7 @@

<ul>
<li><a href="/pages/stakeholder-registration/">Stakeholder registration</a></li>
<li><a href="/pages/topic-landing-page/">Topic landing page</a></li>
</ul>
</div>

Expand Down
5 changes: 4 additions & 1 deletion src/components/_components.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@import 'breadcrumbs/breadcrumbs',
'buttons/buttons',
'card/card',
'container/container',
'cta-bar/cta-bar',
'footer/footer',
'hero/hero',
'in-page-nav/in-page-nav',
Expand All @@ -9,4 +11,5 @@
'panel/panel',
'phase-banner/phase-banner',
'table/table',
'tabs/tabs';
'tabs/tabs',
'tag/tag';
55 changes: 55 additions & 0 deletions src/components/card/_card.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
////
/// @group components
////

/// Card
/// @since 0.3.1
.card {
border-bottom: 1px solid $colour-border;
padding: em($spacing-small 0);

&__header {
}

&__heading {
@include font-size(0);
font-weight: bold;
margin: 0;

a {
text-decoration: none;
}
}

&__icon {
margin: em(0 $spacing-x-small 0 0);
}

&__tag {
@include font-size(-1)
margin-left: em($spacing-x-small);
}

&__metadata {
@include font-size(-1);
color: $colour-nice-dark-grey;
margin: em($spacing-x-small 0 0);
overflow: hidden;

dt {
clear: both;
float: left;
margin: em(0 $spacing-x-small 0 0);
}
dd {
float: left;
margin: em(0 $spacing-medium 0 0);
}

@include mq($from: md) {
dt {
clear: none;
}
}
}
}
33 changes: 33 additions & 0 deletions src/components/card/card.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{% macro card(card) %}
<article class="card">
<header class="card__header">
<h{{ (card.heading.level if card.heading.level else "4") }} class="card__heading">
<a href="{{ card.href }}">
{% if card.heading.icon %}
<span class="card__icon icon icon--{{ card.heading.icon }}" aria-hidden="false"></span>
{% endif %}

{{ card.heading.text }}

{% if card.tag %}
<span class="card__tag tag tag--{{ card.tag.modifier }}">{{ card.tag.label }}</span>
{% endif %}
</a>
</h{{ card.heading.level if card.heading.level else "4" }}>
</header>
{% if card.metadata %}
<dl class="card__metadata">
{% for item in card.metadata %}
<dt>{{ item.key }}:</dt>
<dd>
{% if item.datetime %}
<time datetime="{{ item.datetime }}">{{ item.value }}</time>
{% else %}
{{ item.value }}
{% endif %}
</dd>
{% endfor %}
</dl>
{% endif %}
</article>
{% endmacro %}
59 changes: 59 additions & 0 deletions src/components/cta-bar/_cta-bar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
////
/// @group components
////

/// CTA bar
/// @since 0.3.1
.cta-bar {
@include links-inverse;
background: $colour-nice-cool-teal;
color: $colour-text-inverse;
margin: em($spacing-large 0);
padding: em($spacing-small 0);

&__container {
@extend %container;
}

&__inner {
@include grid;
}

&__text {
@include grid-item($middle: true);
margin-bottom: em($spacing-medium);
}

&__title {
@include font-size(3);
margin: em(0 0 $spacing-x-small);
}

&__intro {
margin: 0;
}

&__actions {
@include grid-item($middle: true);
}

&__cta {

}

@include mq($from: md) {
&__text {
margin-bottom: 0;
width: percentage(3/4);
}

&__actions {
text-align: right;
width: percentage(1/4);
}
}

@media print {
@include important(display, none);
}
}
17 changes: 17 additions & 0 deletions src/components/cta-bar/cta-bar.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% macro ctaBar(ctaBar) %}

<div class="cta-bar">
<div class="cta-bar__container">
<div class="cta-bar__inner">
<div class="cta-bar__text">
<h2 class="cta-bar__title">{{ ctaBar.title }}</h2>
<p class="cta-bar__intro">{{ ctaBar.body }} test test test test test test</p>
</div>
<div class="cta-bar__actions">
<a href="{{ ctaBar.cta.href }}" class="btn btn--inverse">{{ ctaBar.cta.text }}</a>
</div>
</div>
</div>
</div>

{% endmacro %}
52 changes: 4 additions & 48 deletions src/components/phase-banner/_phase-banner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,26 @@

/// A phase banner includes a tag and a label and is designed
/// to designate that a service is in alpha or beta.
/// Usually contains a `.phase-tag`.
/// Usually contains a `.tag .tag--phase`.
///
/// BEM elements:
/// - `__tag` The tag itself
/// - `__label` The label explaining
///
/// @see .phase-tag
/// @see .tag
/// @since 0.1.0
.phase-banner {
border-bottom: 1px solid $colour-border;
display: table;
margin: em(0 0 $spacing-medium);
max-width: 100%;
padding: em($spacing-small 0);
width: 100%;

&__tag {
display: table-cell;
padding: em(0 $spacing-small 0 0);
vertical-align: top;
}

&__label {
Expand All @@ -31,49 +33,3 @@
width: 100%;
}
}

/// A coloured block to designate a service being in alpha or beta. Can be
/// used on its own but usually used within a `.phase-banner`.
///
/// BEM modifiers:
/// - `--alpha` Alpha
/// - `--beta` Beta
/// - `--live` Live
///
/// @todo Distinguish private beta/public beta
/// @todo Do we also need a discover phase colour?
///
/// @see .phase-banner
/// @since 0.1.0
.phase-tag {
@include font-size(-1);
background-color: $colour-panel-inverse;
color: $colour-text-inverse;
display: inline-block;
font-weight: 900;
letter-spacing: 1px;
padding: em($spacing-xx-small $spacing-small);
text-decoration: none;
text-transform: uppercase;
vertical-align: top;

@media print {
@include important(background, $colour-true-black);
@include important(color, $colour-true-white);
}

&--alpha {
background-color: $colour-alpha;
color: $colour-text-inverse;
}

&--beta {
background-color: $colour-beta;
color: $colour-text-inverse;
}

&--live {
background-color: $colour-live;
color: $colour-text-inverse;
}
}
Loading

0 comments on commit cb3352b

Please sign in to comment.