Skip to content

Commit d0fd6c5

Browse files
Add rich text component (Fix #1079) (#1081)
* Add rich text component (Fix #1079) * Update documentation to add utility class section
1 parent 09b9ae0 commit d0fd6c5

29 files changed

Lines changed: 255 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
## Features
44

5+
* **component:** Added `mzp-u-rich-text` utility class to add back list and table styles (#1079)
6+
* **docs:** Added a new utility class section to docs.
57
* **component:** Update breadcrumb styles (#1036)
68
* **assets:** (breaking) Update @mozilla-protocol/assets to 7.0.1
79
* **css:** Updated line height variables for Mozilla theme to reflect guidance published in the brand portal.
10+
* **css:** * Remove `:hover:visited` styles & decrease base link specificity (#1071)
811

912
## Bug Fixes
1013

@@ -13,6 +16,10 @@
1316

1417
## Migration Tips
1518

19+
* Rich text
20+
* If you have previously created a class to add back list and table styling to rich text fields you may be able to swap it out for the new component.
21+
* This component currently styles h2-h4, ul, ol, dl, table, and pre. If you need more elements please create an issue.
22+
1623
* Breadcrumb updates do not require any changes unless you have local customizations.
1724

1825
* Icon updates

assets/sass/protocol/base/elements/_tables.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// We so rarely use tables that it's best not to give them any
88
// base styling and instead use a modifier class for those few
99
// times we need to display tabular data.
10-
.mzp-u-data-table {
10+
%data-table {
1111
border-collapse: collapse;
1212
border-spacing: 0;
1313

@@ -31,3 +31,7 @@
3131
padding-top: 0;
3232
}
3333
}
34+
35+
.mzp-u-data-table {
36+
@extend %data-table;
37+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
5+
@use '../../includes/lib' as *;
6+
@import '../../base/elements/tables';
7+
8+
.mzp-u-rich-text {
9+
h2 {
10+
margin-bottom: $layout-xs;
11+
margin-top: $layout-sm;
12+
}
13+
14+
h3 {
15+
margin-bottom: $layout-xs;
16+
margin-top: $layout-sm;
17+
}
18+
19+
h4 {
20+
@include text-body-lg;
21+
font-family: var(--body-font-family);
22+
margin-bottom: $layout-xs;
23+
margin-top: $layout-xs;
24+
}
25+
26+
@media #{$mq-md} {
27+
h2 {
28+
margin-bottom: $layout-sm;
29+
margin-top: $layout-md;
30+
}
31+
32+
h3 {
33+
margin-top: $layout-md;
34+
}
35+
36+
h4 {
37+
margin-top: $layout-sm;
38+
}
39+
}
40+
41+
@media #{$mq-xl} {
42+
h2 {
43+
margin-bottom: $layout-md;
44+
margin-top: $layout-lg;
45+
}
46+
47+
h3 {
48+
margin-top: $layout-lg;
49+
}
50+
51+
h4 {
52+
margin-top: $layout-md;
53+
}
54+
}
55+
56+
ul {
57+
@include bidi(((margin-left, $layout-sm, margin-right, 0),));
58+
list-style-type: disc;
59+
60+
ul {
61+
list-style-type: circle;
62+
}
63+
}
64+
65+
ol {
66+
@include bidi(((margin-left, $layout-sm, margin-right, 0),));
67+
list-style-type: decimal;
68+
69+
ol {
70+
list-style-type: lower-roman;
71+
}
72+
}
73+
74+
li {
75+
margin-bottom: 0.25em;
76+
77+
ul, ol {
78+
@include bidi(((margin-left, $layout-xs, margin-right, 0),));
79+
}
80+
}
81+
82+
dt {
83+
font-weight: bold;
84+
margin-bottom: 0;
85+
}
86+
87+
dd {
88+
@include bidi(((margin-left, $layout-xs, margin-right, 0),));
89+
margin-bottom: 0.25em;
90+
}
91+
92+
pre {
93+
background-color: $color-light-gray-20;
94+
margin-bottom: 1.25em;
95+
overflow-x: auto;
96+
padding: $spacing-md;
97+
}
98+
99+
table {
100+
@extend %data-table;
101+
}
102+
}

assets/sass/protocol/protocol.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
// Base utilities
2424
@use 'base/utilities/backgrounds';
25+
@use 'base/utilities/rich-text';
2526
@use 'base/utilities/titles';
2627

2728
// Base includes - animations

components/basic-elements/blockquote/blockquote.html renamed to components/00-basic-elements/blockquote/blockquote.html

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

components/basic-elements/headings/readme.md renamed to components/00-basic-elements/headings/readme.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ this base size can be overridden with more context-specific styling.
1111
immediately following an `<h1>`. If you need a subheading or tagline
1212
immediately after a title, chances are it should be a paragraph rather than
1313
a second heading.
14-
- There are presentational utility classes available that you can apply to any
15-
heading, e.g. `mzp-u-title-sm`, but don't abuse them if they aren't necessary.
16-
You can often use the equivalent mixins in Sass/SCSS without a presentational
17-
class.
1814

1915
### Links
2016

0 commit comments

Comments
 (0)