Skip to content

Commit

Permalink
Census branded header (#420)
Browse files Browse the repository at this point in the history
* Reduce width of ONS logo

* Add min-height back to top logo

* Added census logo

* Updated census branding logo size and added documentation
  • Loading branch information
bameyrick authored Jun 13, 2019
1 parent 5f85d09 commit d0c22a0
Show file tree
Hide file tree
Showing 13 changed files with 135 additions and 62 deletions.
32 changes: 10 additions & 22 deletions src/components/header/_header.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
$logo-aspect-ratio: 272 / 24;
$header-logo-height: 1.333rem;

// Block
.header {
display: block;
Expand All @@ -16,22 +13,19 @@ $header-logo-height: 1.333rem;
background: $color-white;
}

&__grid-top {
height: 50px;
}

&--internal & {
&__top {
background: $color-dark-blue;
}
}

&__logo {
width: $header-logo-height * $logo-aspect-ratio;
&__grid-top {
min-height: 54px;
}

&--print {
display: none;
}
&__logo {
display: block;
width: 200px;
}

&__main {
Expand Down Expand Up @@ -83,24 +77,18 @@ $header-logo-height: 1.333rem;

// Modifier - Thin variant
&--thin & {
&__top {
padding: 0.5rem 0;
}

&__grid-top {
height: auto;
}

&__main {
padding: 0.5rem 0;

@include mq(m) {
padding: 0.8rem 0;
}
}
}

&__logo {
width: 200px;
&--internal & {
&__grid-top {
min-height: 36px;
}
}

Expand Down
29 changes: 16 additions & 13 deletions src/components/header/_macro-options.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
| Name | Type | Required | Description |
| ------------ | -------------------------------------------------- | -------- | --------------------------------------------------------- |
| phase | `PhaseBanner` [_(ref)_](/components/phase-banner) | false | Settings for the Phase banner component |
| fullWidth | boolean | false | Set the header to be the full width of the viewport |
| logoHref | string | false | Path for the logo link. Defaults to "/" |
| logo | string | false | Path for the logo. Defaults to "ons-logo-pos" |
| language | `Language` [_(ref)_](/patterns/language-selection) | false | Settings for the language selection component |
| serviceLinks | `Array<Navigation>` | false | An array to render the service links list |
| title | string | true | The title for the service |
| desc | string | false | Tagline/description for the service |
| button | `Button` [_(ref)_](/components/button) | false | Settings for save and sign out using the button component |
| navigation | `Array<Navigation>` | false | An array to render the main navigation |
| titleAsH1 | boolean | false | Override to render the header title as a H1 |
| Name | Type | Required | Description |
| ------------- | -------------------------------------------------- | ------------------------------------ | --------------------------------------------------------- |
| phase | `PhaseBanner` [_(ref)_](/components/phase-banner) | false | Settings for the Phase banner component |
| fullWidth | boolean | false | Set the header to be the full width of the viewport |
| logoHref | string | false | Path for the logo link. Defaults to "/" |
| logo | string | false | Path for the logo. Defaults to "ons-logo-pos" |
| language | `Language` [_(ref)_](/patterns/language-selection) | false | Settings for the language selection component |
| serviceLinks | `Array<Navigation>` | false | An array to render the service links list |
| title | string | true | The title for the service |
| desc | string | false | Tagline/description for the service |
| button | `Button` [_(ref)_](/components/button) | false | Settings for save and sign out using the button component |
| navigation | `Array<Navigation>` | false | An array to render the main navigation |
| titleAsH1 | boolean | false | Override to render the header title as a H1 |
| titleLogo | string | false | URL for image to use instead of a title string |
| titleLogoAlt | string | false (if `titleLogo` not specified) | Alt tag for the title logo |
| titleLogoHref | string | false | Will wrap the title logo in a link to the specified URL |

## Navigation

Expand Down
18 changes: 11 additions & 7 deletions src/components/header/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@
{{ onsPhaseBanner(params.phase) }}
{% endif %}
<div class="header__top" role="banner">
<div class=" container{{ ' container--full-width' if params.fullWidth }}">
<div class="container{{ ' container--full-width' if params.fullWidth }}">
<div class="header__grid-top grid grid--gutterless grid--flex grid--between grid--vertical-center grid--no-wrap">
<div class="grid__col col-auto">
<div class="logo">
{% if params.logoHref %}<a href="{{ params.logoHref }}">{% endif %}
<img src="{{ params.assetsURL if params.assetsURL }}/img/{{ params.logo | default('ons-logo-pos-' + currentLanguageISOCode ) }}.svg" alt="{{ params.logoAlt | default('Office for National Statistics logo') }}" class="logo__img header__logo">
{% if params.logoHref %}</a>{% endif %}
</div>
{% if params.logoHref %}<a href="{{ params.logoHref }}">{% endif %}
<img class="header__logo" src="{{ params.assetsURL if params.assetsURL }}/img/{{ params.logo | default('ons-logo-pos-' + currentLanguageISOCode ) }}.svg" alt="{{ params.logoAlt | default('Office for National Statistics logo') }}">
{% if params.logoHref %}</a>{% endif %}
</div>
{% if params.language or params.serviceLinks %}
<div class="header__links grid__col col-auto">
Expand Down Expand Up @@ -62,7 +60,13 @@
<div class="container{{ ' container--full-width' if params.fullWidth }}">
<div class="grid grid--gutterless grid--flex grid--between grid--vertical-center grid--no-wrap">
<div class="grid__col col-auto u-flex-shrink">
<{{ title_tag }} class="header__title">{{ params.title }}</{{ title_tag }}>
{% if params.titleLogoHref %}<a href="{{ params.titleLogoHref }}">{% endif %}
{% if params.titleLogo and params.titleLogoAlt %}
<img class="header__title-logo" src="{{ params.assetsURL if params.assetsURL }}{{ params.titleLogo }}" alt="{{ params.titleLogoAlt }}">
{% else %}
<{{ title_tag }} class="header__title">{{ params.title }}</{{ title_tag }}>
{% endif %}
{% if params.titleLogoHref %}</a>{% endif %}
{% if params.desc %}
<p class="header__desc">{{ params.desc }}</p>
{% endif %}
Expand Down
37 changes: 37 additions & 0 deletions src/components/header/examples/census-cy/index.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
fullWidth: true
layout: none
---
{% extends "styles/page-template/_template.njk" %}

{% set page = {
"theme": "census",
"header": {
"logoHref": "#",
"titleLogo": "/img/census-logo-cy.svg",
"titleLogoAlt": "Cyfrifiad 2021"
},
"language": {
"allLanguagesUrl": "#",
"languages": [
{
"url": "#",
"ISOCode": "en",
"text": "English",
"buttonAriaLabel": "Language selector. Current language: English",
"chooseLanguage": "Choose language",
"allLanguages": "All languages",
"current": false
},
{
"url": "#",
"ISOCode": "cy",
"text": "Cymraeg",
"buttonAriaLabel": "Dewisydd iaith. Iaith gyfredol: Cymraeg",
"chooseLanguage": "Dewiswch iaith",
"allLanguages": "Pob iaith",
"current": true
}
]
}
} %}
37 changes: 37 additions & 0 deletions src/components/header/examples/census/index.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
fullWidth: true
layout: none
---
{% extends "styles/page-template/_template.njk" %}

{% set page = {
"theme": "census",
"header": {
"logoHref": "#",
"titleLogo": "/img/census-logo-en.svg",
"titleLogoAlt": "Census 2021"
},
"language": {
"allLanguagesUrl": "#",
"languages": [
{
"url": "#",
"ISOCode": "en",
"text": "English",
"buttonAriaLabel": "Language selector. Current language: English",
"chooseLanguage": "Choose language",
"allLanguages": "All languages",
"current": true
},
{
"url": "#",
"ISOCode": "cy",
"text": "Cymraeg",
"buttonAriaLabel": "Dewisydd iaith. Iaith gyfredol: Cymraeg",
"chooseLanguage": "Dewiswch iaith",
"allLanguages": "Pob iaith",
"current": false
}
]
}
} %}
11 changes: 11 additions & 0 deletions src/components/header/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ An internal service uses the internal header variant with service links and a ma
patternlibExample({ "path": "components/header/examples/external-welsh/index.njk" })
}}

### Census
{{
patternlibExample({ "path": "components/header/examples/census/index.njk" })
}}

### Census Welsh
{{
patternlibExample({ "path": "components/header/examples/census-cy/index.njk" })
}}


## Research on this component
{% from "components/panel/_macro.njk" import onsPanel %}
{{
Expand Down
1 change: 1 addition & 0 deletions src/img/census-logo-cy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/img/census-logo-en.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/scss/settings/_census.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
// Census brand
$color-header: #93328e;
$font-sans: 'arial';
13 changes: 0 additions & 13 deletions src/scss/utilities/_grid.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
.grid {
box-sizing: border-box;
@if $grid-use-letter-spacing-hack {
letter-spacing: -0.32em;
} @else {
font-size: 0;
}

margin-left: -$grid-gutters;
}

Expand Down Expand Up @@ -129,13 +123,6 @@
// Fixes text overflow issues
min-width: 0;

@if $grid-use-letter-spacing-hack {
letter-spacing: normal;
word-spacing: normal;
} @else {
font-size: $base-font-size;
}

padding-left: $grid-gutters;
.grid--float & {
float: left;
Expand Down
1 change: 0 additions & 1 deletion src/scss/vars/_grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ $grid-cols: 12 !default;
$grid-cols-mobile: 4 !default;
$grid-gutters: 1rem !default;
$grid-bp-fixed: map-get($grid-bp, m) !default;
$grid-use-letter-spacing-hack: false;
$grid-baseline: 16px;
5 changes: 4 additions & 1 deletion src/styles/page-template/_template.njk
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@
"phase": page.phase,
"assetsURL": assetsURL,
"serviceLinks": page.serviceLinks,
"logoHref": page.header.logoHref
"logoHref": page.header.logoHref,
"titleLogo": page.header.titleLogo,
"titleLogoAlt": page.header.titleLogoAlt,
"titleLogoHref": page.header.titleLogoHref
})
}}
{% endblock %}
Expand Down
Loading

0 comments on commit d0c22a0

Please sign in to comment.