Skip to content

Commit 4f57f32

Browse files
committed
part 14 banner
1 parent 08b6d26 commit 4f57f32

2 files changed

Lines changed: 96 additions & 0 deletions

File tree

src/components/InfoBannerNextJs.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import React from 'react';
2+
3+
const NEXT_JS_COURSE_URL =
4+
'https://courses.mooc.fi/org/uh-cs/courses/full-stack-open-nextjs';
5+
6+
const InfoBannerNextJs = ({ visible, onHide, language }) => {
7+
if (!visible) return null;
8+
9+
const text =
10+
language === 'fi'
11+
? 'Uusi osa ilmestynyt:'
12+
: 'A new course part has been released:';
13+
14+
const style = {
15+
position: 'fixed',
16+
left: 24,
17+
right: 24,
18+
bottom: 20,
19+
display: 'flex',
20+
alignItems: 'flex-start',
21+
gap: 16,
22+
padding: 14,
23+
borderStyle: 'solid',
24+
borderWidth: 2,
25+
borderColor: '#ffc107',
26+
backgroundColor: '#fff3cd',
27+
color: '#5a4000',
28+
zIndex: 2147483647,
29+
boxShadow: '0 8px 30px rgba(0, 0, 0, 0.2)',
30+
};
31+
32+
const textStyle = {
33+
flex: 1,
34+
minWidth: 0,
35+
lineHeight: '1.4em',
36+
};
37+
38+
const linkStyle = {
39+
color: '#5a4000',
40+
fontWeight: 600,
41+
textDecoration: 'underline',
42+
wordBreak: 'break-all',
43+
};
44+
45+
const buttonStyle = {
46+
outline: 'none',
47+
backgroundColor: 'transparent',
48+
border: 'none',
49+
color: 'var(--color-text)',
50+
cursor: 'pointer',
51+
fontSize: 18,
52+
lineHeight: 1,
53+
};
54+
55+
return (
56+
<div style={style} role="region" aria-label="Next.js course notice">
57+
<div style={textStyle}>
58+
{text}{' '}
59+
<a href={NEXT_JS_COURSE_URL} style={linkStyle}>
60+
{NEXT_JS_COURSE_URL}
61+
</a>
62+
</div>
63+
<button
64+
style={buttonStyle}
65+
onClick={onHide}
66+
aria-label={language === 'fi' ? 'Sulje ilmoitus' : 'Close notice'}
67+
>
68+
x
69+
</button>
70+
</div>
71+
);
72+
};
73+
74+
export default InfoBannerNextJs;

src/components/layout.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import InfoBanner from './InfoBanner';
99
import InfoBanner2 from './InfoBanner2';
1010
import InfoBanner3 from './InfoBanner3';
1111
import InfoBanner4 from './InfoBanner4';
12+
import InfoBannerNextJs from './InfoBannerNextJs';
1213
import Footer from './Footer/Footer';
1314
import PropTypes from 'prop-types';
1415
import SkipToContent from './SkipToContent/SkipToContent';
@@ -17,6 +18,7 @@ const BANNER_TO_KEY = 'part_10_changes';
1718
const BANNER3_TO_KEY = 'part_7_changes';
1819
const BANNER2_TO_KEY = 'part_6_changes';
1920
const BANNER4_TO_KEY = 'part_8_changes';
21+
const BANNER_NEXT_JS_KEY = 'part_14_changes';
2022

2123
const Layout = (props) => {
2224
const { i18n } = useTranslation();
@@ -28,6 +30,7 @@ const Layout = (props) => {
2830
const [visible2, setVisible2] = useState(false);
2931
const [visible3, setVisible3] = useState(false);
3032
const [visible4, setVisible4] = useState(false);
33+
const [nextJsVisible, setNextJsVisible] = useState(false);
3134

3235
useEffect(() => {
3336
const key = localStorage.getItem(BANNER_TO_KEY);
@@ -61,6 +64,13 @@ const Layout = (props) => {
6164
}
6265
}, []);
6366

67+
useEffect(() => {
68+
const key = localStorage.getItem(BANNER_NEXT_JS_KEY);
69+
if (!key) {
70+
setNextJsVisible(true);
71+
}
72+
}, []);
73+
6474
const hideNote = () => {
6575
console.log('hideNote');
6676
localStorage.setItem(BANNER_TO_KEY, 'yes');
@@ -85,6 +95,12 @@ const Layout = (props) => {
8595
setVisible4(false);
8696
};
8797

98+
const hideNextJsNote = () => {
99+
console.log('hideNote');
100+
localStorage.setItem(BANNER_NEXT_JS_KEY, 'yes');
101+
setNextJsVisible(false);
102+
};
103+
88104
return (
89105
<div className="main-wrapper">
90106
<SkipToContent isCoursePage={isCoursePage} />
@@ -99,6 +115,12 @@ const Layout = (props) => {
99115

100116
<InfoBanner4 onHide={() => hideNote4()} visible={visible4} />
101117

118+
<InfoBannerNextJs
119+
language={siteLanguage}
120+
onHide={() => hideNextJsNote()}
121+
visible={nextJsVisible}
122+
/>
123+
102124
<main id="main-content">{children}</main>
103125

104126
{!hideFooter && <Footer lang={siteLanguage} />}

0 commit comments

Comments
 (0)