Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 3da218b

Browse files
committed
Style updates for Contentful components
- Adds `tc-typography` SCSS mixin for textual blocks - Updates button styles to play well with that mixin (they used to have style priority conflicts).
1 parent f38ec2f commit 3da218b

File tree

8 files changed

+143
-26
lines changed

8 files changed

+143
-26
lines changed

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"lint:scss": "./node_modules/.bin/stylelint **/*.scss --syntax scss",
3333
"test": "npm run lint && npm run jest"
3434
},
35-
"version": "0.5.1",
35+
"version": "0.5.2",
3636
"dependencies": {
3737
"react": "^16.4.1",
3838
"react-css-super-themr": "^2.2.0",

src/shared/components/buttons/themes/danger.scss

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,23 @@
44

55
@import "default";
66

7-
.button {
7+
@mixin button {
88
background: $tc-red-70;
99
border-color: transparent;
1010
color: $tc-white;
1111
}
1212

13-
.disabled {
13+
.button.disabled {
14+
@include button;
15+
1416
background-color: $tc-gray-20;
1517
opacity: 1;
1618
}
1719

18-
.link,
19-
.regular {
20+
.button.link,
21+
.button.regular {
22+
@include button;
23+
2024
&:visited {
2125
color: $tc-white;
2226
}

src/shared/components/buttons/themes/default.scss

+17-8
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,42 @@
77

88
@import "~styles/mixins";
99

10-
/* General button style - medium size. */
11-
.button {
10+
/* Generic button of medium size. */
11+
@mixin button {
1212
@include tc-label-lg;
1313

1414
align-items: center;
1515
background: $tc-white;
1616
border: solid 1px $tc-gray-30;
1717
border-radius: 4px;
18+
box-sizing: border-box;
1819
color: $tc-gray-80;
1920
display: inline-flex;
2021
justify-content: center;
2122
min-height: 40px;
2223
margin: 5px;
2324
padding: 5px 23px;
25+
text-align: center;
2426
vertical-align: middle;
2527
}
2628

29+
/* NOTE: All CSS rules below use two classes, to have higher specifity, thus
30+
* avoiding overriding of these rules by parent rules in some scenarious. */
31+
2732
/* Additional styling for a disabled button. */
28-
.disabled {
33+
.button.disabled {
34+
@include button;
35+
2936
cursor: not-allowed;
3037
opacity: 0.3;
3138
}
3239

3340
/* .link and .regular classes are applied only to active button-like links,
3441
* and real buttons (rendered as <button> elements). */
35-
.link,
36-
.regular {
42+
.button.link,
43+
.button.regular {
44+
@include button;
45+
3746
/* To prevent different styling of the button-like link once it has been
3847
* visited. */
3948
&:visited {
@@ -63,7 +72,7 @@
6372

6473
/* And a few extra classes to support XS, SM and LG sizes. */
6574

66-
.xs {
75+
.button.xs {
6776
@include tc-label-sm;
6877

6978
border-radius: 2px;
@@ -72,15 +81,15 @@
7281
padding: 1px 13px;
7382
}
7483

75-
.sm {
84+
.button.sm {
7685
@include tc-label-md;
7786

7887
color: $tc-gray-80;
7988
min-height: 30px;
8089
padding: 4px 18px;
8190
}
8291

83-
.lg {
92+
.button.lg {
8493
@include tc-label-xl;
8594

8695
color: $tc-gray-80;

src/shared/components/buttons/themes/ghost.scss

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,22 @@
44

55
@import "default";
66

7-
.button {
7+
@mixin button {
88
background: transparent;
99
border-color: transparent;
1010
color: $tc-dark-blue-110;
1111
}
1212

13-
.disabled {
13+
.button.disabled {
14+
@include button;
15+
1416
color: $tc-gray-80;
1517
}
1618

17-
.link,
18-
.regular {
19+
.button.link,
20+
.button.regular {
21+
@include button;
22+
1923
&:visited {
2024
color: $tc-dark-blue-110;
2125
}

src/shared/components/buttons/themes/primary.scss

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,23 @@
44

55
@import "default";
66

7-
.button {
7+
@mixin button {
88
background: $tc-dark-blue;
99
border-color: transparent;
1010
color: $tc-white;
1111
}
1212

13-
.disabled {
13+
.button.disabled {
14+
@include button;
15+
1416
background-color: $tc-gray-20;
1517
opacity: 1;
1618
}
1719

18-
.link,
19-
.regular {
20+
.button.link,
21+
.button.regular {
22+
@include button;
23+
2024
&:visited {
2125
color: $tc-white;
2226
}

src/shared/components/buttons/themes/secondary.scss

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,23 @@
44

55
@import "default";
66

7-
.button {
7+
@mixin button {
88
background: $tc-gray-40;
99
border-color: transparent;
1010
color: $tc-white;
1111
}
1212

13-
.disabled {
13+
.button.disabled {
14+
@include button;
15+
1416
background-color: $tc-gray-20;
1517
opacity: 1;
1618
}
1719

18-
.link,
19-
.regular {
20+
.button.link,
21+
.button.regular {
22+
@include button;
23+
2024
&:visited {
2125
color: $tc-white;
2226
}

src/styles/_mixins/typography.scss

+92
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,95 @@
172172
font-size: 42px;
173173
line-height: 50px;
174174
}
175+
176+
/**
177+
* Mixing of inline styles for a generic text block.
178+
*
179+
* TODO: In my understanding, it violates UI styleguides in various aspects,
180+
* thus it is placed here for now, and not into UI Kit library. This code comes
181+
* from challenges related to Contentful integration, ContentBlocks,
182+
* in particular, that was done without a close watch on the design. It is
183+
* separated into mixing, as other Contentful components also need inline
184+
* styles, thus we at least should keep them consistent between different
185+
* Contentful components, and later clean them all to match UI Kit.
186+
*/
187+
188+
@mixin tc-typography {
189+
a { color: $tc-dark-blue; }
190+
191+
a:active,
192+
a:focus,
193+
a:visited,
194+
a:hover {
195+
color: $tc-dark-blue;
196+
}
197+
198+
em {
199+
font-style: italic;
200+
}
201+
202+
h1 {
203+
@include tc-heading-lg;
204+
}
205+
206+
h1,
207+
h2,
208+
h3,
209+
h4,
210+
h5,
211+
h6 {
212+
margin: 20px 0 10px;
213+
}
214+
215+
p {
216+
@include tc-body-md;
217+
218+
padding: 10px 0;
219+
}
220+
221+
td,
222+
th {
223+
@include tc-body-md;
224+
}
225+
226+
ul,
227+
ol {
228+
@include tc-body-md;
229+
230+
padding-left: 20px;
231+
}
232+
233+
ul {
234+
list-style-type: disc;
235+
}
236+
237+
ol {
238+
list-style-type: decimal;
239+
}
240+
241+
img {
242+
max-width: 100%;
243+
}
244+
245+
code {
246+
@include roboto-mono-regular;
247+
248+
line-height: 1.5;
249+
white-space: pre;
250+
}
251+
252+
sub,
253+
sup {
254+
font-size: 75%;
255+
line-height: 0;
256+
position: relative;
257+
vertical-align: baseline;
258+
}
259+
260+
sup { top: -0.5em; }
261+
sub { bottom: -0.25em; }
262+
263+
strong {
264+
font-weight: bold;
265+
}
266+
}

0 commit comments

Comments
 (0)