Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,110 --> 00:00:12,050
Our next block on the home page the revolution block requires that we use a new material UI component.
2
00:00:12,090 --> 00:00:19,980
This is the card component and you'll see that it is a very flexible and powerful component that allows
3
00:00:19,980 --> 00:00:23,520
you to pack a lot of functionality.
4
00:00:23,550 --> 00:00:30,690
Let's go over to the material UI documentation and I'll go over all of the options that we have here.
5
00:00:32,590 --> 00:00:40,580
I'm here on the documentation page under components surfaces and cards.
6
00:00:40,800 --> 00:00:50,810
They tell us here that a card contains content and actions about a single subject cards are a very basic
7
00:00:50,900 --> 00:00:56,250
UI component that I'm sure most Web sites use in some form of another.
8
00:00:56,360 --> 00:01:00,460
And you can see a good example here of a simple implementation.
9
00:01:00,590 --> 00:01:05,460
And then we have our content which is this text here up on the top.
10
00:01:05,630 --> 00:01:07,250
And then our actions.
11
00:01:07,250 --> 00:01:14,820
Is this Learn More button down on the bottom if we go ahead and open this up to see what's going on
12
00:01:14,820 --> 00:01:15,510
here.
13
00:01:15,510 --> 00:01:18,480
We'll see that they import the card.
14
00:01:18,480 --> 00:01:28,490
Card actions and card content components we scroll down we'll see that they use them here in a similar
15
00:01:28,490 --> 00:01:33,760
stacking fashion as all of the rest of the material UI components have done.
16
00:01:34,100 --> 00:01:38,540
So you can see we start with an opening card component.
17
00:01:38,570 --> 00:01:47,750
That is our outer most components and within the card components we have an adjacent card content and
18
00:01:47,810 --> 00:01:51,240
a card actions component.
19
00:01:51,320 --> 00:01:58,340
Like I said this first part with all of the text describing the word is our card content.
20
00:01:58,520 --> 00:02:07,320
While the learn more button at the bottom is our card actions by using these two separate material UI
21
00:02:07,320 --> 00:02:11,670
components within the larger card components.
22
00:02:11,670 --> 00:02:17,310
All of these styling and alignment will be automatically taken care of.
23
00:02:17,310 --> 00:02:20,280
And in more complex examples that we'll see below.
24
00:02:20,280 --> 00:02:22,300
This really comes in handy.
25
00:02:22,350 --> 00:02:28,980
So we'll scroll down and let's take a look at some more complex examples like this one here is a great
26
00:02:28,980 --> 00:02:32,310
example with a lot of different elements going on.
27
00:02:32,310 --> 00:02:37,350
So it's got this top section with our little avatar icon here.
28
00:02:37,470 --> 00:02:39,870
A title a subtitle.
29
00:02:39,870 --> 00:02:46,830
And then we also have an expansion button here as well as an expansion button down below which actually
30
00:02:46,830 --> 00:02:48,540
expands our card.
31
00:02:48,720 --> 00:02:55,980
And that is using a collapse component which is a material UI component that we will go over in the
32
00:02:55,980 --> 00:02:58,130
second project of this course.
33
00:02:58,410 --> 00:03:04,500
But let's go and open this up to see how that they are creating these effects.
34
00:03:04,500 --> 00:03:11,340
So we'll open this up and you'll see now that they are importing the card component as well as a card
35
00:03:11,340 --> 00:03:19,440
header component a card media component as well as the card contents and card actions components that
36
00:03:19,440 --> 00:03:21,930
we're familiar with from the last example.
37
00:03:21,930 --> 00:03:26,340
So the new ones here are the card header and the card media.
38
00:03:26,490 --> 00:03:33,030
And we'll see when we scroll down that they again begin with their outer card component.
39
00:03:33,030 --> 00:03:39,660
But the first component within the card is now our card header and that is a self closing component
40
00:03:39,960 --> 00:03:48,620
that takes a set of props you see they're passing in an avatar component for the Avatar prop an icon
41
00:03:48,620 --> 00:03:54,750
button for the action prop and the title in the sub header text as well.
42
00:03:54,770 --> 00:04:04,140
These are all then rendered down to the header that we see below with our avatar the title and the sub
43
00:04:04,140 --> 00:04:08,830
header and then our little icon expansion button here.
44
00:04:08,910 --> 00:04:14,150
That is our actions to see the action prop right there.
45
00:04:15,150 --> 00:04:20,850
And just by passing in that button it automatically is handling the styling for putting that over on
46
00:04:20,850 --> 00:04:27,390
the right side your alignment between your title and sub header and all of these spacing for those elements
47
00:04:27,630 --> 00:04:36,780
in between and then right underneath our card header we have the card media component card and media
48
00:04:36,810 --> 00:04:46,080
component and that simply takes an image directly as well as a title and a class name for all your styles.
49
00:04:46,110 --> 00:04:54,750
So the title is used for the alt tag and you can see when I leave the mouse over the image it displays
50
00:04:54,750 --> 00:04:56,120
that text as well.
51
00:04:56,430 --> 00:05:04,050
So that is just the card media component that automatically creates that style that you see in underneath
52
00:05:04,050 --> 00:05:04,860
the card media.
53
00:05:04,890 --> 00:05:12,350
They have the card content component that we're familiar with from before in this example that simply
54
00:05:12,350 --> 00:05:20,480
has one big paragraph inside a typography component and then underneath it we have the card actions
55
00:05:20,510 --> 00:05:23,040
and that gives us this last row right here.
56
00:05:24,330 --> 00:05:33,030
Where we have all three of our icon buttons as well as below it has the collapse components and all
57
00:05:33,030 --> 00:05:38,100
of the card content for this extra space here.
58
00:05:38,250 --> 00:05:45,720
But hopefully that gives you a good example of what you can do with the card component and the flexibility
59
00:05:45,780 --> 00:05:52,590
as well as the adaptability of this card component to easily and appropriately style the content that
60
00:05:52,590 --> 00:05:53,590
you pass to it.
61
00:05:54,520 --> 00:06:03,520
We can scroll down here below and it gives us more examples of how to use the image within your cards.
62
00:06:03,630 --> 00:06:09,130
And the nice style that it applies for that as well as down here below.
63
00:06:09,160 --> 00:06:18,320
An example of how you can use the actions within a card to create a UI controls so you can see that
64
00:06:18,390 --> 00:06:22,730
by the way you pass in data differently and set up your card.
65
00:06:22,800 --> 00:06:30,540
You can create these different but really clean layouts like this horizontal layout for the UI control
66
00:06:30,780 --> 00:06:38,130
but all of the vertical layouts we've seen above and that all depends on how you style the content within
67
00:06:38,190 --> 00:06:39,330
your card.
68
00:06:39,360 --> 00:06:45,990
So if we come and we take a look at this example we can see we scroll down here how they're using the
69
00:06:46,020 --> 00:06:54,810
card media components underneath a div containing all of the other card content to separate and create
70
00:06:54,870 --> 00:06:57,010
this style that we see.
71
00:06:57,270 --> 00:07:03,770
And if we come up to one of these examples we can see the difference when we open this up.
72
00:07:03,780 --> 00:07:12,270
They are using the card a media component within their card action area components but on top of the
73
00:07:12,270 --> 00:07:17,030
card content and so that is creating the different layout here.
74
00:07:17,100 --> 00:07:23,550
So it's all just about arranging your components in the right order in the right way and then passing
75
00:07:23,550 --> 00:07:30,300
in the right content to create the styles that you want and you can always remember the down here below
76
00:07:30,570 --> 00:07:37,380
it at the API section here you can go and see any of the different components that are being used for
77
00:07:37,380 --> 00:07:43,020
the card component like the card header and if you click on any of these you can then see all of the
78
00:07:43,020 --> 00:07:46,920
different props that you have available to you to customize it.
79
00:07:47,010 --> 00:07:52,520
So when you're working on your own projects if you can't remember a certain piece of functionality then
80
00:07:52,590 --> 00:07:53,900
always come here and check.
81
00:07:53,900 --> 00:08:00,630
This is the first place before you work on setting up your own custom styles or functionality.
82
00:08:00,630 --> 00:08:07,020
I think that's about all there is to the card component though it's pretty similar to like the list
83
00:08:07,020 --> 00:08:13,410
component that we used before and a bunch of these other sandwich structured components where you use
84
00:08:13,410 --> 00:08:15,360
the different card content.
85
00:08:15,360 --> 00:08:20,700
The card actions components within the card component and I think that that breaks it down to make it
86
00:08:20,700 --> 00:08:26,460
really clear how everything is working but we'll get an even better feel for it when we actually use
87
00:08:26,460 --> 00:08:32,880
the card component to build our revolution block on the home page in the next video.
9931
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.