Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,040 --> 00:00:04,880
Let's continue working on our project here.
2
00:00:04,880 --> 00:00:07,660
And let's continue with this link.
3
00:00:07,660 --> 00:00:09,700
At the moment, it looks a bit boring.
4
00:00:09,700 --> 00:00:13,670
And I would like to have that link look like a button.
5
00:00:13,670 --> 00:00:17,510
Now, we'll also use a button in some other places
6
00:00:17,510 --> 00:00:21,050
of our project and, therefore, instead of styling it here,
7
00:00:21,050 --> 00:00:23,070
in the event item component,
8
00:00:23,070 --> 00:00:26,510
I'll add a new component, which we can then reuse,
9
00:00:26,510 --> 00:00:28,400
which I'll add in a new folder,
10
00:00:28,400 --> 00:00:31,430
which I'll name UI for user interface.
11
00:00:31,430 --> 00:00:36,430
And in there, I'll add button.js file.
12
00:00:36,920 --> 00:00:39,260
To create a button component in there,
13
00:00:39,260 --> 00:00:43,460
which sets up this button so that we have a reusable button.
14
00:00:43,460 --> 00:00:45,530
For this, in this button.js file,
15
00:00:45,530 --> 00:00:49,030
we create a button component like this.
16
00:00:49,030 --> 00:00:52,260
A functional component which we, of course, also export.
17
00:00:52,260 --> 00:00:56,683
And then, in here, I will return a link.
18
00:00:57,610 --> 00:01:01,870
And, for this, we need to import link from next/link.
19
00:01:01,870 --> 00:01:04,819
And that link should, of course, hold a text
20
00:01:04,819 --> 00:01:06,910
which is passed in from outside.
21
00:01:06,910 --> 00:01:09,300
So, between the opening and closing tags
22
00:01:09,300 --> 00:01:11,430
of our button component, hence,
23
00:01:11,430 --> 00:01:13,513
we can use props.children here.
24
00:01:14,370 --> 00:01:17,220
And, of course, it should also lead somewhere.
25
00:01:17,220 --> 00:01:22,040
And I expect to get a link prop on this button,
26
00:01:22,040 --> 00:01:24,680
which holds the actual link we wanna to go to
27
00:01:24,680 --> 00:01:29,343
and set this as a value for the ref prop here.
28
00:01:30,280 --> 00:01:32,280
Now, we got this button component,
29
00:01:32,280 --> 00:01:36,810
attached you now find this button.module.css file
30
00:01:36,810 --> 00:01:39,023
with some styles for this button.
31
00:01:39,900 --> 00:01:42,150
And, just as before, to apply them
32
00:01:42,150 --> 00:01:47,150
we now need to import classes from ./button.module.css.
33
00:01:50,020 --> 00:01:53,470
And then, to add those classes here,
34
00:01:53,470 --> 00:01:56,630
we need to actually add an element inside
35
00:01:56,630 --> 00:02:01,630
of the link component, we need to add an anchor tag element.
36
00:02:02,600 --> 00:02:04,920
And then, on this anchor tag element
37
00:02:04,920 --> 00:02:08,943
we can set the class name and set this to classes.button.
38
00:02:09,949 --> 00:02:12,640
Now, if we don't add the anchor tag,
39
00:02:12,640 --> 00:02:15,530
then the link automatically renders
40
00:02:15,530 --> 00:02:17,250
an anchor tag under the hood,
41
00:02:17,250 --> 00:02:19,980
an anchor tag, where it basically controls
42
00:02:19,980 --> 00:02:22,500
what happens when that link is clicked though,
43
00:02:22,500 --> 00:02:25,510
so that we don't send a request for a new file,
44
00:02:25,510 --> 00:02:28,020
but instead it captures that request
45
00:02:28,020 --> 00:02:32,110
and loads a new page with JavaScript only.
46
00:02:32,110 --> 00:02:34,750
But if you want to apply custom styling,
47
00:02:34,750 --> 00:02:38,310
then you need to add that anchor tag on your own.
48
00:02:38,310 --> 00:02:41,340
And the link component will basically detect
49
00:02:41,340 --> 00:02:44,450
that there now is a anchor tag inside of it,
50
00:02:44,450 --> 00:02:47,910
and it will no longer render its own anchor tag
51
00:02:47,910 --> 00:02:49,990
but instead render yours,
52
00:02:49,990 --> 00:02:52,880
but then add all that functionality
53
00:02:52,880 --> 00:02:57,060
where it captures clicks on that link and so on for you.
54
00:02:57,060 --> 00:03:00,110
So, it will add that functionality, that all works.
55
00:03:00,110 --> 00:03:03,740
We just add our own anchor tag to add classes.
56
00:03:03,740 --> 00:03:06,460
We don't, and that's important,
57
00:03:06,460 --> 00:03:11,010
we don't set the ref attribute on this anchor tag though,
58
00:03:11,010 --> 00:03:14,270
as I just said, that will be added automatically
59
00:03:14,270 --> 00:03:17,650
by the link component, which is right wrapped around that.
60
00:03:17,650 --> 00:03:20,090
So, we just set it up like this.
61
00:03:20,090 --> 00:03:22,250
And, now, we can use this button component
62
00:03:22,250 --> 00:03:24,210
in the event item component.
63
00:03:24,210 --> 00:03:29,210
Here, instead of this link, we can now use our own button.
64
00:03:30,160 --> 00:03:34,930
And, of course, for that make sure you also import button
65
00:03:34,930 --> 00:03:38,003
from the UI folder, and the button file.
66
00:03:39,630 --> 00:03:44,020
And then, here, we can still say explore event.
67
00:03:44,020 --> 00:03:47,480
And, now, we set the link prop on the button component
68
00:03:47,480 --> 00:03:49,760
because that's what I'm expecting here,
69
00:03:49,760 --> 00:03:54,760
I'm expecting a link prop and I set this here equal
70
00:03:54,890 --> 00:03:59,110
to the explorer link, just as before.
71
00:03:59,110 --> 00:04:00,930
And of course this button, technically,
72
00:04:00,930 --> 00:04:02,670
now isn't a button but a link,
73
00:04:02,670 --> 00:04:05,933
but it will look like a button, hence the component name.
74
00:04:07,070 --> 00:04:08,670
If you now save all files,
75
00:04:08,670 --> 00:04:10,833
you should have this button look here.
76
00:04:11,810 --> 00:04:15,150
Now, adding a button was one important thing.
77
00:04:15,150 --> 00:04:18,320
I also want to add a couple of icons to ensure
78
00:04:18,320 --> 00:04:21,692
that the event items we're rendering look a bit nicer.
79
00:04:22,610 --> 00:04:25,190
For this, I prepared some icons for you,
80
00:04:25,190 --> 00:04:28,120
some icon components, which you'll find attached.
81
00:04:28,120 --> 00:04:32,350
To be precise, attached you find an icons ZIP file,
82
00:04:32,350 --> 00:04:36,670
which you can extract into your components folder,
83
00:04:36,670 --> 00:04:39,810
so that you end up with a third folder
84
00:04:39,810 --> 00:04:42,810
in the components folder, this icons folder,
85
00:04:42,810 --> 00:04:45,710
which holds free JavaScript files,
86
00:04:45,710 --> 00:04:48,260
which hold react component functions,
87
00:04:48,260 --> 00:04:50,750
which return SVG icons.
88
00:04:50,750 --> 00:04:53,530
Now, these icons are not created by me.
89
00:04:53,530 --> 00:04:55,230
I'm just sharing them with you,
90
00:04:55,230 --> 00:04:58,730
so that we don't have to write that code together.
91
00:04:58,730 --> 00:05:02,840
Instead, these are icons from heroicons.com.
92
00:05:02,840 --> 00:05:07,580
Here, I picked this location marker icon,
93
00:05:07,580 --> 00:05:12,580
I picked the calendar icon, and this arrow right icon.
94
00:05:12,900 --> 00:05:16,080
These icons are taken from heroicons.com
95
00:05:16,080 --> 00:05:19,120
and I just pre-created these components for you,
96
00:05:19,120 --> 00:05:21,993
so that we don't have to write all that code together.
97
00:05:22,980 --> 00:05:26,950
But I just copied the JSX code from heroicons.com.
98
00:05:26,950 --> 00:05:30,040
It's super easy to do, you even get a button for that here.
99
00:05:30,040 --> 00:05:32,633
And I created these components.
100
00:05:33,690 --> 00:05:36,450
Now, with these components added, we can go back
101
00:05:36,450 --> 00:05:40,660
to event-item.js and, there, I now got a couple
102
00:05:40,660 --> 00:05:44,580
of places where these icons should be inserted.
103
00:05:44,580 --> 00:05:47,990
For example, here, in front of the time.
104
00:05:47,990 --> 00:05:52,990
There, I want to render the date icon, so I'll add it here
105
00:05:53,660 --> 00:05:55,920
and we, now, need to import it.
106
00:05:55,920 --> 00:05:59,240
We need to import DateIcon from
107
00:05:59,240 --> 00:06:04,240
and then go up one level into icons/date-icon, like this.
108
00:06:05,210 --> 00:06:08,180
We can now also remove link import, by the way,
109
00:06:08,180 --> 00:06:10,330
since we're not using the link component
110
00:06:10,330 --> 00:06:12,163
in this component anymore.
111
00:06:13,010 --> 00:06:15,540
So, that's the date icon added.
112
00:06:15,540 --> 00:06:20,540
Above the address, I wanna add the address icon, like this.
113
00:06:21,480 --> 00:06:24,140
And for that, you, of course, also need
114
00:06:24,140 --> 00:06:26,343
to add the appropriate import,
115
00:06:27,620 --> 00:06:31,590
and we can also already import the ArrowRightIcon
116
00:06:32,760 --> 00:06:37,760
from /icons/arrow-right-icon,
117
00:06:38,220 --> 00:06:40,983
because I will render that in my button.
118
00:06:42,400 --> 00:06:44,750
Here in this button, I don't just want
119
00:06:44,750 --> 00:06:47,800
to have this explore event text.
120
00:06:47,800 --> 00:06:52,320
Instead, this text should sit side by side to an icon.
121
00:06:52,320 --> 00:06:55,730
Hence, I'll wrap this text in a span
122
00:06:55,730 --> 00:06:58,403
and then add another span here.
123
00:07:01,380 --> 00:07:05,223
And in that second span I'll render this ArrowRightIcon,
124
00:07:06,620 --> 00:07:11,120
which I just imported, and this second span important
125
00:07:11,120 --> 00:07:16,120
also receives a class, it receives the icon class, like this
126
00:07:18,990 --> 00:07:22,520
Again, if you save all files and you go back
127
00:07:22,520 --> 00:07:24,690
you now should see these icons
128
00:07:24,690 --> 00:07:29,090
as part of these event cards here.
129
00:07:29,090 --> 00:07:33,480
And that is, now, the final look of the event items.
130
00:07:33,480 --> 00:07:36,320
We spent quite some time on them, but we will use them
131
00:07:36,320 --> 00:07:39,280
in a lot of different places of this application.
132
00:07:39,280 --> 00:07:40,430
And therefore, that is, of course,
133
00:07:40,430 --> 00:07:43,543
something which I did want to make look good.
134
00:07:44,380 --> 00:07:46,820
Now, let's work on the other pages
135
00:07:46,820 --> 00:07:50,920
because, thus far, we never left the starting page.
136
00:07:50,920 --> 00:07:53,700
And we got more pages, for example,
137
00:07:53,700 --> 00:07:56,720
we got the page for a single event
138
00:07:56,720 --> 00:07:59,900
and we can reach that page for a given event ID,
139
00:07:59,900 --> 00:08:03,550
if we click those buttons, the explore event buttons.
140
00:08:03,550 --> 00:08:08,320
That sets the URL to /events/ID and loads
141
00:08:08,320 --> 00:08:12,120
the event detail page, so time to work on that.
142
00:08:12,120 --> 00:08:14,290
And, of course, feel free to start working
143
00:08:14,290 --> 00:08:18,060
on that on your own, output some event data there.
144
00:08:18,060 --> 00:08:20,980
In the next lecture, we're going to work on it together.
145
00:08:20,980 --> 00:08:22,320
And we're then, also going to add
146
00:08:22,320 --> 00:08:24,083
some styles together, of course.
11986
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.