Skip to content

Commit eb370ce

Browse files
moT01Sembauke
andauthored
chore(curriculum): add newspaper article lab (freeCodeCamp#55844)
Co-authored-by: Sem Bauke <[email protected]>
1 parent 844afd4 commit eb370ce

File tree

4 files changed

+352
-1
lines changed

4 files changed

+352
-1
lines changed

client/i18n/locales/english/intro.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1829,7 +1829,12 @@
18291829
"habq": { "title": "82", "intro": [] },
18301830
"vqut": { "title": "83", "intro": [] },
18311831
"ujcf": { "title": "84", "intro": [] },
1832-
"upuu": { "title": "85", "intro": [] },
1832+
"lab-newspaper-article": {
1833+
"title": "Build a Newspaper Article",
1834+
"intro": [
1835+
"In this lab, you will build a newspaper article page using HTML and CSS."
1836+
]
1837+
},
18331838
"hbme": { "title": "86", "intro": [] },
18341839
"ioby": { "title": "87", "intro": [] },
18351840
"dyvj": { "title": "88", "intro": [] },
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Introduction to the Newspaper Article Lab
3+
block: lab-newspaper-article
4+
superBlock: front-end-development
5+
---
6+
7+
## Introduction to the Newspaper Article Lab
8+
9+
For this lab, you will create a newspaper article web page using HTML and CSS.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "Build a Newspaper Article",
3+
"blockType": "lab",
4+
"isUpcomingChange": true,
5+
"usesMultifileEditor": true,
6+
"dashedName": "lab-newspaper-article",
7+
"order": 85,
8+
"superBlock": "front-end-development",
9+
"challengeOrder": [
10+
{
11+
"id": "66ba762af611169359d9d369",
12+
"title": "Build a Newspaper Article"
13+
}
14+
],
15+
"helpCategory": "HTML-CSS"
16+
}
Lines changed: 321 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,321 @@
1+
---
2+
id: 66ba762af611169359d9d369
3+
title: Build a Newspaper Article
4+
challengeType: 14
5+
dashedName: build-a-newspaper-article
6+
demoType: onClick
7+
---
8+
9+
# --description--
10+
11+
**Objective:** Fulfill the user stories below and get all the tests to pass to complete the lab.
12+
13+
**User Stories:**
14+
15+
1. You should set the root `font-size` of your HTML document to `24px`.
16+
1. You should have an element with a class of `newspaper` that contains all your other elements.
17+
1. Your `.newspaper` element should have a `font-size` of `16px` and a font of `Open Sans` with a fallback font of `sans-serif`.
18+
1. Within your `.newspaper` element, you should have at least seven more elements: one for the newspaper name that has a class of `name`, one for the date of the article with a class of `date`, one for the headline with a class of `headline`, one for the sub-headline with a class of `sub-headline`, one for the author with a class of `author`, and two paragraphs each with a class of `text`. All of these elements should be filled with your article information.
19+
1. Your `.name` element should have a `font-size` that is twice the root element's `font-size` and should use the `Times New Roman` font, with a fallback font of `serif`.
20+
1. Your `.name` and `.author` elements should use CSS to make all their characters uppercase.
21+
1. Your `.headline` element should have a `font-size` that is twice its parent element's `font-size` and should be bold.
22+
1. Your `.sub-headline` element should have a `font-weight` of `100`, a `font-size` that is `1.5` times its parent element's `font-size`, and should be italicized.
23+
1. Your `.author` should use CSS to make it bold.
24+
1. Your `.text` elements should have a `text-indent` of `20px`.
25+
1. Your `.text` elements should have a `line-height` that is twice their parent element's `font-size`.
26+
1. The first letter of your `.text` elements should be bold and twice the size of their parent element's `font-size`. Use the `::first-letter` selector for this.
27+
28+
# --hints--
29+
30+
You should have an `html` selector that sets its `font-size` to `24px`.
31+
32+
```js
33+
assert.equal(new __helpers.CSSHelp(document).getStyle('html')?.fontSize, '24px');
34+
```
35+
36+
You should have an element with a class of `newspaper`.
37+
38+
```js
39+
assert.exists(document.querySelector('.newspaper'));
40+
```
41+
42+
You should have a `.newspaper` selector that sets its elements' `font-size` to `16px`.
43+
44+
```js
45+
assert.equal(new __helpers.CSSHelp(document).getStyle('.newspaper')?.fontSize, '16px');
46+
```
47+
48+
You should have a `.newspaper` selector that sets its elements' `font-family` to `'Open Sans', sans-serif`.
49+
50+
```js
51+
assert.oneOf(new __helpers.CSSHelp(document).getStyle('.newspaper')?.fontFamily, ['"Open Sans", sans-serif', 'Open Sans, sans-serif']);
52+
```
53+
54+
You should have an element with a class of `name` within your `.newspaper` element.
55+
56+
```js
57+
assert.exists(document.querySelector('.newspaper > .name'));
58+
```
59+
60+
Your `.name` element should have the name of your newspaper.
61+
62+
```js
63+
assert.isAtLeast(document.querySelector('.newspaper > .name')?.innerText.length, 1);
64+
```
65+
66+
You should have an element with a class of `date` within your `.newspaper` element.
67+
68+
```js
69+
assert.exists(document.querySelector('.newspaper > .date'));
70+
```
71+
72+
Your `.date` element should have the date.
73+
74+
```js
75+
assert.isAtLeast(document.querySelector('.newspaper > .date')?.innerText.length, 1);
76+
```
77+
78+
You should have an element with a class of `headline` within your `.newspaper` element.
79+
80+
```js
81+
assert.exists(document.querySelector('.newspaper > .headline'));
82+
```
83+
84+
Your `.headline` element should have your article headline.
85+
86+
```js
87+
assert.isAtLeast(document.querySelector('.newspaper > .headline')?.innerText.length, 1);
88+
```
89+
90+
You should have an element with a class of `sub-headline` within your `.newspaper` element.
91+
92+
```js
93+
assert.exists(document.querySelector('.newspaper > .sub-headline'));
94+
```
95+
96+
Your `.sub-headline` element should have your article sub-headline.
97+
98+
```js
99+
assert.isAtLeast(document.querySelector('.newspaper > .sub-headline')?.innerText.length, 1);
100+
```
101+
102+
You should have an element with a class of `author` within your `.newspaper` element.
103+
104+
```js
105+
assert.isAtLeast(document.querySelectorAll('.newspaper > .author').length, 1);
106+
```
107+
108+
Your `.author` element should have your article author.
109+
110+
```js
111+
assert.isAtLeast(document.querySelector('.newspaper > .author')?.innerText.length, 1);
112+
```
113+
114+
You should have at least two paragraph elements, each with a class of `text`, within your `.newspaper` element.
115+
116+
```js
117+
assert.isAtLeast(document.querySelectorAll('.newspaper > .text').length, 2);
118+
```
119+
120+
Your `.text` elements should have your article text.
121+
122+
```js
123+
const textEls = document.querySelectorAll('.newspaper > .text');
124+
assert.isAtLeast(textEls.length, 1);
125+
textEls.forEach(el => assert.isAtLeast(el.innerText.length, 1))
126+
```
127+
128+
You should have a `.name` selector that sets its elements' `font-size` to `2rem`.
129+
130+
```js
131+
assert.equal(new __helpers.CSSHelp(document).getStyle('.name')?.fontSize, '2rem');
132+
```
133+
134+
You should have a `.name` selector that sets its elements' `font-family` to `'Times New Roman', serif`.
135+
136+
```js
137+
assert.oneOf(new __helpers.CSSHelp(document).getStyle('.name')?.fontFamily, ['"Times New Roman", serif', 'Times New Roman, serif']);
138+
```
139+
140+
You should have a `.name` selector that sets its elements' `text-transform` to `uppercase`.
141+
142+
```js
143+
assert.equal(new __helpers.CSSHelp(document).getStyle('.name')?.textTransform, 'uppercase');
144+
```
145+
146+
You should have an `.author` selector that sets its elements' `text-transform` to `uppercase`.
147+
148+
```js
149+
assert.equal(new __helpers.CSSHelp(document).getStyle('.author')?.textTransform, 'uppercase');
150+
```
151+
152+
You should have a `.headline` selector that sets its elements' `font-size` to `2em`.
153+
154+
```js
155+
assert.equal(new __helpers.CSSHelp(document).getStyle('.headline')?.fontSize, '2em');
156+
```
157+
158+
You should have a `.headline` selector that sets its elements' `font-weight` to `bold`.
159+
160+
```js
161+
assert.oneOf(new __helpers.CSSHelp(document).getStyle('.headline')?.fontWeight, ['bold', '700']);
162+
```
163+
164+
You should have a `.sub-headline` selector that sets its elements' `font-weight` to `100`.
165+
166+
```js
167+
assert.equal(new __helpers.CSSHelp(document).getStyle('.sub-headline')?.fontWeight, '100');
168+
```
169+
170+
You should have a `.sub-headline` selector that sets its elements' `font-size` to `1.5em`.
171+
172+
```js
173+
assert.equal(new __helpers.CSSHelp(document).getStyle('.sub-headline')?.fontSize, '1.5em');
174+
```
175+
176+
You should have a `.sub-headline` selector that sets its elements' `font-style` to `italic`.
177+
178+
```js
179+
assert.equal(new __helpers.CSSHelp(document).getStyle('.sub-headline')?.fontStyle, 'italic');
180+
```
181+
182+
You should have an `.author` selector that sets its elements' `font-weight` to `bold`.
183+
184+
```js
185+
assert.oneOf(new __helpers.CSSHelp(document).getStyle('.author')?.fontWeight, ['bold', '700']);
186+
```
187+
188+
You should have a `.text` selector that sets its elements' `text-indent` to `20px`.
189+
190+
```js
191+
assert.equal(new __helpers.CSSHelp(document).getStyle('.text')?.textIndent, '20px');
192+
```
193+
194+
You should have a `.text` selector that sets its elements' `line-height` to `2em`.
195+
196+
```js
197+
assert.equal(new __helpers.CSSHelp(document).getStyle('.text')?.lineHeight, '2em');
198+
```
199+
200+
You should have a `.text::first-letter` selector that sets its elements' `font-weight` to `bold`.
201+
202+
```js
203+
assert.oneOf(new __helpers.CSSHelp(document).getStyle('.text::first-letter')?.fontWeight, ['bold', '700']);
204+
```
205+
206+
You should have an `.text::first-letter` selector that sets its elements' `font-size` to `2em`.
207+
208+
```js
209+
assert.equal(new __helpers.CSSHelp(document).getStyle('.text::first-letter')?.fontSize, '2em');
210+
```
211+
212+
# --seed--
213+
214+
## --seed-contents--
215+
216+
```html
217+
218+
```
219+
220+
```css
221+
222+
```
223+
224+
# --solutions--
225+
226+
```html
227+
<!DOCTYPE html>
228+
<html lang="en">
229+
230+
<head>
231+
<meta charset="UTF-8">
232+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
233+
<title>Daily Chuckles</title>
234+
<link rel="stylesheet" href="styles.css">
235+
</head>
236+
237+
<body>
238+
<main class="newspaper">
239+
<h1 class="name">Daily Chuckles</h1>
240+
<p class="date">July 5, 2024</p>
241+
<h2 class="headline">Breaking: Grandma Edna Saves Earth</h2>
242+
<h3 class="sub-headline">Alien Invasion Foiled by Tech-Savvy Grandma's Wi-Fi Password</h3>
243+
<p class="author">By Jane Doe</p>
244+
<p class="text">In an extraordinary twist of fate, Grandma Edna found herself at the forefront of a potential crisis
245+
when her clever Wi-Fi security measures unexpectedly thwarted an alien invasion. As alien spacecraft descended
246+
upon the town, panic spread until Grandma Edna calmly intervened, resetting her router with a cryptic passphrase
247+
known only to her.</p>
248+
<p class="text">The aliens, encountering unforeseen technological barriers, struggled to breach Grandma Edna's
249+
fortified network. Frustrated and bewildered, they eventually retreated to reassess their invasion strategy,
250+
leaving residents both relieved and amazed at Grandma Edna's resourcefulness.</p>
251+
</main>
252+
</body>
253+
254+
</html>
255+
```
256+
257+
```css
258+
html {
259+
font-size: 24px;
260+
background-color: MintCream;
261+
padding-top: 100px;
262+
}
263+
264+
.newspaper {
265+
font-family: 'Open Sans', sans-serif;
266+
max-width: 800px;
267+
margin: 20px auto;
268+
padding: 20px;
269+
background-color: white;
270+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
271+
font-size: 16px;
272+
}
273+
274+
.name {
275+
font-family: 'Times New Roman', serif;
276+
font-size: 2rem;
277+
text-transform: uppercase;
278+
text-align: center;
279+
margin-bottom: 10px;
280+
}
281+
282+
.date {
283+
font-size: 1em;
284+
text-align: center;
285+
margin-bottom: 20px;
286+
}
287+
288+
.headline {
289+
font-size: 2em;
290+
font-weight: bold;
291+
line-height: 1.2;
292+
margin-bottom: 10px;
293+
}
294+
295+
.sub-headline {
296+
font-size: 1.5em;
297+
font-style: italic;
298+
font-weight: 100;
299+
line-height: 1.4;
300+
margin-bottom: 15px;
301+
}
302+
303+
.author {
304+
font-size: 1em;
305+
text-transform: uppercase;
306+
font-weight: bold;
307+
margin-bottom: 20px;
308+
}
309+
310+
.text {
311+
text-indent: 20px;
312+
font-size: 1em;
313+
line-height: 2em;
314+
margin-bottom: 15px;
315+
}
316+
317+
.text::first-letter {
318+
font-size: 2em;
319+
font-weight: bold;
320+
}
321+
```

0 commit comments

Comments
 (0)