|
| 1 | +// Variables |
| 2 | + |
| 3 | +// Size icons based on the theme-type-scale-[size] number and this factor |
| 4 | +$icon-list-icon-size-factor: 1.5; |
| 5 | +// Center the icon to the title text, works for all size variants |
| 6 | +$icon-list-icon-margin-top: -1.5%; |
| 7 | +// Fine tune the space between the icon and content with this factor |
| 8 | +$icon-list-icon-padding-left-factor: 0.4; |
| 9 | +// Fine tune the title top padding given a line height of lh-2 |
| 10 | +$icon-list-title-padding-top: 0.425ex; |
| 11 | + |
| 12 | +$theme-body-font-sizes: ( |
| 13 | + "xs": $theme-type-scale-xs, |
| 14 | + "sm": $theme-type-scale-sm, |
| 15 | + "md": $theme-type-scale-md, |
| 16 | + "lg": $theme-type-scale-lg, |
| 17 | + "xl": $theme-type-scale-xl, |
| 18 | + "2xl": $theme-type-scale-2xl, |
| 19 | + "3xl": $theme-type-scale-3xl, |
| 20 | +); |
| 21 | + |
| 22 | +$type-scale: font-size($theme-icon-list-font-family, $theme-body-font-size); |
| 23 | + |
| 24 | +// Get fixed size for icon, based on non-normalized size token |
| 25 | +$this-system-token: if( |
| 26 | + map-has-key($theme-body-font-sizes, $theme-body-font-size), |
| 27 | + map-get($theme-body-font-sizes, $theme-body-font-size), |
| 28 | + $theme-body-font-size |
| 29 | +); |
| 30 | +$this-icon-size-px: map-get($system-type-scale, $this-system-token); |
| 31 | +$icon-size: px-to-rem($this-icon-size-px); |
| 32 | + |
| 33 | +@include override-prose { |
| 34 | + .usa-icon-list { |
| 35 | + @include typeset($theme-icon-list-font-family, $theme-body-font-size); |
| 36 | + @include unstyled-list; |
| 37 | + @include u-measure(5); |
| 38 | + } |
| 39 | + |
| 40 | + .usa-icon-list__item { |
| 41 | + display: flex; |
| 42 | + position: relative; |
| 43 | + |
| 44 | + & + .usa-icon-list__item { |
| 45 | + padding-top: units(1.5); |
| 46 | + } |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +// Allow setting icon color on the icon-list element |
| 51 | +.usa-icon-list { |
| 52 | + @each $color, $grades in $all-project-colors { |
| 53 | + @each $grade, $value in $grades { |
| 54 | + @if $value { |
| 55 | + $prefix: if($grade != "default", #{$color}-#{$grade}, #{$color}); |
| 56 | + &--#{$prefix} { |
| 57 | + .usa-icon-list__icon { |
| 58 | + color: color($prefix); |
| 59 | + } |
| 60 | + } |
| 61 | + } |
| 62 | + } |
| 63 | + } |
| 64 | +} |
| 65 | + |
| 66 | +.usa-icon-list__icon { |
| 67 | + .usa-icon { |
| 68 | + // Set the height and width of the icon based on the size variant and factor |
| 69 | + // Doesn't use u-square() because of non-token size |
| 70 | + display: block; |
| 71 | + height: $icon-size * $icon-list-icon-size-factor; |
| 72 | + // margin-top: $icon-list-icon-margin-top; |
| 73 | + position: relative; |
| 74 | + width: $icon-size * $icon-list-icon-size-factor; |
| 75 | + } |
| 76 | +} |
| 77 | + |
| 78 | +// Don't resize any block-level element inside content |
| 79 | +.usa-icon-list__content { |
| 80 | + > p, |
| 81 | + > ul, |
| 82 | + > ol { |
| 83 | + @include u-font($theme-icon-list-font-family, $theme-body-font-size); |
| 84 | + @include u-measure(5); |
| 85 | + } |
| 86 | +} |
| 87 | + |
| 88 | +.usa-icon-list[class*="usa-icon-list--size-"] { |
| 89 | + @include u-measure("none"); |
| 90 | +} |
| 91 | + |
| 92 | +// Generate responsive variants |
| 93 | +// Create a map for looping that includes a default or no-breakpoint version |
| 94 | +$this-null: ( |
| 95 | + "none": null, |
| 96 | +); |
| 97 | +$icon-list-breakpoints: map-merge($this-null, $system-breakpoints); |
| 98 | +@each $mq-key, $mq-value in $icon-list-breakpoints { |
| 99 | + // Set the prefix |
| 100 | + // An empty string if "none" |
| 101 | + $prefix: false; |
| 102 | + @if $mq-key == "none" { |
| 103 | + $prefix: ""; |
| 104 | + } |
| 105 | + // Or the standard prefix if the breakpoint is output |
| 106 | + @else if map-get($theme-utility-breakpoints, $mq-key) { |
| 107 | + $prefix: "#{$mq-key}\\:"; |
| 108 | + } |
| 109 | + |
| 110 | + @include at-media($mq-key) { |
| 111 | + @each $token, $val in $theme-body-font-sizes { |
| 112 | + @if $prefix { |
| 113 | + $this-type-scale: font-size($theme-icon-list-font-family, $token); |
| 114 | + .#{$prefix}usa-icon-list--size-#{$token} { |
| 115 | + .usa-icon-list__icon { |
| 116 | + .usa-icon { |
| 117 | + // Set the height and width of the icon based on the size variant and factor |
| 118 | + height: $this-type-scale * $icon-list-icon-size-factor; |
| 119 | + width: $this-type-scale * $icon-list-icon-size-factor; |
| 120 | + } |
| 121 | + } |
| 122 | + |
| 123 | + .usa-icon-list__content { |
| 124 | + @include u-measure(5); |
| 125 | + // Resize simple (un-marked up) content |
| 126 | + font-size: size($theme-icon-list-font-family, $token); |
| 127 | + // Calculate the space between the icon and content based on the size variant and factor |
| 128 | + padding-left: $this-type-scale * |
| 129 | + $icon-list-icon-padding-left-factor; |
| 130 | + |
| 131 | + .usa-icon-list__title { |
| 132 | + @include u-font($theme-icon-list-title-font-family, $token); |
| 133 | + } |
| 134 | + } |
| 135 | + } |
| 136 | + } |
| 137 | + } |
| 138 | + } |
| 139 | +} |
| 140 | + |
| 141 | +.usa-icon-list__title { |
| 142 | + @include typeset( |
| 143 | + $theme-icon-list-title-font-family, |
| 144 | + $theme-body-font-size, |
| 145 | + 2 |
| 146 | + ); |
| 147 | + margin-bottom: units(0); |
| 148 | + padding-top: $icon-list-title-padding-top; |
| 149 | + & + * { |
| 150 | + margin-top: units(1); |
| 151 | + } |
| 152 | +} |
| 153 | + |
| 154 | +.usa-icon-list__content { |
| 155 | + font-size: $type-scale; |
| 156 | + padding-left: $type-scale * $icon-list-icon-padding-left-factor; |
| 157 | + > *:first-child { |
| 158 | + margin-top: 0; |
| 159 | + } |
| 160 | + > *:last-child { |
| 161 | + margin-bottom: 0; |
| 162 | + } |
| 163 | + |
| 164 | + ul li { |
| 165 | + list-style-type: disc; |
| 166 | + } |
| 167 | +} |
0 commit comments