Skip to content

Commit 9411f1f

Browse files
heyMPgithub-actions[bot]castastrophestarryeyez024
authored
feat: [pfe-styles] ordered list styles (#1571)
* feat: verbose ordered-list-primary extend * feat: switched away from local sass variables. added grid to demo. * fix: fixed demo styles overriding padding on * feat: center align ol.pfe-styles demo * feat: added ul pfe-list styles * Revert "feat: added ul pfe-list styles" This reverts commit 6337423. * feat: improved margin on ol parent * feat: added ie11 fallback for display * fix: moved variables to pfe-local * fix: remove root CSS variables. Fixed pfe-local statements. Added variable stack to BackgroundColor * fix: added fallbacks to margin * feat: added prefix pfe-ol-list--primary * feat: added prefix pfe-list-ol--primary *  fix: added better list selector to demo * chore: update README * feat: added design hooks for pfe-grid. using hooks in pfe-list * feat: updated README. changed gap to spacer api * Typo update * feat: moved ol.pfe-list--primary to typography file * feat: added design hook for removing an items first child margin * Update elements/pfe-sass/mixins/_components.scss Co-authored-by: Kendall Totten <[email protected]> * fix: added more descriptive name to li numbers font size * chore: update changelog * Update CHANGELOG-1.x.md Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: [ Cassondra ] <[email protected]> Co-authored-by: Kendall Totten <[email protected]>
1 parent 18c648a commit 9411f1f

File tree

7 files changed

+163
-5
lines changed

7 files changed

+163
-5
lines changed

CHANGELOG-1.x.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.9.0 (TBD)
2+
3+
- [](https://github.com/patternfly/patternfly-elements/commit/) feat: [pfe-styles] ordered list primary styles
4+
15
# 1.8.0 (2021-05-18)
26

37
- [f1c1176](https://github.com/patternfly/patternfly-elements/commit/f1c1176d9278d6e5b8066b42fc040ea01d98ecb2) feat: pfe-icon now supports setting default icon sets

elements/pfe-sass/mixins/_components.scss

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,3 +246,88 @@
246246
}
247247
}
248248
}
249+
250+
/// ===========================================================================
251+
/// List styles
252+
/// ===========================================================================
253+
254+
// Mixins and extends can't use the LOCAL-VARIABLES map because we would be
255+
// at risk of overriding an elements map if they call our mixin. We need to
256+
// use just regular sass variables and pfe-local and specify the $fallbacks.
257+
@mixin ordered-list-primary($size: 56px) {
258+
// First we create our Sass variables that we will use for fallbacks
259+
// The gap between list items
260+
$gap: pfe-var(content-spacer);
261+
// The space between the circle and content
262+
$spacer: pfe-var(content-spacer);
263+
// rgb value of the color theme of the circle
264+
// we need to wrap this in a calc function so it can be dynamic.
265+
$color: (238, 0, 0);
266+
// font size of the number inside of the circle
267+
$number-font-size: $pf-global--FontSize--2xl;
268+
269+
list-style: none;
270+
min-height: pfe-local(gap, $fallback: $gap);
271+
margin: pfe-local(gap, $fallback: $gap);
272+
padding-left: pfe-local(PaddingLeft, $fallback: 0);
273+
274+
& > li {
275+
// increment the local counter variable
276+
counter-increment: pfe-list;
277+
position: relative;
278+
min-height: pfe-local(size, $region: circle, $fallback: $size);
279+
// the li content will start after the circle and a defined spacer
280+
padding-left: calc(#{pfe-local(spacer, $fallback: $spacer)} + #{pfe-local(size, $region: circle, $fallback: $size)});
281+
// the li content needs to align with the middle of the radius but we
282+
// need to account for the fact that it's also calculating the size
283+
// of the line height of the number inside of the circle
284+
padding-top: calc((#{pfe-local(size, $region: circle, $fallback: $size)} / 2) - ((#{pfe-local(FontSize, $region: circle, $fallback: $number-font-size)} / 2)));
285+
}
286+
& > ul {
287+
list-style-type: disc;
288+
}
289+
& > li:before {
290+
@include pfe-typography(2xl, $type: "title");
291+
// we need to make sure that if the size of the number in the circle changes
292+
// that doesn't affect the size or shape of the circle. since we don't have
293+
// any more psuedo elements to work with, we need to use the flexbox technique
294+
// to center the text.
295+
display: block;
296+
display: flex;
297+
justify-content: center;
298+
align-items: center;
299+
text-align: center;
300+
// make the circle using border-radius
301+
border-radius: 50%;
302+
// keep the circle on the upper left
303+
position: absolute;
304+
top: 0;
305+
left: 0;
306+
// set the size of the circle
307+
width: pfe-local(size, $region: circle, $fallback: $size);
308+
height: pfe-local(size, $region: circle, $fallback: $size);
309+
// set the contents of the circle
310+
content: counter(pfe-list);
311+
font-size: pfe-local(FontSize, $region: circle, $fallback: $number-font-size);
312+
color: rgba(#{pfe-local(color, $region: circle, $fallback: $color)}, 1);
313+
// generate a background color based on the circle text color
314+
// provide an override for BackgroundColor if the user needs to specify
315+
// custom color.
316+
background-color: pfe-local(BackgroundColor, $region: circle, $fallback: rgba(pfe-local(color, $region: circle, $fallback: $color), 0.07));
317+
}
318+
319+
& > li *:first-child {
320+
margin-top: pfe-local(MarginTop, $region: item-first-child, $fallback: 0);
321+
}
322+
323+
// for pfe-grids we:
324+
// - use the pfe-grid API to add grid gap.
325+
// - remove the margins on the <li> tags in favor of the grid gap.
326+
// - add top and bottom margin back to the <ol> tags to maintain correct offset with surrounding content.
327+
&.pfe-l-grid.pfe-m-gutters {
328+
--pfe-grid--gap--vertical: #{pfe-local(gap, $fallback: $gap)};
329+
--pfe-grid--gap--horizontal: #{pfe-local(gap, $fallback: $gap)};
330+
--pfe-grid--Margin: #{pfe-local(Margin, $fallback: $gap)};
331+
--pfe-grid__item--Margin: #{pfe-local(Margin, $region: item, $fallback: 0)};
332+
}
333+
}

elements/pfe-styles/README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ Use a bullseye layout when there is a single child element, and that child is ce
324324
| -------------- | ----------- |
325325
| `pfe-l-bullseye` | Centers child element vertically &amp; horizontally |
326326

327-
Exampe:
327+
Example:
328328

329329
```html
330330
<div class="pfe-l-bullseye">
@@ -344,6 +344,29 @@ Text alignment helper classes can also be applied to any block-level element.
344344

345345

346346

347+
#### List Styles
348+
349+
Add customimzed styling to list items. We currently support the following list styles:
350+
351+
| Class | Type | Description | Hooks |
352+
| ------------------- | ---- | ---------------------------------------- | --- |
353+
| `pfe-list--primary` | ol | Primary visual design for ordered lists. | `--pfe-list-ol--primary--gap: pfe-var(content-spacer);` |
354+
| | | |`--pfe-list-ol--primary--spacer: pfe-var(content-spacer);` |
355+
| | | |`--pfe-list-ol--primary__circle--size: 56px;` |
356+
| | | |`--pfe-list-ol--primary__circle--color: 238,0,0;` |
357+
| | | |`--pfe-list-ol--primary__circle--BackgroundColor: rgba(238,0,0, 0.7);` |
358+
| | | |`--pfe-list-ol--primary__circle--FontSize: 24px;` |
359+
360+
Example:
361+
362+
```html
363+
<ol class="pfe-list--primary">
364+
<li>First step</li>
365+
<li>Second step</li>
366+
<li>Third step</li>
367+
</ol>
368+
```
369+
347370
## Developers
348371

349372
### Testing
@@ -368,4 +391,4 @@ Card (and all PatternFly Elements) use [Prettier][prettier] to auto-format JS an
368391

369392
[prettier]: https://github.com/prettier/prettier/
370393
[prettier-ed]: https://prettier.io/docs/en/editors.html
371-
[web-component-tester]: https://github.com/Polymer/web-component-tester
394+
[web-component-tester]: https://github.com/Polymer/web-component-tester

elements/pfe-styles/demo/index.html

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,38 @@ <h2>List styles &amp; paragraphs</h2>
268268
convallis eget suspendisse consectetur tristique quis in nam parturient. Proin mus a a sem mus nec dapibus elit ac diam facilisi erat lacus scelerisque diam duis a non sapien parturient ad accumsan nunc ridiculus vivamus odio.Ante odio parturient.</li>
269269
<li>List item: ullamcorper eros odio convallis eget suspendisse </li>
270270
</ol>
271+
<h4>Primary Ordered List</h4>
272+
<ol class="pfe-list--primary pfe-l-grid pfe-m-gutters pfe-m-all-6-col-on-lg" style="max-width:1000px; margin-left:auto; margin-right:auto;">
273+
<li>
274+
<h4>Lorem ipsum dolor sit amet</h4>
275+
<ul>
276+
<li>Related instruction for step 1</li>
277+
<li>Related instruction for step 1</li>
278+
</ul>
279+
</li>
280+
<li>
281+
<h4>Lorem ipsum dolor sit amet</h4>
282+
<ul>
283+
<li>Related instruction for step 1</li>
284+
<li>Related instruction for step 1</li>
285+
</ul>
286+
</li>
287+
<li>
288+
<h4>Lorem ipsum dolor sit amet</h4>
289+
<ul>
290+
<li>Related instruction for step 1</li>
291+
<li>Related instruction for step 1</li>
292+
</ul>
293+
</li>
294+
<li>
295+
<h4>Lorem ipsum dolor sit amet</h4>
296+
<ul>
297+
<li>Related instruction for step 1</li>
298+
<li>Related instruction for step 1</li>
299+
</ul>
300+
</li>
301+
</ol>
302+
<pre><code class="lang-markup">&lt;ol class="pfe-list--primary">...&lt;/ol&gt;</code></pre>
271303
<p>Paragraph text: suspendisse id elementum ullamcorper lobortis porttitor congue a molestie ante rhoncus hac a a tortor aptent arcu ad eleifend nisi arcu ultricies ornare elementum.Cum condimentum parturient a condimentum ullamcorper aliquet adipiscing urna ut. </p>
272304
<dl>
273305
<dt>Definition term: eu eget <a href="http://foobaz.com">consectetur vestibulum</a> ullamcorper eros odio

elements/pfe-styles/demo/pfe-colors.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@
466466
background: #e0d7ee;
467467
}
468468

469-
.layouts .pfe-l-grid > * {
469+
.layouts .pfe-l-grid:not(ol,ul) > * {
470470
padding: 8px;
471471
}
472472

elements/pfe-styles/src/layouts/_grid.scss

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,16 @@ $half-grid-gap-vertical: calc(#{$grid-gap-vertical} / 2);
193193
&.pfe-m-gutters {
194194
column-gap: #{$grid-gap-horizontal};
195195
row-gap: #{$grid-gap-vertical};
196-
margin: 0; // Remove IE11
196+
// design hook to customize the margin of the progressively
197+
// enhanced grid. Note, these design hooks will not work in the IE11 code above
198+
// since it is using the negative margin technique to mimic grids.
199+
margin: var(--pfe-grid--Margin, 0); // Remove IE11
197200

198201
& > * {
199-
margin: 0; // Remove IE11
202+
// design hook to customize the margin of the progressively
203+
// enhanced grid. Note, these design hooks will not work in the IE11 code above
204+
// since it is using the negative margin technique to mimic grids.
205+
margin: var(--pfe-grid__item--Margin, 0); // Remove IE11
200206
}
201207
}
202208
}

elements/pfe-styles/src/pfe-typography-classes.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@
1212
.pfe-text--#{$size} {
1313
@include pfe-typography($sizing: $size, $type: text, $important: true);
1414
}
15+
}
16+
17+
// List Styles
18+
// @todo concider breaking these into their own file or renaming this
19+
// file to not be just typography focused but more "style utilities" focused.
20+
$LOCAL: list-ol--primary;
21+
ol.pfe-list--primary {
22+
@include ordered-list-primary;
1523
}

0 commit comments

Comments
 (0)