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

Control height of Brand SVG #480

Merged
merged 40 commits into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
54645e5
Control height of Brand SVG
andrew-nowak Apr 29, 2019
97fe851
pr 480
andrew-nowak Apr 29, 2019
517a21b
Merge remote-tracking branch 'origin/latest' into brand-pass-svg-height
andrew-nowak Apr 29, 2019
64ed955
Make svgHeight optional; reduce ver bump to minor
andrew-nowak Apr 29, 2019
d87063f
rename svgHeight -> svgHeights
andrew-nowak Apr 29, 2019
899e6db
Improve README legibility
andrew-nowak Apr 29, 2019
c87ebd7
lower version bump in changelog too
Apr 30, 2019
c7b8ec8
WIP trying phils new method
andrew-nowak May 1, 2019
3027a87
dynamically scale the SVG between min and max widths
May 3, 2019
477d55a
bump v1.2.0, also bump psammead-assets in devDeps
May 3, 2019
1f7a280
add maxWidth minHeight and height props to snapshot test
May 3, 2019
84252f5
reduce banner height and left-right padding under 600px
May 3, 2019
7c96413
explain the magically CSS powering this
May 3, 2019
fcabffb
resolve merge conflicts after pulling in new branch
May 3, 2019
4de0b01
Merge branch 'latest' of github.com:bbc/psammead into brand-pass-svg-…
May 3, 2019
f8fad17
major version change
May 3, 2019
487b5ce
remove unneeded story
May 7, 2019
3da272d
change story input const names
May 7, 2019
176f2c7
set the banner height based on the height prop
May 7, 2019
179cca1
rename height input to svgHeight
May 7, 2019
7fb8f0a
Merge branch 'latest' of github.com:bbc/psammead into brand-pass-svg-…
May 7, 2019
4ef04fd
snapshotssss
May 7, 2019
99cebf8
add line breaks and change height to svgHeight
May 7, 2019
b1bef6c
Update packages/components/psammead-brand/README.md
12 May 8, 2019
e1d7c1e
don't add CSS if svgHeight isn't provided
May 8, 2019
a1a0123
Merge branch 'brand-pass-svg-height' of github.com:bbc/psammead into …
May 8, 2019
311ed8f
Merge branch 'latest' of github.com:bbc/psammead into brand-pass-svg-…
May 8, 2019
b081792
explicitly set width: 100% on the <a> for firefox support
May 8, 2019
561fafd
tidy code with ternary in function
May 9, 2019
c131895
Merge branch 'latest' of github.com:bbc/psammead into brand-pass-svg-…
May 9, 2019
c172b5b
Merge branch 'latest' into brand-pass-svg-height
May 10, 2019
2b27bde
Merge branch 'latest' into brand-pass-svg-height
May 13, 2019
b5e6a98
merge latest and fix conflcits
May 14, 2019
2547870
Merge branch 'brand-pass-svg-height' of github.com:bbc/psammead into …
May 14, 2019
5c157a1
Merge branch 'latest' into brand-pass-svg-height
May 15, 2019
94445d9
Merge branch 'latest' into brand-pass-svg-height
May 16, 2019
1315b65
Merge branch 'latest' into brand-pass-svg-height
May 17, 2019
e8f54e8
move min/max width to <a> for click area fix + readme FF CSS explainer
May 17, 2019
c6b706c
remove extraneous max-width style
May 17, 2019
569bf81
Merge branch 'latest' into brand-pass-svg-height
jamesbrumpton May 20, 2019
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
1 change: 1 addition & 0 deletions packages/components/psammead-brand/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<!-- prettier-ignore -->
| Version | Description |
| ------- | ----------- |
| 2.0.0 | [PR#480](https://github.com/bbc/psammead/pull/480) Allow the SVG to dynamically scale between the minimum and maximum widths passed in as props, also bump psammead-assets@0.1.9. Also reduce banner height and left-right padding under 600px. |
| 1.0.2 | [PR#515](https://github.com/bbc/psammead/pull/515) Update story to use dirDecorator |
| 1.0.1 | [PR#476](https://github.com/bbc/psammead/pull/476) Fail gracefully if brand svg is not provided |
| 1.0.0 | [PR#457](https://github.com/bbc/psammead/pull/457) Enable passing of different svgs |
Expand Down
26 changes: 24 additions & 2 deletions packages/components/psammead-brand/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@

## Description

The `Brand` component provides the BBC service logo (as SVG), nested inside a styled span, link and div. The link is currently hardcoded to "https://www.bbc.co.uk/news". `Brand` takes a `brandName` and an `svg` as props. `brandName` is passed to a [VisuallyHiddenText](https://github.com/bbc/psammead/tree/latest/packages/components/VisuallyHiddenText) component, nested inside Brand. Note that this does not currently affect the branding itself, which always renders as `BBC NEWS`. The `svg` prop must contain a `group`, `viewbox` values and a `ratio`, which is used within an `svg` element, rendered at a height of 24px. Examples of the `svg` object can be found in [@bbc/psammead-assets](https://github.com/bbc/psammead/blob/latest/packages/utilities/psammead-assets/README.md#service-svgs)
The `Brand` component provides the BBC service logo (as SVG), nested inside a styled link and div. The link is currently hardcoded to "https://www.bbc.co.uk/news".

`Brand` takes a `brandName`, `svgHeight`, `minWidth`, `maxWidth` and `svg` as props.

The `brandName` is passed to a [VisuallyHiddenText](https://github.com/bbc/psammead/tree/latest/packages/components/VisuallyHiddenText) component, nested inside Brand.

The `svg` prop must contain a `group`, `viewbox` values and a `ratio`, which is used within an `svg` element. Examples of the `svg` object can be found in [@bbc/psammead-assets](https://github.com/bbc/psammead/blob/latest/packages/utilities/psammead-assets/README.md#service-svgs).

The `minWidth` and `maxWidth` values are required to allow the ability for the `svg` element to dynamically scale as the viewport becomes a very small size EG: feature phones.

The `svgHeight` value acts as a placeholder for the `svg` element meaning the overall banner height does not change with the dynamic scaling, also the `height` allows the contents of the `svg` element to remain vertically centred within the banner at all times.

## Installation

Expand All @@ -13,6 +23,9 @@ The `Brand` component provides the BBC service logo (as SVG), nested inside a st
| Argument | Type | Required | Default | Example |
| --------- | ------ | -------- | ------- | ------------ |
| brandName | String | yes | N/A | `'BBC News'` |
| svgHeight | Number | yes | N/A | `24` |
| minWidth | Number | yes | N/A | `240` |
| maxWidth | Number | yes | N/A | `380` |
| svg | Object | yes | N/A | { group: `(<g fillrule="evenodd"><path d="M84.32" /></g>)`, viewbox: { height: 24, width: 167.95 }, ratio: 6.9979 } |

## Usage
Expand All @@ -25,7 +38,13 @@ import { igbo } from '@bbc/psammead-assets/svgs';

const Header = brandName => (
<header role="banner">
<Brand brandName={brandName} svg={igbo} />
<Brand
brandName={brandName}
svgHeight={24}
maxWidth={280}
minWidth={180}
svg={igbo}
/>
</header>
);
```
Expand All @@ -44,6 +63,9 @@ The `Brand` component is designed to be used where a BBC logo is required as SVG

<!-- ## Roadmap -->

### Additional notes
- `width: 100%` is needed on both `<a>` and the `<svg>` to allow the brand to dynamically scale on the Firefox browser

## Contributing

Psammead is completely open source. We are grateful for any contributions, whether they be new components, bug fixes or general improvements. Please see our primary contributing guide which can be found at [the root of the Psammead respository](https://github.com/bbc/psammead/blob/latest/CONTRIBUTING.md).
Expand Down
8 changes: 4 additions & 4 deletions packages/components/psammead-brand/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/components/psammead-brand/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bbc/psammead-brand",
"version": "1.0.2",
"version": "2.0.0",
andrew-nowak marked this conversation as resolved.
Show resolved Hide resolved
"main": "dist/index.js",
"description": "Provides the BBC News logo (as SVG), nested a hardcoded link to https://www.bbc.co.uk/news",
"repository": {
Expand All @@ -22,7 +22,7 @@
"@bbc/psammead-visually-hidden-text": "^0.1.10"
},
"devDependencies": {
"@bbc/psammead-assets": "^0.1.8",
"@bbc/psammead-assets": "^0.1.9",
"@bbc/psammead-storybook-helpers": "^2.1.1",
"@bbc/psammead-test-helpers": "^0.3.3",
"react": "^16.6.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Brand should render correctly 1`] = `
.c6 {
.c4 {
-webkit-clip-path: inset(100%);
clip-path: inset(100%);
-webkit-clip: rect(1px,1px,1px,1px);
Expand All @@ -14,138 +14,99 @@ exports[`Brand should render correctly 1`] = `

.c0 {
background-color: #B80000;
height: 5rem;
height: 3.5rem;
width: 100%;
padding: 0 0.5rem;
}

.c1 {
max-width: 80rem;
margin: 0 auto;
}

.c3 {
padding-top: 0.5rem;
.c2 {
display: inline-block;
width: 100%;
max-width: 17.5rem;
min-width: 11.25rem;
}

.c4 {
display: block;
padding-bottom: 1.5rem;
.c3 {
box-sizing: content-box;
fill: #FFFFFF;
padding-top: 1rem;
padding-bottom: 0.75rem;
width: 100%;
}

.c2:hover .c4,
.c2:focus .c4 {
.c1:hover .c3,
.c1:focus .c3 {
-webkit-text-decoration: none;
text-decoration: none;
border-bottom: 0.25rem solid #FFFFFF;
}

.c5 {
display: block;
height: 1.5rem;
width: 10.50rem;
margin-top: 1.25rem;
fill: #fff;
}

@media (max-width:25rem) {
.c0 {
padding: 0 0.5rem;
}
}

@media (min-width:25rem) {
@media (min-width:37.5rem) {
.c0 {
height: 5rem;
padding: 0 1rem;
}
}

@media (min-width:62.9375rem) {
.c0 {
padding: 0 1rem;
@media (min-width:37.5rem) {
.c3 {
padding-top: 1.75rem;
padding-bottom: 1.5rem;
}
}

@media screen and (-ms-high-contrast:active),print {
.c5 {
.c3 {
fill: windowText;
}
}

<div
className="c0"
>
<div
className="c1"
<a
className="c1 c2"
href="https://www.bbc.co.uk/news"
>
<a
className="c2 c3"
href="https://www.bbc.co.uk/news"
<svg
aria-hidden="true"
className="c3"
focusable="false"
height={24}
viewBox="0 0 167.95 24"
xmlns="http://www.w3.org/2000/svg"
>
<span
className="c4"
<g
fillrule="evenodd"
>
<svg
aria-hidden="true"
className="c5"
focusable="false"
viewBox="0 0 167.95 24"
xmlns="http://www.w3.org/2000/svg"
>
<g
fillrule="evenodd"
>
<path
d="M84.32"
/>
</g>
</svg>
<span
className="c6"
>
Default Brand Name
</span>
</span>
</a>
</div>
<path
d="M84.32"
/>
</g>
</svg>
<span
className="c4"
>
Default Brand Name
</span>
</a>
</div>
`;

exports[`Brand should render correctly with svg not provided 1`] = `
.c0 {
background-color: #B80000;
height: 5rem;
width: 100%;
padding: 0 0.5rem;
}

.c1 {
max-width: 80rem;
margin: 0 auto;
}

@media (max-width:25rem) {
.c0 {
padding: 0 0.5rem;
}
}

@media (min-width:25rem) {
.c0 {
padding: 0 1rem;
}
}

@media (min-width:62.9375rem) {
@media (min-width:37.5rem) {
.c0 {
padding: 0 1rem;
}
}

<div
className="c0"
>
<div
className="c1"
/>
</div>
/>
`;
Loading