7.3.18 • Published 2 years ago

@bbc/psammead-brand v7.3.18

Weekly downloads
1,437
License
Apache-2.0
Repository
github
Last release
2 years ago

psammead-brand - Known Vulnerabilities Dependency Status peerDependencies Status Storybook GitHub license npm version PRs Welcome

Description

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 product, svgHeight, minWidth, maxWidth, url, serviceLocalisedName, backgroundColour, logoColour and svg as props.

The product is passed to a VisuallyHiddenText component, nested inside Brand.

The serviceLocalisedName is an optional prop referring to the local name of a service eg Yoruba. It is also passed to VisuallyHiddenText inside the Brand component.

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.

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.

The backgroundColour is the background colour and logoColour is the colour of the SVG and the underline when hovering/focusing on the brand.

The url value is the link that points to the frontpage of the service associated with the svg.

The scriptLink can be used to render ScriptLink component which is a link to the service variant.

Exports

/skip-link - Use the skip link component to help keyboard-only users skip to the main content on the page.

Installation

npm install @bbc/psammead-brand

Props

ArgumentTypeRequiredDefaultExample
productStringyesN/A'BBC News'
svgHeightNumberyesN/A24
minWidthNumberyesN/A240
maxWidthNumberyesN/A380
svgObjectyesN/A{ group: (<g fillrule="evenodd"><path d="M84.32" /></g>), viewbox: { height: 24, width: 167.95 }, ratio: 6.9979 }
backgroundColourStringyesN/A${C_POSTBOX} or relevant string hex code
logoColourStringyesN/A${C_WHITE} or relevant string hex code
urlStringnoN/Ahttps://www.bbc.co.uk/news
serviceLocalisedNameStringnoN/A'Yoruba'
borderTopBooleannofalsetrue
borderBottomBooleannofalsetrue
scriptLinkNodenonull<ScriptLink service='news' script={latin} href='https://www.bbc.com/serbian/lat'> Lat </ScriptLink>
skipLinkNodenonull<SkipLink service='news' script={latin} href='#content'> Skip to content </SkipLink>
linkIdStringnonull'brandLink'

Usage

The typical use-case of this component is at the top of pages in a header element. When this is done it is recommend that the component is wrapped in a banner role. However, a header with a banner role should only appear once on a page.

When using Brand in the header, you should ensure that borderBottom prop is set to true. Similarly, when using brand on the footer you should set borderTop to true. This ensures when in High Contrast Mode on PC and when the user changes colour preferences in FireFox that the top/bottom of the Brand component is visible.

ScriptLink component should be passed to scriptLink only when linking to a service variant.

import Brand from '@bbc/psammead-brand';
import SkipLink from '@bbc/psammead-brand/skip-link';
import { igbo } from '@bbc/psammead-assets/svgs';
import ScriptLink from '@bbc/psammead-script-link';
import { C_POSTBOX, C_WHITE } from '@bbc/psammead-styles/colours';
import { latin } from '@bbc/gel-foundations/scripts';

const scriptLink = (
  <ScriptLink
    service="news"
    script={latin}
    href="https://www.bbc.com/serbian/lat"
  >
    Lat
  </ScriptLink>
);

const skipLink = (
  <SkipLink service="news" script={latin} href="#content">
    Skip to content
  </SkipLink>
);

const Header = (product, serviceName) => (
  <header role="banner">
    <Brand
      product={product}
      serviceLocalisedName={serviceName}
      svgHeight={24}
      maxWidth={280}
      minWidth={180}
      svg={igbo}
      url="https://www.bbc.co.uk/news"
      backgroundColour={backgroundColour}
      logoColour={logoColour}
      borderBottom
      scriptLink={scriptLink}
      skipLink={skipLink}
    />
  </header>
);

When to use this component

The Brand component is designed to be used where a BBC logo is required as SVG. Brand is used in the BrandContainer, which consumes a service context it passes to the Brand.

Accessibility notes

  • Visually hidden text is provided (e.g. for screen reader users)
  • Brand is keyboard-accessible and provides hover and focus styles
  • The brand SVG has support for users with css disabled or high contrast mode enabled.

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.

Code of Conduct

We welcome feedback and help on this work. By participating in this project, you agree to abide by the code of conduct. Please take a moment to read it.

License

Psammead is Apache 2.0 licensed.

7.3.18

2 years ago

7.3.17

2 years ago

7.3.16

2 years ago

7.3.14

2 years ago

7.3.15

2 years ago

7.3.13

2 years ago

7.3.12

3 years ago

7.3.11

