Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Merged
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
66 changes: 66 additions & 0 deletions src/components/banner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React from 'react';
import { css, SerializedStyles } from '@emotion/core';

const bannerLink =
'https://nodejs.org/en/blog/vulnerability/february-2020-security-releases/';

const banner: SerializedStyles = css/* scss */ `
position: relative;
font-weight: bold;
background-color: var(--color-fill-top-banner);
font-size: var(--font-size-display2);
color: var(--color-text-primary);
border-radius: 5px;
text-align: center;
padding-top: 5px;
`;

const bannerButton: SerializedStyles = css/* scss */ `
position: relative;
margin-right: var(--space-32);
border-radius: 5.6rem;
background: var(--purple5);
color: var(--color-fill-top-nav);
line-height: var(--line-height-subheading);
text-decoration: none;
font-family: var(--sans);
font-style: normal;
font-weight: var(--font-weight-semibold);
`;

/**
* The banner is used for displaying upcoming Nodejs events and important announcements ex. security updates
* Usage
* <p css={{
* paddingTop: 'var(--space-08)',
* paddingBottom: 'var(--space-08)',
* }}>
* <button css={bannerCta} type="button">
* <a css={bannerButtonText} href={bannerLink}>
* Blog post
* </a>
* </button>
* New security releases now available for all release lines
*</p>
*/
const Banner = (): JSX.Element => {
return (
<div css={banner}>
<p
css={{
paddingTop: 'var(--space-08)',
paddingBottom: 'var(--space-08)',
}}
>
<a href={bannerLink}>
<button css={bannerButton} type="button">
Blog post
</button>
</a>
New security releases now available for all release lines
</p>
</div>
);
};

export default Banner;
2 changes: 2 additions & 0 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import leafsIllustrationFront from '../images/illustrations/leafs-front.svg';
import leafsIllustrationMiddle from '../images/illustrations/leafs-middle.svg';
import leafsIllustrationBack from '../images/illustrations/leafs-back.svg';
import dotsIllustration from '../images/illustrations/dots.svg';
import Banner from '../components/banner';

const nodeFeature1 =
'Lorem ipsum dolor amet pug vape +1 poke pour-over kitsch tacos meh. ';
Expand Down Expand Up @@ -52,6 +53,7 @@ export default function Index(): JSX.Element {
description={description}
style={{ overflow: 'hidden' }}
>
<Banner />
<div className="home-page">
<Hero title={title} subTitle={subTitle} />

Expand Down
1 change: 1 addition & 0 deletions src/styles/tokens.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ body {
--color-fill-canvas: var(--black1);
--color-fill-side-nav: var(--black1);
--color-fill-top-nav: var(--black0);
--color-fill-top-banner: #9992;
--color-fill-action: var(--brand5); /*for actionable elements*/

/* Typography */
Expand Down
62 changes: 62 additions & 0 deletions test/components/__snapshots__/banner.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Tests for Header component renders correctly 1`] = `
<div
css={
Object {
"map": undefined,
"name": "433qea",
"next": undefined,
"styles": "
position: relative;
font-weight: bold;
background-color: var(--color-fill-top-banner);
font-size: var(--font-size-display2);
color: var(--color-text-primary);
border-radius: 5px;
text-align: center;
padding-top: 5px;
",
}
}
>
<p
css={
Object {
"paddingBottom": "var(--space-08)",
"paddingTop": "var(--space-08)",
}
}
>
<a
href="https://nodejs.org/en/blog/vulnerability/february-2020-security-releases/"
>
<button
css={
Object {
"map": undefined,
"name": "16knpov",
"next": undefined,
"styles": "
position: relative;
margin-right: var(--space-32);
border-radius: 5.6rem;
background: var(--purple5);
color: var(--color-fill-top-nav);
line-height: var(--line-height-subheading);
text-decoration: none;
font-family: var(--sans);
font-style: normal;
font-weight: var(--font-weight-semibold);
",
}
}
type="button"
>
Blog post
</button>
</a>
New security releases now available for all release lines
</p>
</div>
`;
11 changes: 11 additions & 0 deletions test/components/banner.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable @typescript-eslint/explicit-function-return-type */
import React from 'react';
import renderer from 'react-test-renderer';
import Banner from '../../src/components/banner';

describe('Tests for Header component', () => {
it('renders correctly', () => {
const tree = renderer.create(<Banner />).toJSON();
expect(tree).toMatchSnapshot();
});
});