Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,070 --> 00:00:05,700
So, some kind of general layout would be nice.
2
00:00:05,700 --> 00:00:09,900
A general navigation bar, which we have on all our pages
3
00:00:09,900 --> 00:00:12,660
because at the moment we don't have that.
4
00:00:12,660 --> 00:00:13,493
Now for dat,
5
00:00:13,493 --> 00:00:16,400
we can of course dive into all our page components
6
00:00:16,400 --> 00:00:20,090
and start adding some some header at the top.
7
00:00:20,090 --> 00:00:23,160
So above our main content, we could add a header
8
00:00:23,160 --> 00:00:25,520
with a nav bar and so on.
9
00:00:25,520 --> 00:00:27,110
And we could do that
10
00:00:27,110 --> 00:00:31,020
but we would repeat that code for all our page components
11
00:00:31,020 --> 00:00:33,680
in the end, since I wanna have the same navigation bar
12
00:00:33,680 --> 00:00:35,393
in all those components.
13
00:00:36,300 --> 00:00:39,740
And the dat is where dis _app.js file
14
00:00:39,740 --> 00:00:41,910
now becomes important.
15
00:00:41,910 --> 00:00:45,240
This in the end is the root component
16
00:00:45,240 --> 00:00:49,690
where the different page components are rendered in.
17
00:00:49,690 --> 00:00:51,890
This component, which is rendered here
18
00:00:51,890 --> 00:00:55,410
that's your page component in the end next to js
19
00:00:55,410 --> 00:01:00,410
we'll use this _app component to hand your page content
20
00:01:00,820 --> 00:01:05,090
to it to then display it whenever you switch the page.
21
00:01:05,090 --> 00:01:06,980
So that's your page being rendered,
22
00:01:06,980 --> 00:01:08,700
this component.
23
00:01:08,700 --> 00:01:12,530
That means that we of course can wrap this component
24
00:01:12,530 --> 00:01:15,620
with some general layout component.
25
00:01:15,620 --> 00:01:17,430
We could wrap it with a fragment
26
00:01:17,430 --> 00:01:19,790
and add a header on top of it.
27
00:01:19,790 --> 00:01:23,620
And that is exactly what we're now going to do.
28
00:01:23,620 --> 00:01:26,100
For this in the components folder,
29
00:01:26,100 --> 00:01:29,030
I'll add a new sub folder side by side
30
00:01:29,030 --> 00:01:31,990
to event-detail, events, icons, and ui
31
00:01:31,990 --> 00:01:33,803
and I will name it layout.
32
00:01:35,310 --> 00:01:39,280
And in this folder, I'll now add a layout.js file
33
00:01:40,530 --> 00:01:44,363
and a main-header.js file.
34
00:01:45,200 --> 00:01:48,430
Now the layout.js file will be fairly trivial.
35
00:01:48,430 --> 00:01:52,380
It holds a functional component, the layout component
36
00:01:52,380 --> 00:01:55,460
and that component will receive some props.
37
00:01:55,460 --> 00:01:59,520
And of course, we also export this layout component here.
38
00:01:59,520 --> 00:02:04,040
And then here, I just want to return a fragment
39
00:02:04,040 --> 00:02:06,500
which we import from react.
40
00:02:06,500 --> 00:02:07,770
So we import from react.
41
00:02:07,770 --> 00:02:12,350
We import the fragment and then a main HTML element
42
00:02:12,350 --> 00:02:15,770
between which I output props.children.
43
00:02:15,770 --> 00:02:18,660
But then above that also my header
44
00:02:19,750 --> 00:02:22,790
and I'll create that header in a separate file
45
00:02:22,790 --> 00:02:25,650
in the main-header.js file.
46
00:02:25,650 --> 00:02:30,650
In there we add another component, the main-header component
47
00:02:31,100 --> 00:02:35,240
which we also export as a default here.
48
00:02:35,240 --> 00:02:38,010
And then in here in this main-header component
49
00:02:38,010 --> 00:02:40,743
we return our header coat.
50
00:02:41,630 --> 00:02:45,740
So here we'll have a header wrapper HTML element.
51
00:02:45,740 --> 00:02:49,220
And then in there a div, which holds our logo,
52
00:02:49,220 --> 00:02:51,480
our logo text in this case
53
00:02:51,480 --> 00:02:55,520
since we'll not have any image logo in this application
54
00:02:55,520 --> 00:02:58,960
and next to that logo we'll then have a nav bar
55
00:02:58,960 --> 00:03:01,073
with our navigation items.
56
00:03:02,480 --> 00:03:05,870
But let's start with the logo that will be fairly trivial,
57
00:03:05,870 --> 00:03:09,360
I'll make it clickable by adding a link here.
58
00:03:09,360 --> 00:03:13,400
And hence, we need to import link from next/link
59
00:03:13,400 --> 00:03:17,563
and I'll say, NextEvents here, that's my logo text.
60
00:03:18,410 --> 00:03:19,740
And it should be clickable
61
00:03:19,740 --> 00:03:22,560
and always take us back to the starting page.
62
00:03:22,560 --> 00:03:26,249
Hence ref here is just /nothing,
63
00:03:26,249 --> 00:03:29,390
slash nothing so dat when we click the logo
64
00:03:29,390 --> 00:03:31,453
we're taken back to the starting page.
65
00:03:32,870 --> 00:03:37,700
Now in the nav part here, I'll add an unordered list
66
00:03:37,700 --> 00:03:40,400
of all the navigation items
67
00:03:40,400 --> 00:03:45,120
though here it'll only be one nav item, which also is a link
68
00:03:45,120 --> 00:03:47,690
because it all does should be clickable.
69
00:03:47,690 --> 00:03:50,320
And here I'll say All Events
70
00:03:50,320 --> 00:03:53,633
because this should take me to the All Events page.
71
00:03:54,680 --> 00:03:57,540
Or we say Browse All Events
72
00:03:58,440 --> 00:04:02,510
and therefore here ref is /events to take us
73
00:04:02,510 --> 00:04:04,193
to this events page.
74
00:04:06,160 --> 00:04:09,200
Now some styling would be nice and therefore, again,
75
00:04:09,200 --> 00:04:12,490
attached you'll find a CSS file.
76
00:04:12,490 --> 00:04:17,490
You'll find the main-header.module.css file attached
77
00:04:17,640 --> 00:04:21,850
which contains some styles for this main-header component.
78
00:04:21,850 --> 00:04:23,950
And hence we should import
79
00:04:25,620 --> 00:04:26,907
classes from
80
00:04:26,907 --> 00:04:31,360
./main-header.module.css here
81
00:04:31,360 --> 00:04:34,823
and assign these classes to the HTML code.
82
00:04:35,810 --> 00:04:38,120
On the header element for example,
83
00:04:38,120 --> 00:04:41,870
you should assign a class of .header,
84
00:04:41,870 --> 00:04:45,620
So classes.header on that div with the logo
85
00:04:45,620 --> 00:04:48,590
it's classes.logo.
86
00:04:48,590 --> 00:04:49,520
On the nav,
87
00:04:49,520 --> 00:04:50,680
it's
88
00:04:50,680 --> 00:04:52,860
classes.navigation
89
00:04:52,860 --> 00:04:53,750
and that's it.
90
00:04:53,750 --> 00:04:56,563
These are the three classes which are added here.
91
00:04:57,520 --> 00:05:00,820
With dat we prepared the main-header component.
92
00:05:00,820 --> 00:05:02,710
And now in the layout component,
93
00:05:02,710 --> 00:05:05,350
we can add the main-header here
94
00:05:05,350 --> 00:05:06,183
above
95
00:05:06,183 --> 00:05:07,670
our main
96
00:05:07,670 --> 00:05:08,840
HTML
97
00:05:08,840 --> 00:05:10,040
element.
98
00:05:10,040 --> 00:05:12,410
So for this, we need to import main-header
99
00:05:12,410 --> 00:05:14,680
and then render it here.
100
00:05:14,680 --> 00:05:18,610
And now we just wanna wrap our overall layout
101
00:05:18,610 --> 00:05:21,080
around all the page content.
102
00:05:21,080 --> 00:05:23,520
And that is exactly what we can do
103
00:05:23,520 --> 00:05:27,070
with this _app.js file.
104
00:05:27,070 --> 00:05:30,020
We simply wrap this component
105
00:05:30,020 --> 00:05:32,573
which is our page content with,
106
00:05:33,790 --> 00:05:34,760
layout.
107
00:05:34,760 --> 00:05:38,480
So with our own layout component like this
108
00:05:38,480 --> 00:05:39,370
and for dis of course,
109
00:05:39,370 --> 00:05:42,010
you should make sure that you import layout
110
00:05:42,010 --> 00:05:45,350
this layout component which we just worked on.
111
00:05:45,350 --> 00:05:48,120
And we can wrap layout around that
112
00:05:48,120 --> 00:05:52,300
because in layout we do pass props.children.
113
00:05:52,300 --> 00:05:54,230
So the content between the opening
114
00:05:54,230 --> 00:05:59,090
and closing layout tags on to this main HTML element.
115
00:05:59,090 --> 00:06:01,860
So we render it between those main tasks.
116
00:06:01,860 --> 00:06:05,010
And hence, now if you save all files
117
00:06:05,010 --> 00:06:07,540
you should see this navigation bar at the top.
118
00:06:07,540 --> 00:06:09,100
And if I click on NextEvents
119
00:06:09,100 --> 00:06:11,010
I'm taken back to the starting page.
120
00:06:11,010 --> 00:06:13,040
If I click on browse, All Events,
121
00:06:13,040 --> 00:06:15,970
I'm taken to the All Events page
122
00:06:15,970 --> 00:06:19,660
where we haven't added any content yet.
123
00:06:19,660 --> 00:06:21,760
And therefore dats the next step,
124
00:06:21,760 --> 00:06:25,143
let's work on this All Events page now.
9388
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.