3 years ago

7.3.10

3 years ago

7.3.9

3 years ago

7.3.8

3 years ago

7.3.7

3 years ago

7.3.6

3 years ago

7.3.5

3 years ago

7.3.4

3 years ago

7.3.3

3 years ago

7.3.2

3 years ago

7.3.1

3 years ago

7.3.0

3 years ago

7.2.1

3 years ago

7.2.0

3 years ago

7.1.3

3 years ago

7.1.2

3 years ago

7.1.1

3 years ago

7.1.0

3 years ago

7.0.31

3 years ago

7.0.30

3 years ago

7.0.29

3 years ago

7.0.28

3 years ago

7.0.27

3 years ago

7.0.26

3 years ago

7.0.25

3 years ago

7.0.23

3 years ago

7.0.24

3 years ago

7.0.21

3 years ago

7.0.22

3 years ago

7.0.18

3 years ago

7.0.19

3 years ago

7.0.20

3 years ago

7.0.16

3 years ago

7.0.17

3 years ago

7.0.15

3 years ago

7.0.13

3 years ago

7.0.14

3 years ago

7.0.12

3 years ago

7.0.11

3 years ago

7.0.10

3 years ago

7.0.9

3 years ago

7.0.8

3 years ago

7.0.7

4 years ago

7.0.6

4 years ago

7.0.5

4 years ago

7.0.4

4 years ago

7.0.3

4 years ago

7.0.2

4 years ago

7.0.0

4 years ago

7.0.1

4 years ago

6.0.4

4 years ago

6.0.3

4 years ago

6.0.1

4 years ago

6.0.2

4 years ago

6.0.0-alpha.0

4 years ago

5.1.35

4 years ago

5.1.34

4 years ago

5.1.33

4 years ago

5.1.32

4 years ago

5.1.31

4 years ago

5.1.30

4 years ago

5.1.29

4 years ago

5.1.28

4 years ago

5.1.27

4 years ago

5.1.26

4 years ago

5.1.25

4 years ago

5.1.24

4 years ago

5.1.23

4 years ago

5.1.22

4 years ago

5.1.21

4 years ago

5.1.20

4 years ago

5.1.19

4 years ago

5.1.18

4 years ago

5.1.17

4 years ago

5.1.16

4 years ago

5.1.15

4 years ago

5.1.14

4 years ago

5.1.13

4 years ago

5.1.12

4 years ago

5.1.11

4 years ago

5.1.10

4 years ago

5.1.9

4 years ago

5.1.8

4 years ago

5.1.7

4 years ago

5.1.6

4 years ago

5.1.5

4 years ago

5.1.4

4 years ago

5.1.3

4 years ago

5.1.2

4 years ago

5.1.1

4 years ago

5.1.0

4 years ago

5.1.0-alpha.10

4 years ago

5.1.0-alpha.9

4 years ago

5.1.0-alpha.7

4 years ago

5.1.0-alpha.6

4 years ago

5.1.0-alpha.5

4 years ago

5.1.0-alpha.4

4 years ago

5.1.0-alpha.3

4 years ago

5.1.0-alpha.2

4 years ago

5.1.0-alpha.1

4 years ago

5.0.11

5 years ago

5.0.10

5 years ago

5.0.9

5 years ago

5.0.8

5 years ago

5.0.7

5 years ago

5.0.6

5 years ago

5.0.5

5 years ago

5.0.4

5 years ago

5.0.3

5 years ago

5.0.2

5 years ago

5.0.1

5 years ago

5.0.0

5 years ago

4.3.8

5 years ago

4.3.7

5 years ago

4.3.6

5 years ago

4.3.5

5 years ago

4.3.4

5 years ago

4.3.3

5 years ago

4.3.2

5 years ago

4.3.1

5 years ago

4.3.0

5 years ago

4.2.6

5 years ago

4.2.5

5 years ago

4.2.4

5 years ago

4.2.3

5 years ago

4.2.2

5 years ago

4.2.1

5 years ago

4.2.0

5 years ago

4.1.12

5 years ago

4.1.11

5 years ago

4.1.10

5 years ago

4.1.9

5 years ago

4.1.8

5 years ago

4.1.7

5 years ago

4.1.6

5 years ago

4.1.5

5 years ago

4.1.4

5 years ago

4.1.3

5 years ago

4.1.2

5 years ago

4.1.1

5 years ago

4.1.0

5 years ago

4.0.2

5 years ago

4.0.1

5 years ago

4.0.0

5 years ago

3.0.0

5 years ago

2.0.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago