Skip to content

Conversation

@thisisdano
Copy link
Contributor

@thisisdano thisisdano commented Feb 10, 2021

Preview

This PR makes a few modifications to (hopefully!) streamline and improve the functionality of the icon list.

First, I'd like to focus the icon list a use case that's closer in spirit to a conventional unordered list, except using an icon instead of a bullet. This means building for shorter lists, with only a few words or sentences per list item, or a slightly more robust list item, with a title and some accompanying text:

Default list

Screen Shot 2021-02-10 at 3 12 38 PM

List with rich text

Screen Shot 2021-02-10 at 3 12 51 PM

Next, I wanted to simplify the implementation for lists that use a custom size. I liked how you could pass a size variant into the list and it would update the icon and the text — but I didn't like the extra step of adding the usa-icon-list--title class. This PR changes the behavior, so that content inside of usa-icon-list--content gets the custom sizing. For example:

Default

Screen Shot 2021-02-10 at 3 23 41 PM

<ul class="usa-icon-list">
    <li class="usa-icon-list__item">
        <div class="usa-icon-list__icon text-green"> ... </div>
        <div class="usa-icon-list__content">
            Donate cash when possible.
        </div>
    </li>
    ...
</ul>

Large variant

Screen Shot 2021-02-10 at 3 23 53 PM

<ul class="usa-icon-list usa-icon-list--size-lg">
    <li class="usa-icon-list__item">
        <div class="usa-icon-list__icon text-green"> ... </div>
        <div class="usa-icon-list__content">
            Donate cash when possible.
        </div>
    </li>
    ...
</ul>

This custom sizing only applies to text directly inside the usa-icon-list__content element. Any block-level child of usa-icon-list__content gets initial styling. So, if you want to have custom styled text inside content, just put it in a p, h3, div, or whatever. You can add the usa-icon-list__title class to a block-level heading that should get the custom sizing:

Screen Shot 2021-02-10 at 3 38 25 PM

<ul class="usa-icon-list usa-icon-list--size-lg">
    <li class="usa-icon-list__item">
        <div class="usa-icon-list__icon text-green"> ... </div>
        <div class="usa-icon-list__content">
            <h3 class="usa-icon-list__title">Donate cash when possible.</h3>
            <p>Financial contributions to recognized disaster relief organizations are the fastest, most flexible and most effective method of donating. Organizations on the ground know what items and quantities are needed, often buy in bulk with discounts and, if possible, purchase through businesses local to the disaster, which supports economic recovery.</p>
        </div>
    </li>
    ...
</ul>

Styling controlled with span, em, strong, etc works as expected:

Screen Shot 2021-02-10 at 3 41 53 PM

<ul class="usa-icon-list usa-icon-list--size-lg">
    <li class="usa-icon-list__item">
        <div class="usa-icon-list__icon text-green"> ... </div>
        <div class="usa-icon-list__content">
            <strong class="text-bold">Use cash.</strong> Donate cash when possible.
        </div>
    </li>
    ...
</ul>

Other changes

Responsive variants

Added responsive prefixing to the size variant. Larger sizes would be impractical for narrow widths, but devs should be able to access them when they're appropriate. So now you can add something like tablet:usa-icon-list--size-lg.

responsive-icon-list.mp4

Rem sizing

I rebuilt some of the sizing and spacing Sass to use rem instead of px. This will help with responsiveness and accessibility, especially if users have custom font sizing set in their browser.

Size and spacing adjustments

I reduced the size and padding of the icons a bit, and reduced the size of the default title to the same as the text size, except bold.

- Add responsive size variants
- Apply custom size to entire container
- Use adaptive size for usa-icon-list__title elements, but not others
- Move default title styling to end
- Use system heading line height for title elements
- Use rem for icon size for more reliable accessible resize
- Use rem values for padding
- Use them-body-font-size for the default
- Sync heading size between default and variant versions
- Reduce left padding
- Simplify sass structure, put less in the override prose mixin
$quoted-bp: smart-quote($bp);
$our-breakpoints: map-deep-get($system-properties, breakpoints, standard);
@if map-has-key($our-breakpoints, $quoted-bp) {
@if $quoted-bp == "none" {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this to facilitate better looping in my responsive breakpoints loop

Comment on lines +145 to +146
> *:last-child {
margin-bottom: 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't let last-child's margin affect li/li spacing

Copy link
Contributor

@mitchmoccia mitchmoccia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks great @thisisdano I'm going to merge this and update the guidance site now, thank you

@mitchmoccia mitchmoccia merged commit 4cbcf9a into accelerator/3772-icon-list Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants