|
| 1 | +@use "../../themes/mixins" as mixins; |
| 2 | +@use "../../themes/functions.color" as colors; |
| 3 | +@use "./chip.base.vars.scss" as vars; |
| 4 | + |
| 5 | +// Chip: Common Styles |
| 6 | +// -------------------------------------------------- |
| 7 | + |
| 8 | +:host { |
| 9 | + /** |
| 10 | + * @prop --background: Background of the chip |
| 11 | + * @prop --border-radius: Border radius of the chip |
| 12 | + * @prop --color: Color of the chip |
| 13 | + * @prop --focus-ring-color: Color of the focus ring |
| 14 | + * @prop --focus-ring-width: Width of the focus ring |
| 15 | + */ |
| 16 | + --focus-ring-color: #{vars.$chip-focus-ring-color}; |
| 17 | + --focus-ring-width: #{vars.$chip-focus-ring-width}; |
| 18 | + |
| 19 | + @include mixins.font-smoothing(); |
| 20 | + @include mixins.border-radius(var(--border-radius)); |
| 21 | + @include mixins.margin(vars.$chip-margin); |
| 22 | + @include mixins.padding(vars.$chip-padding-vertical, vars.$chip-padding-horizontal); |
| 23 | + |
| 24 | + display: inline-flex; |
| 25 | + position: relative; |
| 26 | + |
| 27 | + align-items: center; |
| 28 | + justify-content: center; |
| 29 | + |
| 30 | + background: var(--background); |
| 31 | + color: var(--color); |
| 32 | + |
| 33 | + line-height: vars.$chip-line-height; |
| 34 | + |
| 35 | + cursor: pointer; |
| 36 | + overflow: hidden; |
| 37 | + vertical-align: middle; |
| 38 | + box-sizing: border-box; |
| 39 | + |
| 40 | + gap: vars.$chip-gap; |
| 41 | +} |
| 42 | + |
| 43 | +// Chip Sizes |
| 44 | +// --------------------------------------------- |
| 45 | + |
| 46 | +:host(.chip-small) { |
| 47 | + min-height: vars.$chip-size-small-height; |
| 48 | + |
| 49 | + font-size: vars.$chip-size-small-font-size; |
| 50 | +} |
| 51 | + |
| 52 | +:host(.chip-medium) { |
| 53 | + min-height: vars.$chip-size-medium-height; |
| 54 | + |
| 55 | + font-size: vars.$chip-size-medium-font-size; |
| 56 | +} |
| 57 | + |
| 58 | +:host(.chip-large) { |
| 59 | + min-height: vars.$chip-size-large-height; |
| 60 | + |
| 61 | + font-size: vars.$chip-size-large-font-size; |
| 62 | +} |
| 63 | + |
| 64 | +// Chip Shapes |
| 65 | +// --------------------------------------------- |
| 66 | + |
| 67 | +:host(.chip-soft) { |
| 68 | + --border-radius: #{vars.$chip-border-radius-soft}; |
| 69 | +} |
| 70 | + |
| 71 | +:host(.chip-round) { |
| 72 | + --border-radius: #{vars.$chip-border-radius-round}; |
| 73 | +} |
| 74 | + |
| 75 | +:host(.chip-rectangular) { |
| 76 | + --border-radius: #{vars.$chip-border-radius-rectangular}; |
| 77 | +} |
| 78 | + |
| 79 | +// Chip Hues |
| 80 | +// --------------------------------------------- |
| 81 | + |
| 82 | +// Bold |
| 83 | +:host(.chip-bold) { |
| 84 | + --background: #{vars.$chip-hue-bold-bg}; |
| 85 | + --color: #{vars.$chip-hue-bold-color}; |
| 86 | +} |
| 87 | + |
| 88 | +:host(.chip-bold.chip-outline) { |
| 89 | + border-color: #{vars.$chip-hue-bold-outline-border-color}; |
| 90 | +} |
| 91 | + |
| 92 | +// Subtle |
| 93 | +:host(.chip-subtle) { |
| 94 | + --background: #{vars.$chip-hue-subtle-bg}; |
| 95 | + --color: #{vars.$chip-hue-subtle-color}; |
| 96 | +} |
| 97 | + |
| 98 | +:host(.chip-subtle.chip-outline) { |
| 99 | + border-color: #{vars.$chip-hue-subtle-outline-border-color}; |
| 100 | +} |
| 101 | + |
| 102 | +// Chip Colors |
| 103 | +// --------------------------------------------- |
| 104 | + |
| 105 | +// Bold |
| 106 | +:host(.ion-color.chip-bold) { |
| 107 | + background: colors.current-color(base, vars.$chip-hue-bold-semantic-bg-alpha); |
| 108 | + color: vars.$chip-hue-bold-semantic-color; |
| 109 | +} |
| 110 | + |
| 111 | +:host(.ion-color.chip-bold.chip-outline) { |
| 112 | + border-color: vars.$chip-hue-bold-semantic-outline-border-color; |
| 113 | +} |
| 114 | + |
| 115 | +// Subtle |
| 116 | +:host(.ion-color.chip-subtle) { |
| 117 | + background: colors.current-color(base, $subtle: true); |
| 118 | + color: colors.current-color(contrast, $subtle: true); |
| 119 | +} |
| 120 | + |
| 121 | +:host(.ion-color.chip-subtle.chip-outline) { |
| 122 | + border-color: colors.current-color(shade, $subtle: true); |
| 123 | +} |
| 124 | + |
| 125 | +// Outline Chip |
| 126 | +// --------------------------------------------- |
| 127 | + |
| 128 | +:host(.chip-outline) { |
| 129 | + border-width: vars.$chip-outline-border-width; |
| 130 | + border-style: solid; |
| 131 | +} |
| 132 | + |
| 133 | +:host(.chip-outline), |
| 134 | +:host(.chip-outline.ion-color) { |
| 135 | + background: vars.$chip-outline-bg; |
| 136 | +} |
| 137 | + |
| 138 | +// Chip States |
| 139 | +// --------------------------------------------- |
| 140 | + |
| 141 | +// Disabled |
| 142 | +:host(.chip-disabled) { |
| 143 | + cursor: default; |
| 144 | + opacity: vars.$chip-state-disabled-opacity; |
| 145 | + pointer-events: none; |
| 146 | +} |
| 147 | + |
| 148 | +// Focus |
| 149 | +:host(.ion-focused) { |
| 150 | + --background: #{vars.$chip-focus-bg}; |
| 151 | + |
| 152 | + @include mixins.focused-state(var(--focus-ring-width), $color: var(--focus-ring-color)); |
| 153 | +} |
| 154 | + |
| 155 | +:host(.ion-focused.ion-color) { |
| 156 | + background: vars.$chip-focus-semantic-bg; |
| 157 | +} |
| 158 | + |
| 159 | +:host(.ion-focused.chip-outline:not(.ion-color)) { |
| 160 | + background: vars.$chip-outline-focus-bg; |
| 161 | +} |
| 162 | + |
| 163 | +// Activated |
| 164 | +:host(.ion-activated) { |
| 165 | + --background: #{vars.$chip-activated-bg}; |
| 166 | +} |
| 167 | + |
| 168 | +:host(.ion-activated.ion-color) { |
| 169 | + background: vars.$chip-activated-semantic-bg; |
| 170 | +} |
| 171 | + |
| 172 | +// Hover |
| 173 | +@media (any-hover: hover) { |
| 174 | + :host(:hover) { |
| 175 | + --background: #{vars.$chip-hover-bg}; |
| 176 | + } |
| 177 | + |
| 178 | + :host(.ion-color:hover) { |
| 179 | + background: vars.$chip-hover-semantic-bg; |
| 180 | + } |
| 181 | + |
| 182 | + :host(.chip-outline:not(.ion-color):hover) { |
| 183 | + background: vars.$chip-outline-hover-bg; |
| 184 | + } |
| 185 | +} |
| 186 | + |
| 187 | +// Chip Slotted Elements |
| 188 | +// --------------------------------------------- |
| 189 | + |
| 190 | +// Icon |
| 191 | +::slotted(ion-icon) { |
| 192 | + font-size: vars.$chip-icon-size; |
| 193 | +} |
| 194 | + |
| 195 | +:host(:not(.ion-color)) ::slotted(ion-icon) { |
| 196 | + color: vars.$chip-icon-color; |
| 197 | +} |
| 198 | + |
| 199 | +::slotted(ion-icon:first-child) { |
| 200 | + @include mixins.margin(vars.$chip-icon-first-child-margin, vars.$chip-icon-first-child-margin-end, $start: vars.$chip-icon-first-child-margin); |
| 201 | +} |
| 202 | + |
| 203 | +::slotted(ion-icon:last-child) { |
| 204 | + @include mixins.margin(vars.$chip-icon-last-child-margin, $start: vars.$chip-icon-last-child-margin-start); |
| 205 | +} |
| 206 | + |
| 207 | +// Avatar |
| 208 | +::slotted(ion-avatar) { |
| 209 | + flex-shrink: 0; |
| 210 | + |
| 211 | + width: vars.$chip-avatar-size; |
| 212 | + height: vars.$chip-avatar-size; |
| 213 | +} |
| 214 | + |
| 215 | +::slotted(ion-avatar:first-child) { |
| 216 | + @include mixins.margin(vars.$chip-avatar-first-child-margin-vertical, $end: vars.$chip-avatar-first-child-margin-end, $start: vars.$chip-avatar-first-child-margin-start); |
| 217 | +} |
| 218 | + |
| 219 | +::slotted(ion-avatar:last-child) { |
| 220 | + @include mixins.margin(vars.$chip-avatar-last-child-margin-vertical, $end: vars.$chip-avatar-last-child-margin-end, $start: vars.$chip-avatar-last-child-margin-start); |
| 221 | +} |
| 222 | + |
0 commit comments