Enhancing our UI with Styled components

5 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$49.99
List Price:  $69.99
You save:  $20
€43.65
List Price:  €61.12
You save:  €17.46
£37.73
List Price:  £52.83
You save:  £15.09
CA$68.48
List Price:  CA$95.88
You save:  CA$27.39
A$71.16
List Price:  A$99.63
You save:  A$28.47
S$64.02
List Price:  S$89.63
You save:  S$25.61
HK$391.46
List Price:  HK$548.08
You save:  HK$156.61
CHF 39.45
List Price:  CHF 55.24
You save:  CHF 15.78
NOK kr486.15
List Price:  NOK kr680.65
You save:  NOK kr194.49
DKK kr326.22
List Price:  DKK kr456.73
You save:  DKK kr130.51
NZ$85.85
List Price:  NZ$120.20
You save:  NZ$34.34
د.إ183.58
List Price:  د.إ257.03
You save:  د.إ73.45
৳6,144.50
List Price:  ৳8,602.80
You save:  ৳2,458.29
₹4,620.07
List Price:  ₹6,468.47
You save:  ₹1,848.39
RM196.48
List Price:  RM275.09
You save:  RM78.61
₦69,356.62
List Price:  ₦97,104.82
You save:  ₦27,748.20
₨13,981.74
List Price:  ₨19,575.56
You save:  ₨5,593.81
฿1,626.04
List Price:  ฿2,276.59
You save:  ฿650.55
₺2,209.10
List Price:  ₺3,092.92
You save:  ₺883.81
B$268.30
List Price:  B$375.65
You save:  B$107.34
R843.76
List Price:  R1,181.33
You save:  R337.57
Лв85.38
List Price:  Лв119.54
You save:  Лв34.16
₩74,787.50
List Price:  ₩104,708.49
You save:  ₩29,920.98
₪156.79
List Price:  ₪219.52
You save:  ₪62.72
₱2,989.35
List Price:  ₱4,185.33
You save:  ₱1,195.98
¥7,964.55
List Price:  ¥11,151.01
You save:  ¥3,186.45
MX$891.91
List Price:  MX$1,248.74
You save:  MX$356.83
QR182.02
List Price:  QR254.85
You save:  QR72.82
P682.34
List Price:  P955.34
You save:  P272.99
KSh6,462.70
List Price:  KSh9,048.30
You save:  KSh2,585.60
E£2,620.81
List Price:  E£3,669.34
You save:  E£1,048.53
ብር7,816.27
List Price:  ብር10,943.40
You save:  ብር3,127.13
Kz45,597.42
List Price:  Kz63,840.04
You save:  Kz18,242.62
CLP$46,025.29
List Price:  CLP$64,439.09
You save:  CLP$18,413.80
CN¥344.74
List Price:  CN¥482.66
You save:  CN¥137.92
RD$3,076.41
List Price:  RD$4,307.22
You save:  RD$1,230.81
DA6,623.73
List Price:  DA9,273.75
You save:  DA2,650.02
FJ$110.99
List Price:  FJ$155.39
You save:  FJ$44.40
Q384
List Price:  Q537.63
You save:  Q153.63
GY$10,476.18
List Price:  GY$14,667.49
You save:  GY$4,191.31
ISK kr6,296.24
List Price:  ISK kr8,815.24
You save:  ISK kr2,519
DH471.62
List Price:  DH660.30
You save:  DH188.68
L875.48
List Price:  L1,225.75
You save:  L350.26
ден2,692.03
List Price:  ден3,769.07
You save:  ден1,077.03
MOP$403.66
List Price:  MOP$565.16
You save:  MOP$161.49
N$841.02
List Price:  N$1,177.50
You save:  N$336.47
C$1,842.53
List Price:  C$2,579.69
You save:  C$737.15
रु7,395.40
List Price:  रु10,354.15
You save:  रु2,958.75
S/172.68
List Price:  S/241.76
You save:  S/69.08
K218.96
List Price:  K306.56
You save:  K87.60
SAR187.58
List Price:  SAR262.64
You save:  SAR75.05
ZK974.65
List Price:  ZK1,364.60
You save:  ZK389.94
L222.40
List Price:  L311.38
You save:  L88.98
Kč1,066.96
List Price:  Kč1,493.84
You save:  Kč426.87
Ft17,099.08
List Price:  Ft23,940.09
You save:  Ft6,841
SEK kr470.37
List Price:  SEK kr658.56
You save:  SEK kr188.18
ARS$69,898.52
List Price:  ARS$97,863.52
You save:  ARS$27,965
Bs346.01
List Price:  Bs484.45
You save:  Bs138.43
COP$184,354.73
List Price:  COP$258,111.38
You save:  COP$73,756.64
₡23,559.94
List Price:  ₡32,985.81
You save:  ₡9,425.86
L1,325.48
List Price:  L1,855.78
You save:  L530.30
₲323,053.08
List Price:  ₲452,300.17
You save:  ₲129,247.08
$U2,018.88
List Price:  $U2,826.59
You save:  $U807.71
zł186.41
List Price:  zł260.99
You save:  zł74.57
Already have an account? Log In

Transcript

I did us very small refactoring. So as you can see, I've introduced our loading property in our state, that is default true. I have removed the test get method and have created a component did mount, we felt that it's a react related method, in which I'm going to take up to retrieve the list of articles as soon as the component is mounted. So, when I get back the articles I set the loading property to false even here, so, this is our new render method. So we take the loading property from the state. If we are loading if you are still learning we just show up simple my such loading articles otherwise We are going to create our carts according to the articles in the state.

So if you are fast enough, you can check here loading loading articles before the e commerce title and articles are shown. Now let's see how we can add some style here. For example, what if we have if you want to have the title, center it uppercase and with some margin, of course the first thing we can do we can use some bootstrap classes for example, tax center to center it takes uppercase to make it uppercase. And for example, we can have our vertical margin of five. So if we save here what we have but I would like to introduce the concept of standard components as you can see here, this is the common to Eastern All stellar components I have already done it. So what we are going to do is to create for example, ecommerce title, ecommerce title and we are using styled components right here.

So for example, we will have ecommerce title that is tired dot div dot not sorry that h1 and we import import styling from started components. And we can have here for example, text center margin Donal 15 pixels z Excel Text throngs for per case and should be everything he really is. If you want to increase the margin, this is it. And it's interesting because we can use PDO query here inside so for example, we can do let's say fleet and you can have for example color green. So if we are going to increase, this is green. Okay, so this is very interesting.

So, we want to treat again and we Want to create some margin in the cart? This is just an exercise. Of course you can use classes but cart with top margin. So in this case, it's not an HTML element elements. So what we can do, what we should do is to use it like this. So card and what we do is to use two, create our marching talk.

Here's our margin. The last thing we see here you we just we just create a small border. In the bottom of our image so for example, we can do like this. And we just create or the bottom one piece. So, for example, with some color and we're currently emoji becomes like this

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.