Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit f58c13c

Browse files
authored
refactor(banner): Refactor styling to use scss (#655)
1 parent 36dee14 commit f58c13c

3 files changed

Lines changed: 44 additions & 90 deletions

File tree

src/components/Banner/Banner.scss

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.banner {
2+
position: relative;
3+
font-weight: bold;
4+
background-color: var(--color-fill-top-banner);
5+
font-size: var(--font-size-display2);
6+
color: var(--color-text-primary);
7+
border-radius: 5px;
8+
text-align: center;
9+
padding-top: 5px;
10+
}
11+
12+
.bannerButton {
13+
position: relative;
14+
margin-right: var(--space-32);
15+
border-radius: 5.6rem;
16+
background: var(--purple5);
17+
color: var(--color-fill-top-nav);
18+
line-height: var(--line-height-subheading);
19+
text-decoration: none;
20+
font-family: var(--sans);
21+
font-style: normal;
22+
font-weight: var(--font-weight-semibold);
23+
border: 1px solid transparent;
24+
}
25+
26+
p {
27+
padding-top: var(--space-08);
28+
padding-bottom: var(--space-08);
29+
}

src/components/Banner/__tests__/__snapshots__/banner.test.tsx.snap

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,14 @@
22

33
exports[`Tests for Header component renders correctly 1`] = `
44
<div
5-
css={
6-
Object {
7-
"map": undefined,
8-
"name": "433qea",
9-
"next": undefined,
10-
"styles": "
11-
position: relative;
12-
font-weight: bold;
13-
background-color: var(--color-fill-top-banner);
14-
font-size: var(--font-size-display2);
15-
color: var(--color-text-primary);
16-
border-radius: 5px;
17-
text-align: center;
18-
padding-top: 5px;
19-
",
20-
}
21-
}
5+
className="banner"
226
>
23-
<p
24-
css={
25-
Object {
26-
"paddingBottom": "var(--space-08)",
27-
"paddingTop": "var(--space-08)",
28-
}
29-
}
30-
>
7+
<p>
318
<a
329
href="https://nodejs.org/en/blog/vulnerability/february-2020-security-releases/"
3310
>
3411
<button
35-
css={
36-
Object {
37-
"map": undefined,
38-
"name": "1x4o9mg",
39-
"next": undefined,
40-
"styles": "
41-
position: relative;
42-
margin-right: var(--space-32);
43-
border-radius: 5.6rem;
44-
background: var(--purple5);
45-
color: var(--color-fill-top-nav);
46-
line-height: var(--line-height-subheading);
47-
text-decoration: none;
48-
font-family: var(--sans);
49-
font-style: normal;
50-
font-weight: var(--font-weight-semibold);
51-
border: 1px solid transparent;
52-
",
53-
}
54-
}
12+
className="bannerButton"
5513
type="button"
5614
>
5715
Blog post

src/components/Banner/index.tsx

Lines changed: 12 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,27 @@
11
import React from 'react';
2-
import { css, SerializedStyles } from '@emotion/core';
2+
import './Banner.scss';
33

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

7-
const banner: SerializedStyles = css/* scss */ `
8-
position: relative;
9-
font-weight: bold;
10-
background-color: var(--color-fill-top-banner);
11-
font-size: var(--font-size-display2);
12-
color: var(--color-text-primary);
13-
border-radius: 5px;
14-
text-align: center;
15-
padding-top: 5px;
16-
`;
17-
18-
const bannerButton: SerializedStyles = css/* scss */ `
19-
position: relative;
20-
margin-right: var(--space-32);
21-
border-radius: 5.6rem;
22-
background: var(--purple5);
23-
color: var(--color-fill-top-nav);
24-
line-height: var(--line-height-subheading);
25-
text-decoration: none;
26-
font-family: var(--sans);
27-
font-style: normal;
28-
font-weight: var(--font-weight-semibold);
29-
border: 1px solid transparent;
30-
`;
31-
327
/**
338
* The banner is used for displaying upcoming Nodejs events and important announcements ex. security updates
349
* Usage
35-
* <p css={{
36-
* paddingTop: 'var(--space-08)',
37-
* paddingBottom: 'var(--space-08)',
38-
* }}>
39-
* <button css={bannerCta} type="button">
40-
* <a css={bannerButtonText} href={bannerLink}>
41-
* Blog post
42-
* </a>
43-
* </button>
44-
* New security releases now available for all release lines
45-
*</p>
10+
<p>
11+
<a href={bannerLink}>
12+
<button className="bannerButton" type="button">
13+
Blog post
14+
</button>
15+
</a>
16+
New security releases now available for all release lines
17+
</p>
4618
*/
4719
const Banner = (): JSX.Element => {
4820
return (
49-
<div css={banner}>
50-
<p
51-
css={{
52-
paddingTop: 'var(--space-08)',
53-
paddingBottom: 'var(--space-08)',
54-
}}
55-
>
21+
<div className="banner">
22+
<p>
5623
<a href={bannerLink}>
57-
<button css={bannerButton} type="button">
24+
<button className="bannerButton" type="button">
5825
Blog post
5926
</button>
6027
</a>

0 commit comments

Comments
 (0)