Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,580 --> 00:00:03,700
Welcome to the coding challenge
2
00:00:03,700 --> 00:00:05,570
of this section.
3
00:00:05,570 --> 00:00:08,730
So we have built a couple of components together.
4
00:00:08,730 --> 00:00:09,570
And so now it's time
5
00:00:09,570 --> 00:00:13,343
for you to actually build this component here on your own.
6
00:00:14,220 --> 00:00:18,000
So basically this very simple pagination component
7
00:00:18,000 --> 00:00:19,963
that you see here, on the right side.
8
00:00:21,440 --> 00:00:25,893
And this is what the final result should look and work like.
9
00:00:26,830 --> 00:00:29,640
So when we hover over these buttons here,
10
00:00:29,640 --> 00:00:31,800
they get this green background color
11
00:00:31,800 --> 00:00:35,293
and the same here for each of the page's link.
12
00:00:36,170 --> 00:00:39,100
So here, I want you to use two buttons,
13
00:00:39,100 --> 00:00:43,320
one to go to the previous and one to go to the next page.
14
00:00:43,320 --> 00:00:46,280
Then these, in here, are simply links.
15
00:00:46,280 --> 00:00:48,160
So anchor elements.
16
00:00:48,160 --> 00:00:50,240
And then we also have these dots here,
17
00:00:50,240 --> 00:00:53,740
which is a simple span text element.
18
00:00:53,740 --> 00:00:55,780
All right, now,
19
00:00:55,780 --> 00:00:58,930
I don't want you to use any absolute positioning here
20
00:00:58,930 --> 00:01:00,580
or anything like that.
21
00:01:00,580 --> 00:01:03,760
So these buttons look the same or very similar
22
00:01:03,760 --> 00:01:07,190
to the ones that we used in the carousel component,
23
00:01:07,190 --> 00:01:09,260
but there we used some absolute positioning,
24
00:01:09,260 --> 00:01:12,080
which is not necessary in this case.
25
00:01:12,080 --> 00:01:15,760
So we don't have any visual container here.
26
00:01:15,760 --> 00:01:18,900
And so this one here is simply going to be the first element
27
00:01:18,900 --> 00:01:21,950
and this the last one, all right.
28
00:01:21,950 --> 00:01:25,040
Then notice how all of this, here, is vertically aligned
29
00:01:25,040 --> 00:01:27,750
and also how this entire pagination
30
00:01:27,750 --> 00:01:30,270
is centered in the browser.
31
00:01:30,270 --> 00:01:31,103
All right.
32
00:01:31,103 --> 00:01:35,260
And so, I think that is enough for the instructions.
33
00:01:35,260 --> 00:01:39,210
So please go ahead and try to build this challenge now.
34
00:01:39,210 --> 00:01:42,720
And this is probably going to be the hardest challenge
35
00:01:42,720 --> 00:01:45,400
of all yet in this course.
36
00:01:45,400 --> 00:01:47,430
And so please don't be discouraged
37
00:01:47,430 --> 00:01:50,670
in case there is something that you cannot really do.
38
00:01:50,670 --> 00:01:53,020
So just try to do all that you can.
39
00:01:53,020 --> 00:01:55,650
So basically trying your best
40
00:01:55,650 --> 00:01:59,040
because that's, as always, the most important thing.
41
00:01:59,040 --> 00:02:00,710 line:15%
So pause the video now, here,
42
00:02:00,710 --> 00:02:03,703 line:15%
and then come back for the solution once you're done.
43
00:02:06,190 --> 00:02:07,630 line:15%
Okay.
44
00:02:07,630 --> 00:02:09,563
So how did that go?
45
00:02:10,780 --> 00:02:14,423
Hopefully you managed to do a part of this pagination,
46
00:02:18,210 --> 00:02:20,120
and so now here comes the solution,
47
00:02:20,120 --> 00:02:23,083
in case you missed anything.
48
00:02:24,100 --> 00:02:26,910
So let me, as always, get the starter code
49
00:02:26,910 --> 00:02:31,823
basically from this component file, then paste that here,
50
00:02:33,720 --> 00:02:35,303
collapse the sidebar,
51
00:02:38,370 --> 00:02:43,370
and I will now start here writing the HTML as always.
52
00:02:45,360 --> 00:02:49,957
Now here we want a "div" with the class of "pagination".
53
00:02:53,930 --> 00:02:56,403
Now, of course we need to close that.
54
00:02:58,130 --> 00:02:59,780
And then we can immediately start
55
00:02:59,780 --> 00:03:02,120
with the first button element, here,
56
00:03:02,120 --> 00:03:04,810
which will contain this icon.
57
00:03:04,810 --> 00:03:08,710
So you could have copied that from the carousel component
58
00:03:08,710 --> 00:03:11,453
or also, of course, here from the Hero Icons.
59
00:03:12,550 --> 00:03:14,203
So that's what I'm doing now.
60
00:03:16,980 --> 00:03:18,023
All right.
61
00:03:18,950 --> 00:03:23,323
So this one, let's actually give it to class of "btn"
62
00:03:25,179 --> 00:03:28,873
and this one here, "btn-icon,
63
00:03:32,120 --> 00:03:34,403
then let's build our anchor elements.
64
00:03:35,710 --> 00:03:39,110
And I didn't mention that they shouldn't point anywhere,
65
00:03:39,110 --> 00:03:42,253
but hopefully you figured that one out on your own.
66
00:03:43,510 --> 00:03:45,227
So calling these one "page-link".
67
00:03:46,110 --> 00:03:50,053
but of course you could have called them whatever you liked.
68
00:03:51,600 --> 00:03:52,433
Okay.
69
00:03:55,870 --> 00:03:58,163
So copy/pasting this a couple of times.
70
00:03:59,110 --> 00:04:02,233
So 1, 2, 3, 4, 5, 6, and then the last one,
71
00:04:03,840 --> 00:04:05,570
for page 23...
72
00:04:06,700 --> 00:04:10,200
3, 4, 5, 6,
73
00:04:10,200 --> 00:04:11,483
and 23.
74
00:04:13,370 --> 00:04:14,799
Okay.
75
00:04:14,799 --> 00:04:19,360
And then, also ,here between the six and the 23.
76
00:04:19,360 --> 00:04:22,760
So basically before the last one, we have some dots.
77
00:04:22,760 --> 00:04:26,540
So basically indicating that there are more than six pages
78
00:04:26,540 --> 00:04:29,210
and in total 23 pages.
79
00:04:29,210 --> 00:04:32,563
So that's a common thing to do in a pagination like this.
80
00:04:34,020 --> 00:04:35,010
And as I mentioned here,
81
00:04:35,010 --> 00:04:36,940
I'm going to use a span element
82
00:04:38,500 --> 00:04:41,850
with the class of just "dots"
83
00:04:41,850 --> 00:04:44,403
and then here, well the three dots.
84
00:04:45,370 --> 00:04:46,530
Okay.
85
00:04:46,530 --> 00:04:51,063
And let's now take a look here, at what it looks like.
86
00:04:52,370 --> 00:04:56,513
So we need to reload this usually, and then here we go.
87
00:04:57,800 --> 00:04:59,750
So we have the button here, which is again,
88
00:04:59,750 --> 00:05:03,733
very small and we're missing actually the last button.
89
00:05:09,300 --> 00:05:11,333
So again, let's call it "btn"
90
00:05:15,240 --> 00:05:18,403
and then let's grab this icon here,
91
00:05:22,850 --> 00:05:26,807
with the class of "btn-icon".
92
00:05:28,040 --> 00:05:29,070
Okay.
93
00:05:29,070 --> 00:05:31,430
And now I will copy all of this, here again,
94
00:05:31,430 --> 00:05:35,453
with the trick of hitting alt or option at the same time.
95
00:05:39,970 --> 00:05:41,493
And I think that's it.
96
00:05:42,910 --> 00:05:44,420
So copying everything...
97
00:05:46,880 --> 00:05:48,243
and there we go.
98
00:05:49,500 --> 00:05:52,700
Now, actually I'm going to do the same trick here again,
99
00:05:52,700 --> 00:05:56,540
because now I want to write the same thing in all of them.
100
00:05:56,540 --> 00:05:58,680
So we want add a dot,
101
00:05:58,680 --> 00:06:01,320
then we can go all the way to the end
102
00:06:01,320 --> 00:06:03,820
and then we can write this...
103
00:06:05,630 --> 00:06:06,463
like this.
104
00:06:07,390 --> 00:06:08,360
All right.
105
00:06:08,360 --> 00:06:12,180
So we saved some time there and let's now start styling them
106
00:06:12,180 --> 00:06:13,840
one by one here.
107
00:06:13,840 --> 00:06:17,110
And I will actually, again, start with the icon
108
00:06:17,110 --> 00:06:19,080
because that's what makes these buttons here
109
00:06:19,080 --> 00:06:20,623
look so small right now.
110
00:06:22,320 --> 00:06:23,490
So we're giving them, again,
111
00:06:23,490 --> 00:06:25,943
a height and width of 24 pixels.
112
00:06:29,810 --> 00:06:34,743
So 24 at the end, of course, the green color.
113
00:06:36,750 --> 00:06:39,533
So that's again using the stroke property.
114
00:06:43,090 --> 00:06:44,440
All right.
115
00:06:44,440 --> 00:06:46,423
So those are the icons.
116
00:06:47,290 --> 00:06:50,610
And remember that it's supposed to be this round
117
00:06:50,610 --> 00:06:53,283
with the green border around the button.
118
00:06:55,140 --> 00:06:58,260
So let's start with that actually,
119
00:06:58,260 --> 00:07:01,217
border one, pixel "solid".
120
00:07:03,490 --> 00:07:06,910
Then let's give it some height and some width here as well.
121
00:07:06,910 --> 00:07:10,723
And let's make it double the one of the icons themselves.
122
00:07:13,540 --> 00:07:18,540
So 48 pixels, and then for the round corners,
123
00:07:19,100 --> 00:07:21,270
so basically to make it round,
124
00:07:21,270 --> 00:07:26,070
remember we use a border radius of 50%.
125
00:07:26,070 --> 00:07:28,160
All right, nice.
126
00:07:28,160 --> 00:07:32,010
Now we just need to get rid of the background color,
127
00:07:32,010 --> 00:07:34,483
which these buttons always have by default.
128
00:07:38,410 --> 00:07:40,923
And we also want to add that cursor.
129
00:07:43,450 --> 00:07:44,513
Yes, always.
130
00:07:48,010 --> 00:07:49,793
Well, that didn't work,
131
00:07:50,690 --> 00:07:53,270
but that's because here we actually need "background",
132
00:07:53,270 --> 00:07:54,707
not just "background-color".
133
00:07:55,610 --> 00:07:56,570
Okay.
134
00:07:56,570 --> 00:07:58,930
Now let's do the visual formatting
135
00:07:58,930 --> 00:08:01,293
of these individual links here.
136
00:08:02,170 --> 00:08:04,560
So that is "page-link."
137
00:08:04,560 --> 00:08:08,870
And then of course we need to add our pseudo classes,
138
00:08:08,870 --> 00:08:11,713
which are the "link"...
139
00:08:16,284 --> 00:08:18,490
and the "visited" here first,
140
00:08:18,490 --> 00:08:21,657
and then remember also "hover" and "visited",
141
00:08:22,990 --> 00:08:24,640
or actually "hover" and "active".
142
00:08:29,970 --> 00:08:33,153
So let's start with the regular link styling.
143
00:08:34,060 --> 00:08:36,330
Let's make them a little bit bigger.
144
00:08:36,330 --> 00:08:38,315
18 pixels, let's say.
145
00:08:38,315 --> 00:08:42,840
Then we also want the color to be our gray.
146
00:08:42,840 --> 00:08:45,490
So the one that we have always been using.
147
00:08:45,490 --> 00:08:48,423
And we want to get rid of the underlining.
148
00:08:50,620 --> 00:08:54,187
So that's "text-decoration", "none".
149
00:08:55,140 --> 00:08:57,450
And now, as for the hover effect,
150
00:08:57,450 --> 00:08:59,913
let's again check out how that looks like.
151
00:09:01,630 --> 00:09:05,150
So basically there is this circle around each of the links,
152
00:09:05,150 --> 00:09:08,570
which then becomes green as we hover over it.
153
00:09:08,570 --> 00:09:09,403
Now,
154
00:09:09,403 --> 00:09:11,670
what that means is that this circle, actually,
155
00:09:11,670 --> 00:09:16,300
needs to kind of exist already in the predefined link.
156
00:09:16,300 --> 00:09:20,220
So in the state before the hover, right?
157
00:09:20,220 --> 00:09:22,053
So let's actually do that.
158
00:09:23,970 --> 00:09:26,490
And, as always, to make that work visually,
159
00:09:26,490 --> 00:09:28,883
let's give it some background color here first.
160
00:09:31,140 --> 00:09:33,450
And so now, of course, it's only a square.
161
00:09:33,450 --> 00:09:34,283
And if so,
162
00:09:34,283 --> 00:09:38,570
if we hovered or if we gave it some style now for the hover,
163
00:09:38,570 --> 00:09:41,003
then only that square would become green.
164
00:09:48,260 --> 00:09:51,113
And also the color white since we're here already.
165
00:09:54,400 --> 00:09:55,530
So right,
166
00:09:55,530 --> 00:10:00,030
now only this square that's around the actual element
167
00:10:00,030 --> 00:10:03,090
or behind the element would become green.
168
00:10:03,090 --> 00:10:06,303
And so we need to make that circle here at this point.
169
00:10:07,270 --> 00:10:11,143
So in order to do that, we give it a height and a width.
170
00:10:12,310 --> 00:10:13,810
So 36,
171
00:10:13,810 --> 00:10:17,620
which is one of the values that is in the spacing system
172
00:10:18,640 --> 00:10:21,750
and the width of 36 as well.
173
00:10:21,750 --> 00:10:22,770
And so by this,
174
00:10:22,770 --> 00:10:25,603
we can ensure that it is an actual square.
175
00:10:26,705 --> 00:10:29,520
Now, right now, this didn't work yet
176
00:10:29,520 --> 00:10:31,780
because, remember that, by default,
177
00:10:31,780 --> 00:10:33,440
this is an inline element,
178
00:10:33,440 --> 00:10:35,543
and so therefore it's not going to work.
179
00:10:38,160 --> 00:10:39,580
Inline block.
180
00:10:39,580 --> 00:10:42,923
And so now they are squares as expected.
181
00:10:43,850 --> 00:10:47,350
So to inline elements, height and width does not apply,
182
00:10:47,350 --> 00:10:48,330
right?
183
00:10:48,330 --> 00:10:51,073
And so we need to change that to something else.
184
00:10:52,230 --> 00:10:57,080
Great. So now we have the square that we can make round.
185
00:10:57,080 --> 00:10:58,210
And by the way,
186
00:10:58,210 --> 00:11:01,598
we couldn't use padding in order to create this new space,
187
00:11:01,598 --> 00:11:03,360
because by doing that,
188
00:11:03,360 --> 00:11:07,530
we could not ensure that they would be perfect squares,
189
00:11:07,530 --> 00:11:09,693
but by doing this, we can.
190
00:11:11,000 --> 00:11:13,460
Now we also need to center the text now,
191
00:11:13,460 --> 00:11:14,840
inside of the squares,
192
00:11:14,840 --> 00:11:18,133
both horizontally and vertically, right?
193
00:11:19,120 --> 00:11:22,743
So once again, what is a nice trick to do that?
194
00:11:23,630 --> 00:11:27,640
Well, we can do that, once again, using Flexbox.
195
00:11:27,640 --> 00:11:30,150
And I think we did this trick before.
196
00:11:30,150 --> 00:11:33,930
So basically using Flexbox simply to center the text
197
00:11:33,930 --> 00:11:36,156
that is inside of an element,
198
00:11:36,156 --> 00:11:38,433
both horizontally and vertically.
199
00:11:39,510 --> 00:11:40,343
So here actually
200
00:11:40,343 --> 00:11:45,130
we do not want "inline block" as the display property,
201
00:11:45,130 --> 00:11:50,130
but "flex", and then here "align-items", "center",
202
00:11:53,045 --> 00:11:55,107
and also "justify content", "center".
203
00:11:56,400 --> 00:11:58,163
All right, there we go.
204
00:11:59,210 --> 00:12:02,520
Now these links here, suddenly got stacked.
205
00:12:02,520 --> 00:12:05,600
So they're now one below the other,
206
00:12:05,600 --> 00:12:08,350
and that's because basically by default,
207
00:12:08,350 --> 00:12:13,340
a flex container is also something like a block element.
208
00:12:13,340 --> 00:12:14,430
So again,
209
00:12:14,430 --> 00:12:18,070
each of these page links here is now a flex container,
210
00:12:18,070 --> 00:12:18,903
right?
211
00:12:18,903 --> 00:12:20,800
And, by default, flex containers
212
00:12:20,800 --> 00:12:23,270
are also like block elements.
213
00:12:23,270 --> 00:12:24,160
And so, therefore,
214
00:12:24,160 --> 00:12:28,580
each of these elements now here occupies its own line.
215
00:12:28,580 --> 00:12:29,850
All right.
216
00:12:29,850 --> 00:12:32,100
So let's fix that in a moment,
217
00:12:32,100 --> 00:12:34,940
but in order not to jump around all the time,
218
00:12:34,940 --> 00:12:37,870
let's finish this part here first.
219
00:12:37,870 --> 00:12:40,950
So we still need to make them round.
220
00:12:40,950 --> 00:12:45,617
So that's border radius 50%, right.
221
00:12:47,360 --> 00:12:49,310
And then we need to get rid, of course,
222
00:12:49,310 --> 00:12:50,923
of this background color.
223
00:12:52,330 --> 00:12:54,750
And so now that is actually the effect
224
00:12:54,750 --> 00:12:57,553
that we were going for. Right?
225
00:12:58,610 --> 00:12:59,580
Okay.
226
00:12:59,580 --> 00:13:02,021
Actually, we also need the same effect here
227
00:13:02,021 --> 00:13:06,000
on these buttons, right?
228
00:13:06,000 --> 00:13:08,493
So we need to quickly implement that as well.
229
00:13:09,610 --> 00:13:13,907
So that is "btn", "hover".
230
00:13:18,090 --> 00:13:20,623
So background color, this green.
231
00:13:22,200 --> 00:13:23,210
And now of course,
232
00:13:23,210 --> 00:13:26,323
we also need to make the icon itself white.
233
00:13:27,260 --> 00:13:30,613
Like this is impossible to see it, right?
234
00:13:31,620 --> 00:13:34,690
Now here, we need to do this.
235
00:13:34,690 --> 00:13:36,790
So let me write it first and then explain.
236
00:13:39,190 --> 00:13:41,560
So we are still interested in what happens
237
00:13:41,560 --> 00:13:45,520
when we hover the button here and not the button icon.
238
00:13:45,520 --> 00:13:49,300
And so what we want to happen is that the icon turns white
239
00:13:49,300 --> 00:13:51,270
when we hover the button.
240
00:13:51,270 --> 00:13:55,220
And so that's why we write "btn, "hover" like we did before.
241
00:13:55,220 --> 00:13:57,393
And then as a child of that condition,
242
00:13:59,810 --> 00:14:02,023
basically "btn", "icon" selector.
243
00:14:03,790 --> 00:14:08,103
And so that is where the stroke then becomes white.
244
00:14:10,371 --> 00:14:13,627
All right. And so that works beautifully now.
245
00:14:14,540 --> 00:14:17,380
So if we didn't do this,
246
00:14:17,380 --> 00:14:20,940
so if we simply said "we copied this",
247
00:14:20,940 --> 00:14:22,690
because this is actually important.
248
00:14:26,380 --> 00:14:28,363
So if we did this,
249
00:14:29,910 --> 00:14:32,110
then it would work in a quite different way.
250
00:14:32,990 --> 00:14:35,500
So now if we hovered only the button,
251
00:14:35,500 --> 00:14:37,800
then the icon would still be green,
252
00:14:37,800 --> 00:14:40,050
but now as we move more inward,
253
00:14:40,050 --> 00:14:43,150
so at some point we will hover over the icon, right?
254
00:14:43,150 --> 00:14:46,140
And so now that is when the icon becomes white
255
00:14:46,140 --> 00:14:47,680
as we want it.
256
00:14:47,680 --> 00:14:52,240
But only, again, once we actually hovered the icon itself.
257
00:14:52,240 --> 00:14:54,130
So that's what we set here.
258
00:14:54,130 --> 00:14:55,540
Right.
259
00:14:55,540 --> 00:14:59,770
But again, that's not the effect we are looking for.
260
00:14:59,770 --> 00:15:03,230
Instead we want the icon here to become white
261
00:15:03,230 --> 00:15:06,800
as soon as we actually hover the button itself.
262
00:15:06,800 --> 00:15:10,000
So just like this, right.
263
00:15:10,000 --> 00:15:14,500
Now okay, so the visual styling here is almost complete.
264
00:15:14,500 --> 00:15:17,750
Now let's finally take care of the layout.
265
00:15:17,750 --> 00:15:20,150
So basically putting all of these elements here,
266
00:15:20,150 --> 00:15:21,363
side by side.
267
00:15:23,490 --> 00:15:25,943
So that is the pagination class.
268
00:15:29,070 --> 00:15:33,420
And so as expected for that, we're going to use Flexbox.
269
00:15:33,420 --> 00:15:37,250
So it is a one-dimensional layout. So just a row.
270
00:15:37,250 --> 00:15:39,883
And so Flexbox is the right job for that.
271
00:15:41,150 --> 00:15:42,183
Beautiful.
272
00:15:43,040 --> 00:15:46,543
And now let's, of course, vertically align our items here.
273
00:15:47,580 --> 00:15:51,490
So "align items", "center".
274
00:15:51,490 --> 00:15:52,510
Now okay.
275
00:15:52,510 --> 00:15:55,370
And now, just to finish, we need some gap between them
276
00:15:57,879 --> 00:16:00,530
and there we go.
277
00:16:00,530 --> 00:16:02,020
And of course, also,
278
00:16:02,020 --> 00:16:05,630
we want to center this entire component here
279
00:16:05,630 --> 00:16:08,323
inside of the body, as always.
280
00:16:09,240 --> 00:16:10,880
All right, now here,
281
00:16:10,880 --> 00:16:13,070
you would have actually needed that trick
282
00:16:13,070 --> 00:16:15,043
that I showed you in the last lecture.
283
00:16:15,990 --> 00:16:17,880
So using basically Flexbox
284
00:16:17,880 --> 00:16:20,150
in order to center this component,
285
00:16:20,150 --> 00:16:23,630
that's because the trick with margin zero auto
286
00:16:23,630 --> 00:16:26,540
will actually not work in this case.
287
00:16:26,540 --> 00:16:28,010
So that trick, remember,
288
00:16:28,010 --> 00:16:32,990
only works when we actually define a width on the element.
289
00:16:32,990 --> 00:16:34,090
So in this case,
290
00:16:34,090 --> 00:16:37,430
we would have to declare a width on the pagination
291
00:16:37,430 --> 00:16:41,170
and then use that trick of margin zero auto.
292
00:16:41,170 --> 00:16:42,210
But in this case,
293
00:16:42,210 --> 00:16:43,330
we are not interested
294
00:16:43,330 --> 00:16:46,030
in actually giving this pagination a width.
295
00:16:46,030 --> 00:16:48,370
So the width is simply defined
296
00:16:48,370 --> 00:16:52,243
by basically all the width of this here added together,
297
00:16:53,710 --> 00:16:54,543
right?
298
00:16:54,543 --> 00:16:55,800
So we're not defining it.
299
00:16:55,800 --> 00:16:59,050
And so therefore that trick would not work.
300
00:16:59,050 --> 00:17:01,660
So instead, what we're going to do is to again,
301
00:17:01,660 --> 00:17:04,063
make the body a flex container,
302
00:17:06,660 --> 00:17:09,717
and then "justify-content", "center".
303
00:17:10,740 --> 00:17:11,573
And by the way,
304
00:17:11,573 --> 00:17:13,040
this is not the kind of things
305
00:17:13,040 --> 00:17:17,010
that I expected you to also do in the coding challenge.
306
00:17:17,010 --> 00:17:18,360
So, for the challenge,
307
00:17:18,360 --> 00:17:19,710
I was mainly interested
308
00:17:19,710 --> 00:17:24,020
that you did like this visual styling and all of that,
309
00:17:24,020 --> 00:17:25,410
but centering in the browser,
310
00:17:25,410 --> 00:17:28,870
using this technique here, if you didn't do that,
311
00:17:28,870 --> 00:17:30,803
that's not a problem at all.
312
00:17:32,470 --> 00:17:34,920
Well, let's just add some margin to the top here.
313
00:17:37,610 --> 00:17:39,053
All right. Nice.
314
00:17:40,070 --> 00:17:42,120
So let's take a look at what's different.
315
00:17:43,160 --> 00:17:45,950
And so here are these dots,
316
00:17:45,950 --> 00:17:48,130
they need to have a different color.
317
00:17:48,130 --> 00:17:51,440
And then also there basically this indication
318
00:17:51,440 --> 00:17:54,400
that we're on page number three right now.
319
00:17:54,400 --> 00:17:57,293
So basically an active page indicator.
320
00:18:00,310 --> 00:18:03,990
So let's style our dots,
321
00:18:03,990 --> 00:18:07,293
which are right here, right.
322
00:18:08,852 --> 00:18:11,543
And let's use some gray background color here.
323
00:18:14,050 --> 00:18:15,003
Let's say this,
324
00:18:16,280 --> 00:18:20,490
not a background color, but an actual text color.
325
00:18:20,490 --> 00:18:21,580
Nice.
326
00:18:21,580 --> 00:18:22,630
And now again,
327
00:18:22,630 --> 00:18:25,760
we want one of them here to look as if they were active
328
00:18:25,760 --> 00:18:27,060
right now.
329
00:18:27,060 --> 00:18:28,160
And so basically
330
00:18:28,160 --> 00:18:33,100
that style is exactly the same style as to hover, right?
331
00:18:33,100 --> 00:18:34,780
So we see that here.
332
00:18:34,780 --> 00:18:37,513
And it is exactly what happens when we hover.
333
00:18:39,010 --> 00:18:42,650
So, since we already have that style written,
334
00:18:42,650 --> 00:18:46,593
which is this one here, we can simply reuse that.
335
00:18:48,380 --> 00:18:52,363
So let's add a class down here, in the third one.
336
00:18:55,540 --> 00:18:58,940
So "page-link", and then some sort of variation,
337
00:18:58,940 --> 00:19:02,043
which remember, I like to use two dashes for that.
338
00:19:05,520 --> 00:19:09,463
So "current", so this is the current page link.
339
00:19:11,370 --> 00:19:13,240
So let's copy that.
340
00:19:13,240 --> 00:19:16,423
And now we need to paste that right here.
341
00:19:21,960 --> 00:19:24,020
Okay. Because once again,
342
00:19:24,020 --> 00:19:26,510
we already have written this style here,
343
00:19:26,510 --> 00:19:30,540
and so we can simply add this class to this list.
344
00:19:30,540 --> 00:19:33,150
And of course we could have done it separately as well,
345
00:19:33,150 --> 00:19:36,010
but then we would have this code here in duplicate,
346
00:19:36,010 --> 00:19:38,290
and that's not what we want.
347
00:19:38,290 --> 00:19:40,870
However, actually this is not going to work.
348
00:19:40,870 --> 00:19:43,950
And let me show you, right.
349
00:19:43,950 --> 00:19:46,860
So it gave it the correct background color,
350
00:19:46,860 --> 00:19:51,240
but the text color itself is still coming from up here.
351
00:19:51,240 --> 00:19:52,840
And that's because, right now,
352
00:19:52,840 --> 00:19:55,973
both these rules here are actually applying.
353
00:19:56,810 --> 00:20:00,160
So of course this element is still a page link,
354
00:20:00,160 --> 00:20:01,663
so still this one here,
355
00:20:03,020 --> 00:20:05,740
and so that's where the text color comes from,
356
00:20:05,740 --> 00:20:08,790
but it is also a "page-link--current".
357
00:20:08,790 --> 00:20:11,630
So that's where the background color comes from.
358
00:20:11,630 --> 00:20:15,290
So it uses this background color over this one here,
359
00:20:15,290 --> 00:20:19,507
which means that somehow this selector here gets priority
360
00:20:19,507 --> 00:20:20,993
over this one here.
361
00:20:22,430 --> 00:20:24,007
So this one,
362
00:20:24,007 --> 00:20:26,730
and the reason for that is a little bit complicated,
363
00:20:26,730 --> 00:20:28,540
but if we hover over it,
364
00:20:28,540 --> 00:20:31,821
you will see here that it says "selector specificity",
365
00:20:31,821 --> 00:20:35,030
(0,2,0), right?
366
00:20:35,030 --> 00:20:36,887
And down here it says (0,1,0).
367
00:20:38,640 --> 00:20:40,960
And so that two here is higher,
368
00:20:40,960 --> 00:20:42,863
and so that's why this applies.
369
00:20:43,990 --> 00:20:46,920
And if you're interested in why this is two,
370
00:20:46,920 --> 00:20:49,410
well, the quick reason is that here,
371
00:20:49,410 --> 00:20:52,850
this selector does actually have two classes
372
00:20:52,850 --> 00:20:54,223
or pseudo classes.
373
00:20:55,180 --> 00:20:59,030
So this is one and this is two.
374
00:20:59,030 --> 00:21:01,440
And so that's why we have that two,
375
00:21:01,440 --> 00:21:03,660
and here we only have one.
376
00:21:03,660 --> 00:21:06,290
And so that's where this one comes from.
377
00:21:06,290 --> 00:21:11,220
However, we want this here to be applied always, right.
378
00:21:11,220 --> 00:21:14,160
So we want, actually, the color to be white as well.
379
00:21:14,160 --> 00:21:16,620
And so we need to make that the specificity
380
00:21:16,620 --> 00:21:17,783
is also two here.
381
00:21:19,710 --> 00:21:23,560
So what we can do is to use a new selector,
382
00:21:23,560 --> 00:21:27,400
which is basically the end selector.
383
00:21:27,400 --> 00:21:28,763
So let me write that here.
384
00:21:29,650 --> 00:21:30,570
And again, of course,
385
00:21:30,570 --> 00:21:32,280
this is not the kind of things
386
00:21:32,280 --> 00:21:34,810
that you could have figured out by yourself
387
00:21:34,810 --> 00:21:36,010
in the coding challenge.
388
00:21:37,216 --> 00:21:38,293
Right.
389
00:21:39,770 --> 00:21:44,220
So basically if we write this, but without the space here,
390
00:21:44,220 --> 00:21:45,810
that's very important,
391
00:21:45,810 --> 00:21:49,370
then that means that this only applies
392
00:21:49,370 --> 00:21:54,370
when the element has this selector and also this one.
393
00:21:54,840 --> 00:21:56,100
Okay.
394
00:21:56,100 --> 00:21:57,380
So again,
395
00:21:57,380 --> 00:22:01,540
this is the end selector and it only applies to an element
396
00:22:01,540 --> 00:22:04,103
if it has both of these classes.
397
00:22:05,440 --> 00:22:06,600
So in this case,
398
00:22:06,600 --> 00:22:11,387
it does have a "page-link" and also "page-link--current".
399
00:22:12,710 --> 00:22:16,520
Okay. And so very important, not the space.
400
00:22:16,520 --> 00:22:19,530
So with the space, it is a descendant selector,
401
00:22:19,530 --> 00:22:23,040
but without a space, it is an end selector.
402
00:22:23,040 --> 00:22:23,873
So again,
403
00:22:23,873 --> 00:22:27,320
"end" meaning that the element has both this class
404
00:22:27,320 --> 00:22:28,910
and this class.
405
00:22:28,910 --> 00:22:31,900
And so now, the selector has two classes
406
00:22:31,900 --> 00:22:34,999
and when we hover it, we see that two here.
407
00:22:34,999 --> 00:22:37,210
And so now both of them have two.
408
00:22:37,210 --> 00:22:38,320
And so in that case,
409
00:22:38,320 --> 00:22:41,510
the one that is last is the one that applies.
410
00:22:41,510 --> 00:22:46,350
And so now you see that it turned white.
411
00:22:46,350 --> 00:22:47,590
All right.
412
00:22:47,590 --> 00:22:51,660
So this part, I admit, is a bit confusing.
413
00:22:51,660 --> 00:22:53,510
So maybe go back a little bit
414
00:22:53,510 --> 00:22:56,180
and listen to my explanation again,
415
00:22:56,180 --> 00:22:58,720
because this can be a source of confusion
416
00:22:58,720 --> 00:23:00,450
when you write your own code.
417
00:23:00,450 --> 00:23:01,870
And then, in some situation,
418
00:23:01,870 --> 00:23:05,120
you might not really understand what is going on.
419
00:23:05,120 --> 00:23:06,970
Just remember that I showed you,
420
00:23:06,970 --> 00:23:08,600
in one of the first sections,
421
00:23:08,600 --> 00:23:11,390
the priority between the selectors.
422
00:23:11,390 --> 00:23:14,405
So between ID selectors and class selectors
423
00:23:14,405 --> 00:23:16,760
and element selectors,
424
00:23:16,760 --> 00:23:20,940
but there, we didn't talk about this notion of specificity.
425
00:23:20,940 --> 00:23:24,150
And I still don't want to go deep into that,
426
00:23:24,150 --> 00:23:28,530
but I just want you to use basically VS code here as a help.
427
00:23:28,530 --> 00:23:32,360
And so whenever you have one selector that has a lower value
428
00:23:33,399 --> 00:23:35,570
here in one of these points,
429
00:23:35,570 --> 00:23:38,880
then that is the one that will not get applied.
430
00:23:38,880 --> 00:23:40,660
So the one with the higher value,
431
00:23:40,660 --> 00:23:42,910
is the one that gets applied.
432
00:23:42,910 --> 00:23:47,137
Okay. And again, now both here are at two, so (0,2,0),
433
00:23:48,600 --> 00:23:51,813
and then it is the last of the two that gets applied.
434
00:23:53,060 --> 00:23:55,360
So if we changed this here to the top,
435
00:23:55,360 --> 00:23:57,440
then it would still not work.
436
00:23:57,440 --> 00:23:58,273
So only now,
437
00:23:58,273 --> 00:24:01,663
because it is the last one is the reason why it works.
438
00:24:02,949 --> 00:24:06,253
And I think, with this, we actually finished this component.
439
00:24:07,440 --> 00:24:09,900
Yep. Everything works nicely.
440
00:24:09,900 --> 00:24:12,260
And so that is it.
441
00:24:12,260 --> 00:24:17,133
So everything works nicely and so our work is done here.
31737
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.