_chip-theme.scss 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506
  1. //
  2. // Copyright 2020 Google Inc.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. // Selector '.mdc-*' should only be used in this project.
  23. // stylelint-disable selector-class-pattern --
  24. // Internal styling for Chip MDC component.
  25. @use 'sass:map';
  26. @use 'sass:meta';
  27. @use 'sass:math';
  28. @use 'sass:color';
  29. @use '@material/dom/dom';
  30. @use '@material/density/density';
  31. @use '@material/feature-targeting/feature-targeting';
  32. @use '@material/shape/shape';
  33. @use '@material/ripple/ripple-theme';
  34. @use '@material/rtl/rtl';
  35. @use '@material/theme/theme';
  36. @use '@material/theme/keys';
  37. @use '@material/elevation/elevation-theme';
  38. @use '@material/tokens/resolvers';
  39. @use '@material/theme/state';
  40. @use '@material/theme/theme-color';
  41. @use '@material/typography/typography';
  42. $height: 32px;
  43. $minimum-height: 24px;
  44. $maximum-height: $height;
  45. $density-scale: density.$default-scale;
  46. $density-config: (
  47. height: (
  48. default: $height,
  49. maximum: $maximum-height,
  50. minimum: $minimum-height,
  51. ),
  52. );
  53. $radius: math.div($height, 2);
  54. $type-scale: body2;
  55. $container-color: color.mix(
  56. theme-color.prop-value(on-surface),
  57. theme-color.prop-value(surface),
  58. 12%
  59. );
  60. $text-label-color: rgba(theme-color.prop-value(on-surface), 0.87);
  61. $icon-color: rgba(theme-color.prop-value(on-surface), 0.87);
  62. $checkmark-color: rgba(theme-color.prop-value(on-surface), 0.87);
  63. $trailing-action-color: rgba(theme-color.prop-value(on-surface), 0.87);
  64. $ripple-color: on-surface;
  65. $checkmark-size: 20px;
  66. $leading-icon-size: 20px;
  67. $trailing-action-size: 18px;
  68. $leading-padding: 12px;
  69. $trailing-padding: 12px;
  70. $avatar-size: 24px;
  71. $avatar-leading-padding: 4px;
  72. $avatar-trailing-padding: 8px;
  73. $graphic-leading-padding: 6px;
  74. $graphic-trailing-padding: 6px;
  75. $trailing-action-leading-padding: 8px;
  76. $trailing-action-trailing-padding: 8px;
  77. $ripple-target: '.mdc-evolution-chip__ripple';
  78. $ripple-target-primary: '.mdc-evolution-chip__ripple--primary';
  79. $ripple-target-trailing: '.mdc-evolution-chip__ripple--trailing';
  80. // Filter chip colors
  81. $filter-selected-container-color: color.mix(
  82. theme-color.prop-value(on-surface),
  83. $container-color,
  84. 8%
  85. );
  86. $light-theme: (
  87. container-elevation: null,
  88. container-height: null,
  89. container-shadow-color: null,
  90. container-shape: null,
  91. disabled-label-text-color: null,
  92. disabled-label-text-opacity: null,
  93. disabled-outline-color: null,
  94. disabled-outline-opacity: null,
  95. elevated-container-color: null,
  96. elevated-container-elevation: null,
  97. elevated-container-shadow-color: null,
  98. container-surface-tint-layer-color: null,
  99. elevated-disabled-container-color: null,
  100. elevated-disabled-container-elevation: null,
  101. elevated-disabled-container-opacity: null,
  102. elevated-focus-container-elevation: null,
  103. elevated-hover-container-elevation: null,
  104. elevated-pressed-container-elevation: null,
  105. elevated-selected-container-color: null,
  106. elevated-selected-container-elevation: null,
  107. elevated-unselected-container-color: null,
  108. flat-container-elevation: null,
  109. flat-disabled-outline-color: null,
  110. flat-disabled-outline-opacity: null,
  111. flat-disabled-selected-container-color: null,
  112. flat-disabled-selected-container-opacity: null,
  113. flat-disabled-selected-outline-color: null,
  114. flat-disabled-selected-outline-opacity: null,
  115. flat-disabled-unselected-outline-color: null,
  116. flat-disabled-unselected-outline-opacity: null,
  117. flat-focus-outline-color: null,
  118. flat-outline-color: null,
  119. flat-outline-width: null,
  120. flat-selected-container-color: null,
  121. flat-selected-focus-container-elevation: null,
  122. flat-selected-hover-container-elevation: null,
  123. flat-selected-outline-color: null,
  124. flat-selected-outline-width: null,
  125. flat-selected-pressed-container-elevation: null,
  126. flat-unselected-focus-container-elevation: null,
  127. flat-unselected-focus-outline-color: null,
  128. flat-unselected-hover-container-elevation: null,
  129. flat-unselected-outline-color: null,
  130. flat-unselected-outline-width: null,
  131. flat-unselected-pressed-container-elevation: null,
  132. focus-label-text-color: null,
  133. focus-outline-color: null,
  134. focus-state-layer-color: null,
  135. focus-state-layer-opacity: null,
  136. hover-label-text-color: null,
  137. hover-state-layer-color: null,
  138. hover-state-layer-opacity: null,
  139. label-text-color: null,
  140. label-text-font: null,
  141. label-text-line-height: null,
  142. label-text-size: null,
  143. label-text-tracking: null,
  144. label-text-weight: null,
  145. outline-color: null,
  146. outline-width: null,
  147. pressed-label-text-color: null,
  148. pressed-state-layer-color: null,
  149. pressed-state-layer-opacity: null,
  150. selected-focus-label-text-color: null,
  151. selected-focus-state-layer-color: null,
  152. selected-focus-state-layer-opacity: null,
  153. selected-hover-label-text-color: null,
  154. selected-hover-state-layer-color: null,
  155. selected-hover-state-layer-opacity: null,
  156. selected-label-text-color: null,
  157. selected-pressed-label-text-color: null,
  158. selected-pressed-state-layer-color: null,
  159. selected-pressed-state-layer-opacity: null,
  160. unselected-focus-label-text-color: null,
  161. unselected-focus-state-layer-color: null,
  162. unselected-focus-state-layer-opacity: null,
  163. unselected-hover-label-text-color: null,
  164. unselected-hover-state-layer-color: null,
  165. unselected-hover-state-layer-opacity: null,
  166. unselected-label-text-color: null,
  167. unselected-pressed-label-text-color: null,
  168. unselected-pressed-state-layer-color: null,
  169. unselected-pressed-state-layer-opacity: null,
  170. with-avatar-avatar-shape: null,
  171. with-avatar-avatar-size: null,
  172. with-avatar-disabled-avatar-opacity: null,
  173. with-icon-disabled-icon-color: null,
  174. with-icon-disabled-icon-opacity: null,
  175. with-icon-focus-icon-color: null,
  176. with-icon-hover-icon-color: null,
  177. with-icon-icon-color: null,
  178. with-icon-icon-size: null,
  179. with-icon-pressed-icon-color: null,
  180. with-icon-selected-focus-icon-color: null,
  181. with-icon-selected-hover-icon-color: null,
  182. with-icon-selected-icon-color: null,
  183. with-icon-selected-pressed-icon-color: null,
  184. with-icon-unselected-focus-icon-color: null,
  185. with-icon-unselected-hover-icon-color: null,
  186. with-icon-unselected-icon-color: null,
  187. with-icon-unselected-pressed-icon-color: null,
  188. with-leading-icon-disabled-leading-icon-color: null,
  189. with-leading-icon-disabled-leading-icon-opacity: null,
  190. with-leading-icon-focus-leading-icon-color: null,
  191. with-leading-icon-hover-leading-icon-color: null,
  192. with-leading-icon-leading-icon-color: null,
  193. with-leading-icon-leading-icon-size: null,
  194. with-leading-icon-pressed-leading-icon-color: null,
  195. with-trailing-icon-disabled-trailing-icon-color: null,
  196. with-trailing-icon-disabled-trailing-icon-opacity: null,
  197. with-trailing-icon-focus-trailing-icon-color: null,
  198. with-trailing-icon-hover-trailing-icon-color: null,
  199. with-trailing-icon-pressed-trailing-icon-color: null,
  200. with-trailing-icon-trailing-icon-color: null,
  201. with-trailing-icon-trailing-icon-size: null,
  202. );
  203. $_custom-property-prefix: 'chip';
  204. // TODO(b/259513131): Move theme resolution to variant theme
  205. // and remove custom property declaration when all customers are ready to be migrated
  206. @mixin theme($theme, $resolvers: resolvers.$material) {
  207. @include theme.validate-theme($light-theme, $theme);
  208. $theme: resolve-theme($theme, $resolvers: $resolvers);
  209. @include keys.declare-custom-properties(
  210. $theme,
  211. $prefix: $_custom-property-prefix
  212. );
  213. }
  214. // TODO(b/259513131): Move theme resolution to variant theme
  215. // and remove custom property declaration when all customers are ready to be migrated
  216. @mixin theme-styles($theme, $resolvers: resolvers.$material) {
  217. @include theme.validate-theme-styles($light-theme, $theme);
  218. $theme: resolve-theme($theme, $resolvers: $resolvers);
  219. $theme: keys.create-theme-properties(
  220. $theme,
  221. $prefix: $_custom-property-prefix
  222. );
  223. @include _container-shape(map.get($theme, container-shape));
  224. .mdc-evolution-chip__icon--primary {
  225. @include shape.radius(map.get($theme, with-avatar-avatar-shape));
  226. }
  227. @include graphic-size(map.get($theme, with-avatar-avatar-size));
  228. @include height(map.get($theme, container-height));
  229. @include elevation-theme.overlay-container-color(
  230. map.get($theme, container-surface-tint-layer-color)
  231. );
  232. @include _container-elevation(
  233. $map: (
  234. default: map.get($theme, container-elevation),
  235. )
  236. );
  237. @include _container-elevation(
  238. $map: (
  239. enabled: map.get($theme, flat-container-elevation),
  240. )
  241. );
  242. @include _container-elevation(
  243. $map: (
  244. enabled: map.get($theme, elevated-container-elevation),
  245. disabled: map.get($theme, elevated-disabled-container-elevation),
  246. hover: map.get($theme, elevated-hover-container-elevation),
  247. focus: map.get($theme, elevated-focus-container-elevation),
  248. pressed: map.get($theme, elevated-pressed-container-elevation),
  249. )
  250. );
  251. &.mdc-evolution-chip--selected {
  252. @include _container-elevation(
  253. (
  254. enabled: map.get($theme, elevated-selected-container-elevation),
  255. disabled:
  256. map.get($theme, elevated-selected-disabled-container-elevation),
  257. hover: map.get($theme, elevated-selected-hover-container-elevation),
  258. focus: map.get($theme, elevated-selected-focus-container-elevation),
  259. pressed: map.get($theme, elevated-selected-pressed-container-elevation),
  260. )
  261. );
  262. @include _container-elevation(
  263. (
  264. enabled: map.get($theme, flat-selected-container-elevation),
  265. disabled: map.get($theme, flat-selected-disabled-container-elevation),
  266. hover: map.get($theme, flat-selected-hover-container-elevation),
  267. focus: map.get($theme, flat-selected-focus-container-elevation),
  268. pressed: map.get($theme, flat-selected-pressed-container-elevation),
  269. )
  270. );
  271. }
  272. &:not(.mdc-evolution-chip--selected) {
  273. @include _container-elevation(
  274. (
  275. enabled: map.get($theme, flat-unselected-container-elevation),
  276. disabled: map.get($theme, flat-unselected-disabled-container-elevation),
  277. hover: map.get($theme, flat-unselected-hover-container-elevation),
  278. focus: map.get($theme, flat-unselected-focus-container-elevation),
  279. pressed: map.get($theme, flat-unselected-pressed-container-elevation),
  280. )
  281. );
  282. }
  283. @include outline-color(
  284. (
  285. enabled: map.get($theme, outline-color),
  286. focus: map.get($theme, focus-outline-color),
  287. disabled: map.get($theme, disabled-outline-color),
  288. )
  289. );
  290. @include outline-color(
  291. (
  292. enabled: map.get($theme, flat-outline-color),
  293. focus: map.get($theme, flat-focus-outline-color),
  294. disabled: map.get($theme, flat-disabled-outline-color),
  295. )
  296. );
  297. @include selected-outline-color(
  298. (
  299. enabled: map.get($theme, flat-selected-outline-color),
  300. disabled: map.get($theme, flat-disabled-selected-outline-color),
  301. )
  302. );
  303. &:not(.mdc-evolution-chip--selected) {
  304. @include outline-color(
  305. (
  306. disabled: map.get($theme, flat-disabled-unselected-outline-color),
  307. focus: map.get($theme, flat-unselected-focus-outline-color),
  308. enabled: map.get($theme, flat-unselected-outline-color),
  309. )
  310. );
  311. }
  312. @include outline-width(map.get($theme, outline-width));
  313. @include outline-width(map.get($theme, flat-outline-width));
  314. &.mdc-evolution-chip--selected {
  315. @include outline-width(map.get($theme, flat-selected-outline-width));
  316. }
  317. &:not(.mdc-evolution-chip--selected) {
  318. @include outline-width(map.get($theme, flat-unselected-outline-width));
  319. }
  320. @include container-color(
  321. (
  322. enabled: map.get($theme, elevated-container-color),
  323. disabled: map.get($theme, elevated-disabled-container-color),
  324. )
  325. );
  326. @include selected-container-color(
  327. (
  328. enabled: map.get($theme, elevated-selected-container-color),
  329. disabled: map.get($theme, elevated-disabled-container-color),
  330. )
  331. );
  332. // TODO(b/255716167) Separate theme-styles mixin for hairline and elevated chip variants.
  333. @include selected-container-color(
  334. (
  335. enabled: map.get($theme, flat-selected-container-color),
  336. disabled: map.get($theme, flat-disabled-selected-container-color),
  337. )
  338. );
  339. &:not(.mdc-evolution-chip--selected) {
  340. @include container-color(
  341. (
  342. enabled: map.get($theme, elevated-unselected-container-color),
  343. )
  344. );
  345. }
  346. .mdc-evolution-chip__text-label {
  347. @include typography.theme-styles(
  348. (
  349. font: map.get($theme, label-text-font),
  350. line-height: map.get($theme, label-text-line-height),
  351. size: map.get($theme, label-text-size),
  352. weight: map.get($theme, label-text-weight),
  353. tracking: map.get($theme, label-text-tracking),
  354. )
  355. );
  356. }
  357. @include text-label-color(
  358. (
  359. enabled: map.get($theme, label-text-color),
  360. hover: map.get($theme, hover-label-text-color),
  361. focus: map.get($theme, focus-label-text-color),
  362. pressed: map.get($theme, pressed-label-text-color),
  363. disabled: map.get($theme, disabled-label-text-color),
  364. )
  365. );
  366. @include selected-text-label-color(
  367. (
  368. enabled: map.get($theme, selected-label-text-color),
  369. hover: map.get($theme, selected-hover-label-text-color),
  370. focus: map.get($theme, selected-focus-label-text-color),
  371. pressed: map.get($theme, selected-pressed-label-text-color),
  372. disabled: map.get($theme, disabled-label-text-color),
  373. )
  374. );
  375. &:not(.mdc-evolution-chip--selected) {
  376. @include text-label-color(
  377. (
  378. enabled: map.get($theme, unselected-label-text-color),
  379. hover: map.get($theme, unselected-hover-label-text-color),
  380. focus: map.get($theme, unselected-focus-label-text-color),
  381. pressed: map.get($theme, unselected-pressed-label-text-color),
  382. disabled: map.get($theme, unselected-disabled-label-text-color),
  383. )
  384. );
  385. }
  386. @include icon-size(map.get($theme, with-icon-icon-size));
  387. @include icon-color(
  388. (
  389. enabled: map.get($theme, with-icon-icon-color),
  390. disabled: map.get($theme, with-icon-disabled-icon-color),
  391. hover: map.get($theme, with-icon-hover-icon-color),
  392. focus: map.get($theme, with-icon-focus-icon-color),
  393. pressed: map.get($theme, with-icon-pressed-icon-color),
  394. )
  395. );
  396. @include checkmark-color(
  397. (
  398. enabled: map.get($theme, with-icon-selected-icon-color),
  399. disabled: map.get($theme, with-icon-disabled-icon-color),
  400. hover: map.get($theme, with-icon-selected-hover-icon-color),
  401. focus: map.get($theme, with-icon-selected-focus-icon-color),
  402. pressed: map.get($theme, with-icon-selected-pressed-icon-color),
  403. )
  404. );
  405. &:not(.mdc-evolution-chip--selected) {
  406. @include icon-color(
  407. (
  408. enabled: map.get($theme, with-icon-unselected-icon-color),
  409. disabled: map.get($theme, with-icon-unselected-disabled-icon-color),
  410. hover: map.get($theme, with-icon-unselected-hover-icon-color),
  411. focus: map.get($theme, with-icon-unselected-focus-icon-color),
  412. pressed: map.get($theme, with-icon-unselected-pressed-icon-color),
  413. )
  414. );
  415. }
  416. @include icon-color(
  417. (
  418. disabled: map.get($theme, with-leading-icon-disabled-leading-icon-color),
  419. focus: map.get($theme, with-leading-icon-focus-leading-icon-color),
  420. hover: map.get($theme, with-leading-icon-hover-leading-icon-color),
  421. enabled: map.get($theme, with-leading-icon-leading-icon-color),
  422. pressed: map.get($theme, with-leading-icon-pressed-leading-icon-color),
  423. )
  424. );
  425. @include trailing-action-color(
  426. (
  427. disabled: map.get($theme, with-trailing-icon-disabled-trailing-icon-color),
  428. focus: map.get($theme, with-trailing-icon-focus-trailing-icon-color),
  429. hover: map.get($theme, with-trailing-icon-hover-trailing-icon-color),
  430. enabled: map.get($theme, with-trailing-icon-trailing-icon-color),
  431. pressed: map.get($theme, with-trailing-icon-pressed-trailing-icon-color),
  432. )
  433. );
  434. @include _ripple-theme(
  435. (
  436. focus-state-layer-color: map.get($theme, focus-state-layer-color),
  437. focus-state-layer-opacity: map.get($theme, focus-state-layer-opacity),
  438. hover-state-layer-color: map.get($theme, hover-state-layer-color),
  439. hover-state-layer-opacity: map.get($theme, hover-state-layer-opacity),
  440. pressed-state-layer-color: map.get($theme, pressed-state-layer-color),
  441. pressed-state-layer-opacity: map.get($theme, pressed-state-layer-opacity),
  442. )
  443. );
  444. &.mdc-evolution-chip--selected {
  445. @include _ripple-theme(
  446. (
  447. focus-state-layer-color:
  448. map.get($theme, selected-focus-state-layer-color),
  449. focus-state-layer-opacity:
  450. map.get($theme, selected-focus-state-layer-opacity),
  451. hover-state-layer-color:
  452. map.get($theme, selected-hover-state-layer-color),
  453. hover-state-layer-opacity:
  454. map.get($theme, selected-hover-state-layer-opacity),
  455. pressed-state-layer-color:
  456. map.get($theme, selected-pressed-state-layer-color),
  457. pressed-state-layer-opacity:
  458. map.get($theme, selected-pressed-state-layer-opacity),
  459. )
  460. );
  461. }
  462. &:not(.mdc-evolution-chip--selected) {
  463. @include _ripple-theme(
  464. (
  465. focus-state-layer-color:
  466. map.get($theme, unselected-focus-state-layer-color),
  467. focus-state-layer-opacity:
  468. map.get($theme, unselected-focus-state-layer-opacity),
  469. hover-state-layer-color:
  470. map.get($theme, unselected-hover-state-layer-color),
  471. hover-state-layer-opacity:
  472. map.get($theme, unselected-hover-state-layer-opacity),
  473. pressed-state-layer-color:
  474. map.get($theme, unselected-pressed-state-layer-color),
  475. pressed-state-layer-opacity:
  476. map.get($theme, unselected-pressed-state-layer-opacity),
  477. )
  478. );
  479. }
  480. }
  481. @function resolve-theme($theme, $resolvers) {
  482. $elevation-resolver: map.get($resolvers, elevation);
  483. @if $elevation-resolver == null {
  484. @return $theme;
  485. }
  486. $elevation-pairs: (
  487. container-shadow-color: (
  488. container-elevation,
  489. ),
  490. flat-container-shadow-color: (
  491. flat-container-elevation,
  492. ),
  493. elevated-container-shadow-color: (
  494. elevated-container-elevation,
  495. elevated-disabled-container-elevation,
  496. elevated-focus-container-elevation,
  497. elevated-hover-container-elevation,
  498. elevated-pressed-container-elevation,
  499. elevated-selected-container-elevation,
  500. elevated-selected-disabled-container-elevation,
  501. elevated-selected-focus-container-elevation,
  502. elevated-selected-hover-container-elevation,
  503. elevated-selected-pressed-container-elevation,
  504. flat-selected-focus-container-elevation,
  505. flat-selected-hover-container-elevation,
  506. flat-selected-pressed-container-elevation,
  507. flat-unselected-focus-container-elevation,
  508. flat-unselected-hover-container-elevation,
  509. flat-unselected-pressed-container-elevation,
  510. ),
  511. );
  512. @each $shadow-color-key, $elevation-keys in $elevation-pairs {
  513. $shadow-color: map.get($theme, $shadow-color-key);
  514. @if $shadow-color != null {
  515. @each $key in $elevation-keys {
  516. $elevation: map.get($theme, $key);
  517. @if $elevation != null {
  518. $resolved-value: meta.call(
  519. $elevation-resolver,
  520. $elevation: $elevation,
  521. $shadow-color: $shadow-color
  522. );
  523. // Update the key with the resolved value.
  524. $theme: map.set($theme, $key, $resolved-value);
  525. }
  526. }
  527. }
  528. }
  529. @return $theme;
  530. }
  531. @mixin _ripple-theme($ripple-theme) {
  532. .mdc-evolution-chip__action--primary {
  533. @include ripple-theme.internal-theme-styles(
  534. (
  535. focus-state-layer-color: map.get($ripple-theme, focus-state-layer-color),
  536. focus-state-layer-opacity:
  537. map.get($ripple-theme, focus-state-layer-opacity),
  538. hover-state-layer-color: map.get($ripple-theme, hover-state-layer-color),
  539. hover-state-layer-opacity:
  540. map.get($ripple-theme, hover-state-layer-opacity),
  541. pressed-state-layer-color:
  542. map.get($ripple-theme, pressed-state-layer-color),
  543. pressed-state-layer-opacity:
  544. map.get($ripple-theme, pressed-state-layer-opacity),
  545. ),
  546. $ripple-target: $ripple-target
  547. );
  548. }
  549. }
  550. ///
  551. /// Sets the ripple color of the chip.
  552. /// @param {Color} $color - The color of the ripple.
  553. /// @param {Map} $opacity-map [null] - The optional opacity map for the states.
  554. ///
  555. @mixin ripple-color(
  556. $color,
  557. $opacity-map: null,
  558. $query: feature-targeting.all()
  559. ) {
  560. @include _ripple-color($color, $opacity-map, $query);
  561. }
  562. ///
  563. /// Sets the selected ripple color of the chip.
  564. /// @param {Color} $color - The color of the ripple.
  565. /// @param {Map} $opacity-map [null] - The optional opacity map for the states.
  566. ///
  567. @mixin selected-ripple-color(
  568. $color,
  569. $opacity-map: null,
  570. $query: feature-targeting.all()
  571. ) {
  572. &.mdc-evolution-chip--selected {
  573. @include ripple-color($color, $opacity-map, $query: $query);
  574. }
  575. }
  576. @mixin _ripple-color($color, $opacity-map, $query) {
  577. .mdc-evolution-chip__action--primary {
  578. @include ripple-theme.states(
  579. $color: $color,
  580. $opacity-map: $opacity-map,
  581. $query: $query,
  582. $ripple-target: $ripple-target
  583. );
  584. }
  585. }
  586. ///
  587. /// Sets the ripple color of the chip's trailing action.
  588. /// @param {Color} $color - The color of the ripple.
  589. /// @param {Map} $opacity-map [null] - The optional opacity map for the states.
  590. ///
  591. @mixin trailing-action-ripple-color(
  592. $color,
  593. $opacity-map: null,
  594. $query: feature-targeting.all()
  595. ) {
  596. .mdc-evolution-chip__action--trailing {
  597. @include ripple-theme.states(
  598. $color: $color,
  599. $opacity-map: $opacity-map,
  600. $query: $query,
  601. $ripple-target: $ripple-target
  602. );
  603. }
  604. }
  605. ///
  606. /// Sets the size of the trailing action's ripple.
  607. /// @param {Number} $size - The size of the ripple.
  608. ///
  609. @mixin trailing-action-ripple-size($size, $query: feature-targeting.all()) {
  610. $feat-structure: feature-targeting.create-target($query, structure);
  611. .mdc-evolution-chip__ripple--trailing {
  612. @include feature-targeting.targets($feat-structure) {
  613. @include theme.property(height, $size);
  614. @include theme.property(width, $size);
  615. }
  616. }
  617. }
  618. ///
  619. /// Sets the density scale for the chip.
  620. /// @param {Number | String} $density-scale - Density scale value for component.
  621. /// Supported density scale values are `-2`, `-1`, `0`.
  622. ///
  623. @mixin density($density-scale, $query: feature-targeting.all()) {
  624. $height: density.prop-value(
  625. $density-config: $density-config,
  626. $density-scale: $density-scale,
  627. $property-name: height,
  628. );
  629. @include height($height, $query: $query);
  630. @if $density-scale != 0 {
  631. @include _reset-touch-target($query: $query);
  632. }
  633. }
  634. ///
  635. /// Resets touch target-related styles. This is called from the density mixin to
  636. /// automatically remove the increased touch target, since dense components
  637. /// don't have the same default a11y requirements.
  638. /// @access private
  639. ///
  640. @mixin _reset-touch-target($query: feature-targeting.all()) {
  641. $feat-structure: feature-targeting.create-target($query, structure);
  642. .mdc-evolution-chip__action-touch {
  643. @include feature-targeting.targets($feat-structure) {
  644. display: none;
  645. }
  646. }
  647. }
  648. ///
  649. /// Sets custom height for the chip.
  650. /// @param {Number} $height - The height of the chip.
  651. ///
  652. @mixin height($height, $query: feature-targeting.all()) {
  653. $feat-structure: feature-targeting.create-target($query, structure);
  654. @include feature-targeting.targets($feat-structure) {
  655. @include theme.property(height, $height);
  656. }
  657. }
  658. @mixin _container-shape($radius) {
  659. @include shape.radius($radius);
  660. #{$ripple-target} {
  661. @include shape.radius($radius);
  662. }
  663. .mdc-evolution-chip__action--primary:before {
  664. @include shape.radius($radius);
  665. }
  666. }
  667. ///
  668. /// Sets the shape radius of the chip.
  669. /// @param {Number|List} $radius - Shape radius in `border-radius` CSS format.
  670. /// @param {Boolean} $rtl-reflexive - True flips radius corners in RTL.
  671. ///
  672. @mixin shape-radius(
  673. $radius,
  674. $rtl-reflexive: false,
  675. $density-scale: $density-scale,
  676. $query: feature-targeting.all()
  677. ) {
  678. $height: density.prop-value(
  679. $density-config: $density-config,
  680. $density-scale: $density-scale,
  681. $property-name: height,
  682. );
  683. @include shape.radius(
  684. $radius,
  685. $rtl-reflexive,
  686. $component-height: $height,
  687. $query: $query
  688. );
  689. #{$ripple-target} {
  690. @include shape.radius(
  691. $radius,
  692. $rtl-reflexive,
  693. $component-height: $height,
  694. $query: $query
  695. );
  696. }
  697. .mdc-evolution-chip__action--primary:before {
  698. @include shape.radius(
  699. $radius,
  700. $rtl-reflexive,
  701. $component-height: $height,
  702. $query: $query
  703. );
  704. }
  705. .mdc-evolution-chip__icon--primary {
  706. @include shape.radius(
  707. $radius,
  708. $rtl-reflexive,
  709. $component-height: $height,
  710. $query: $query
  711. );
  712. }
  713. }
  714. ///
  715. /// Sets the width of the chip outline.
  716. /// @param {Number} $width - The width of the chip outline.
  717. ///
  718. @mixin outline-width($width, $query: feature-targeting.all()) {
  719. $feat-structure: feature-targeting.create-target($query, structure);
  720. .mdc-evolution-chip__action--primary:before {
  721. @include feature-targeting.targets($feat-structure) {
  722. @include theme.property(border-width, $width);
  723. }
  724. }
  725. }
  726. ///
  727. /// Customizes the outline color, using a Color or state Map.
  728. /// - To set only the default color, provide a single Color.
  729. /// - To set one or more state colors, provide a state Map with optional keys.
  730. /// - Supported state Map keys: `default`, `enabled`, `focus`, `disabled`.
  731. ///
  732. /// @example
  733. /// @include outline-color(blue);
  734. /// @include outline-color((disabled: gray));
  735. ///
  736. /// @param {Color | Map} $color-or-map - The outline's color or a state Map
  737. ///
  738. @mixin outline-color($color-or-map, $query: feature-targeting.all()) {
  739. @include _outline-color(state.get-default-state($color-or-map), $query);
  740. &:not(.mdc-evolution-chip--disabled) {
  741. @include _outline-color(state.get-enabled-state($color-or-map), $query);
  742. }
  743. @include _focus-outline-color(state.get-focus-state($color-or-map), $query);
  744. &.mdc-evolution-chip--disabled {
  745. @include _outline-color(state.get-disabled-state($color-or-map), $query);
  746. }
  747. }
  748. ///
  749. /// Customizes the selected outline color, using a Color or state Map.
  750. /// - To set only the default color, provide a single Color.
  751. /// - To set one or more state colors, provide a state Map with optional keys.
  752. /// - Supported state Map keys: `default`, `enabled`, `focus`, `disabled`.
  753. ///
  754. /// @example
  755. /// @include selected-outline-color(blue);
  756. /// @include selected-outline-color((disabled: gray));
  757. ///
  758. /// @param {Color | Map} $color-or-map - The outline's color or a state Map
  759. ///
  760. @mixin selected-outline-color($color-or-map, $query: feature-targeting.all()) {
  761. &.mdc-evolution-chip--selected {
  762. @include outline-color($color-or-map, $query: $query);
  763. }
  764. }
  765. @mixin _outline-color($color, $query: feature-targeting.all()) {
  766. $feat-color: feature-targeting.create-target($query, color);
  767. .mdc-evolution-chip__action--primary:before {
  768. @include feature-targeting.targets($feat-color) {
  769. @if $color {
  770. @include theme.property(border-color, $color);
  771. }
  772. // TODO(b/206694742): Find a better solution.
  773. @if $color == transparent {
  774. @include dom.forced-colors-mode($exclude-ie11: true) {
  775. @include theme.property(border-color, CanvasText);
  776. }
  777. }
  778. }
  779. }
  780. }
  781. @mixin _focus-outline-color($color, $query: feature-targeting.all()) {
  782. $feat-color: feature-targeting.create-target($query, color);
  783. .mdc-evolution-chip__action--primary:not(.mdc-evolution-chip__action--presentational) {
  784. @include ripple-theme.focus() {
  785. &:before {
  786. @include feature-targeting.targets($feat-color) {
  787. @if $color {
  788. @include theme.property(border-color, $color);
  789. }
  790. }
  791. }
  792. }
  793. }
  794. }
  795. ///
  796. /// Sets the style of the chip outline.
  797. /// @param {String} $style - The style of the chip outline.
  798. ///
  799. @mixin outline-style($style, $query: feature-targeting.all()) {
  800. $feat-structure: feature-targeting.create-target($query, structure);
  801. .mdc-evolution-chip__action--primary:before {
  802. @include feature-targeting.targets($feat-structure) {
  803. @include theme.property(border-style, $style);
  804. }
  805. }
  806. }
  807. ///
  808. /// Customizes the container color, using a Color or state Map.
  809. /// - To set only the default color, provide a single Color.
  810. /// - To set one or more state colors, provide a state Map with optional keys.
  811. /// - Supported state Map keys: `default`, `enabled`, `disabled`.
  812. ///
  813. /// @example
  814. /// @include container-color(blue);
  815. /// @include container-color((disabled: gray));
  816. ///
  817. /// @param {Color | Map} $color-or-map - The container's color or a state Map
  818. ///
  819. @mixin container-color($color-or-map, $query: feature-targeting.all()) {
  820. @include _container-color(state.get-default-state($color-or-map), $query);
  821. &:not(.mdc-evolution-chip--disabled) {
  822. @include _container-color(state.get-enabled-state($color-or-map), $query);
  823. }
  824. &.mdc-evolution-chip--disabled {
  825. @include _container-color(state.get-disabled-state($color-or-map), $query);
  826. }
  827. }
  828. ///
  829. /// Customizes the selected container color, using a Color or state Map.
  830. /// - To set only the default color, provide a single Color.
  831. /// - To set one or more state colors, provide a state Map with optional keys.
  832. /// - Supported state Map keys: `default`, `enabled`, `disabled`.
  833. ///
  834. /// @example
  835. /// @include selected-container-color(blue);
  836. /// @include selected-container-color((disabled: gray));
  837. ///
  838. /// @param {Color | Map} $color-or-map - The container's color or a state Map
  839. ///
  840. @mixin selected-container-color(
  841. $color-or-map,
  842. $query: feature-targeting.all()
  843. ) {
  844. &.mdc-evolution-chip--selected {
  845. @include container-color($color-or-map, $query: $query);
  846. }
  847. }
  848. @mixin _container-color($color, $query: feature-targeting.all()) {
  849. $feat-color: feature-targeting.create-target($query, color);
  850. @include feature-targeting.targets($feat-color) {
  851. @if $color {
  852. @include theme.property(background-color, $color);
  853. }
  854. }
  855. }
  856. ///
  857. /// Customizes the text label color, using a Color or state Map.
  858. /// - To set only the default color, provide a single Color.
  859. /// - To set one or more state colors, provide a state Map with optional keys.
  860. /// - Supported state Map keys: `default`, `enabled`, `hover`, `focus`, `disabled`.
  861. ///
  862. /// @example
  863. /// @include text-label-color(blue);
  864. /// @include text-label-color((disabled: gray));
  865. ///
  866. /// @param {Color | Map} $color-or-map - The label's color or a state Map
  867. ///
  868. @mixin text-label-color($color-or-map, $query: feature-targeting.all()) {
  869. @include _text-label-color(state.get-default-state($color-or-map), $query);
  870. &:not(.mdc-evolution-chip--disabled) {
  871. @include _text-label-color(state.get-enabled-state($color-or-map), $query);
  872. }
  873. .mdc-evolution-chip__action--primary:not(.mdc-evolution-chip__action--presentational):hover {
  874. @include _text-label-color(state.get-hover-state($color-or-map), $query);
  875. }
  876. .mdc-evolution-chip__action--primary:not(.mdc-evolution-chip__action--presentational) {
  877. @include ripple-theme.focus() {
  878. @include _text-label-color(state.get-focus-state($color-or-map), $query);
  879. }
  880. }
  881. &.mdc-evolution-chip--disabled {
  882. @include _text-label-color(state.get-disabled-state($color-or-map), $query);
  883. }
  884. }
  885. ///
  886. /// Customizes the selected text label color, using a Color or state Map.
  887. /// - To set only the default color, provide a single Color.
  888. /// - To set one or more state colors, provide a state Map with optional keys.
  889. /// - Supported state Map keys: `default`, `hover`, `focus`, `disabled`.
  890. ///
  891. /// @example
  892. /// @include selected-text-label-color(blue);
  893. /// @include selected-text-label-color((disabled: gray));
  894. ///
  895. /// @param {Color | Map} $color-or-map - The label's color or a state Map
  896. ///
  897. @mixin selected-text-label-color(
  898. $color-or-map,
  899. $query: feature-targeting.all()
  900. ) {
  901. &.mdc-evolution-chip--selected {
  902. @include text-label-color($color-or-map, $query: $query);
  903. }
  904. }
  905. @mixin _text-label-color($color, $query: feature-targeting.all()) {
  906. $feat-color: feature-targeting.create-target($query, color);
  907. .mdc-evolution-chip__text-label {
  908. @include feature-targeting.targets($feat-color) {
  909. @if $color {
  910. @include theme.property(color, $color);
  911. }
  912. }
  913. }
  914. }
  915. ///
  916. /// Sets the type scale of the text label.
  917. /// @param {String} $type-scale - The type scale of the text label.
  918. ///
  919. @mixin text-label-type-scale($type-scale, $query: feature-targeting.all()) {
  920. .mdc-evolution-chip__text-label {
  921. @include typography.typography($type-scale, $query: $query);
  922. }
  923. }
  924. ///
  925. /// Sets the size of the graphic.
  926. /// @param {Number} $size - The size of the graphic.
  927. ///
  928. @mixin graphic-size($size, $query: feature-targeting.all()) {
  929. $feat-structure: feature-targeting.create-target($query, structure);
  930. // Expose the width as a readable custom property that can be used when
  931. // computing the chip bounding client rect as an additive value for the chip
  932. // width. This solves for selectable chips without icons growing/shrinking as
  933. // they toggle their selected state. The ripple dimensions will have been
  934. // computed based on the unselected bounding client react which will not have
  935. // enough horizontal space to account for the growth in width.
  936. &.mdc-evolution-chip--selectable:not(.mdc-evolution-chip--with-primary-icon) {
  937. @if $size {
  938. @include theme.property(--mdc-chip-graphic-selected-width, $size);
  939. }
  940. }
  941. .mdc-evolution-chip__graphic {
  942. @include feature-targeting.targets($feat-structure) {
  943. @include theme.property(height, $size);
  944. @include theme.property(width, $size);
  945. @include theme.property(font-size, $size);
  946. }
  947. }
  948. }
  949. ///
  950. /// Customizes the icon color, using a Color or state Map.
  951. /// - To set only the default color, provide a single Color.
  952. /// - To set one or more state colors, provide a state Map with optional keys.
  953. /// - Supported state Map keys: `default`, `enabled`, `focus`, `disabled`.
  954. ///
  955. /// @example
  956. /// @include icon-color(blue);
  957. /// @include icon-color((disabled: gray));
  958. ///
  959. /// @param {Color | Map} $color-or-map - The icon's color or a state Map
  960. ///
  961. @mixin icon-color($color-or-map, $query: feature-targeting.all()) {
  962. @include _icon-color(state.get-default-state($color-or-map), $query);
  963. &:not(.mdc-evolution-chip--disabled) {
  964. @include _icon-color(state.get-enabled-state($color-or-map), $query);
  965. }
  966. .mdc-evolution-chip__action--primary:not(.mdc-evolution-chip__action--presentational):hover {
  967. @include _icon-color(state.get-hover-state($color-or-map), $query);
  968. }
  969. .mdc-evolution-chip__action--primary:not(.mdc-evolution-chip__action--presentational) {
  970. @include ripple-theme.focus() {
  971. @include _icon-color(state.get-focus-state($color-or-map), $query);
  972. }
  973. }
  974. &.mdc-evolution-chip--disabled {
  975. @include _icon-color(state.get-disabled-state($color-or-map), $query);
  976. }
  977. }
  978. @mixin _icon-color($color, $query: feature-targeting.all()) {
  979. $feat-color: feature-targeting.create-target($query, color);
  980. .mdc-evolution-chip__icon--primary {
  981. @include feature-targeting.targets($feat-color) {
  982. @if $color {
  983. @include theme.property(color, $color);
  984. }
  985. }
  986. }
  987. }
  988. ///
  989. /// Customizes the icon container color, using a Color or state Map.
  990. /// - To set only the default color, provide a single Color.
  991. /// - To set one or more state colors, provide a state Map with optional keys.
  992. /// - Supported state Map keys: `default`, `hover`, `focus`, `disabled`.
  993. ///
  994. /// @example
  995. /// @include icon-container-color(blue);
  996. /// @include icon-container-color((disabled: gray));
  997. ///
  998. /// @param {Color | Map} $color-or-map - The icon's container color or a state Map
  999. ///
  1000. @mixin icon-container-color($color-or-map, $query: feature-targeting.all()) {
  1001. @include _icon-container-color(
  1002. state.get-default-state($color-or-map),
  1003. $query
  1004. );
  1005. .mdc-evolution-chip__action--primary:not(.mdc-evolution-chip__action--presentational):hover {
  1006. @include _icon-container-color(
  1007. state.get-hover-state($color-or-map),
  1008. $query
  1009. );
  1010. }
  1011. .mdc-evolution-chip__action--primary:not(.mdc-evolution-chip__action--presentational) {
  1012. @include ripple-theme.focus() {
  1013. @include _icon-container-color(
  1014. state.get-focus-state($color-or-map),
  1015. $query
  1016. );
  1017. }
  1018. }
  1019. &.mdc-evolution-chip--disabled {
  1020. @include _icon-container-color(
  1021. state.get-disabled-state($color-or-map),
  1022. $query
  1023. );
  1024. }
  1025. }
  1026. @mixin _icon-container-color($color, $query: feature-targeting.all()) {
  1027. $feat-color: feature-targeting.create-target($query, color);
  1028. .mdc-evolution-chip__icon--primary {
  1029. @include feature-targeting.targets($feat-color) {
  1030. @if $color {
  1031. @include theme.property(background-color, $color);
  1032. }
  1033. }
  1034. }
  1035. }
  1036. ///
  1037. /// Sets the size of the icon.
  1038. /// @param {Number} $size - The size of the icon.
  1039. ///
  1040. @mixin icon-size($size, $query: feature-targeting.all()) {
  1041. $feat-structure: feature-targeting.create-target($query, structure);
  1042. .mdc-evolution-chip__icon--primary {
  1043. @include feature-targeting.targets($feat-structure) {
  1044. @include theme.property(height, $size);
  1045. @include theme.property(width, $size);
  1046. @include theme.property(font-size, $size);
  1047. }
  1048. }
  1049. }
  1050. ///
  1051. /// Sets the size of the trailing action.
  1052. /// @param {Number} $size - The size of the trailing action.
  1053. ///
  1054. @mixin trailing-action-size($size, $query: feature-targeting.all()) {
  1055. $feat-structure: feature-targeting.create-target($query, structure);
  1056. .mdc-evolution-chip__icon--trailing {
  1057. @include feature-targeting.targets($feat-structure) {
  1058. @include theme.property(height, $size);
  1059. @include theme.property(width, $size);
  1060. @include theme.property(font-size, $size);
  1061. }
  1062. }
  1063. }
  1064. ///
  1065. /// Customizes the trailing action color, using a Color or state Map.
  1066. /// - To set only the default color, provide a single Color.
  1067. /// - To set one or more state colors, provide a state Map with optional keys.
  1068. /// - Supported state Map keys: `default`, `hover`, `focus`, `disabled`.
  1069. ///
  1070. /// @example
  1071. /// @include trailing-action-color(blue);
  1072. /// @include trailing-action-color((disabled: gray));
  1073. ///
  1074. /// @param {Color | Map} $color-or-map - The trailing action's color or a state Map
  1075. ///
  1076. @mixin trailing-action-color($color-or-map, $query: feature-targeting.all()) {
  1077. @include _trailing-action-color(
  1078. state.get-default-state($color-or-map),
  1079. $query
  1080. );
  1081. &:not(.mdc-evolution-chip--disabled) {
  1082. @include _trailing-action-color(
  1083. state.get-enabled-state($color-or-map),
  1084. $query
  1085. );
  1086. }
  1087. .mdc-evolution-chip__action--trailing:hover {
  1088. @include _trailing-action-color(
  1089. state.get-hover-state($color-or-map),
  1090. $query
  1091. );
  1092. }
  1093. .mdc-evolution-chip__action--trailing {
  1094. @include ripple-theme.focus() {
  1095. @include _trailing-action-color(
  1096. state.get-focus-state($color-or-map),
  1097. $query
  1098. );
  1099. }
  1100. }
  1101. &.mdc-evolution-chip--disabled {
  1102. @include _trailing-action-color(
  1103. state.get-disabled-state($color-or-map),
  1104. $query
  1105. );
  1106. }
  1107. }
  1108. @mixin _trailing-action-color($color, $query: feature-targeting.all()) {
  1109. $feat-color: feature-targeting.create-target($query, color);
  1110. .mdc-evolution-chip__icon--trailing {
  1111. @include feature-targeting.targets($feat-color) {
  1112. @if $color {
  1113. @include theme.property(color, $color);
  1114. }
  1115. }
  1116. }
  1117. }
  1118. ///
  1119. /// Sets the size of the checkmark.
  1120. /// @param {Number} $size - The size of the checkmark.
  1121. ///
  1122. @mixin checkmark-size($size, $query: feature-targeting.all()) {
  1123. $feat-structure: feature-targeting.create-target($query, structure);
  1124. .mdc-evolution-chip__checkmark {
  1125. @include feature-targeting.targets($feat-structure) {
  1126. @include theme.property(height, $size);
  1127. @include theme.property(width, $size);
  1128. }
  1129. }
  1130. }
  1131. ///
  1132. /// Customizes the checkmark color, using a Color or state Map.
  1133. /// - To set only the default color, provide a single Color.
  1134. /// - To set one or more state colors, provide a state Map with optional keys.
  1135. /// - Supported state Map keys: `default`, `enabled`, `hover`, `focus`, `disabled`.
  1136. ///
  1137. /// @example
  1138. /// @include checkmark-color(blue);
  1139. /// @include checkmark-color((disabled: gray));
  1140. ///
  1141. /// @param {Color | Map} $color-or-map - The checkmark's color or a state Map
  1142. ///
  1143. @mixin checkmark-color($color-or-map, $query: feature-targeting.all()) {
  1144. @include _checkmark-color(state.get-default-state($color-or-map), $query);
  1145. &:not(.mdc-evolution-chip--disabled) {
  1146. @include _checkmark-color(state.get-enabled-state($color-or-map), $query);
  1147. }
  1148. .mdc-evolution-chip__action--primary:not(.mdc-evolution-chip__action--presentational):hover {
  1149. @include _checkmark-color(state.get-hover-state($color-or-map), $query);
  1150. }
  1151. .mdc-evolution-chip__action--primary {
  1152. @include ripple-theme.focus() {
  1153. @include _checkmark-color(state.get-focus-state($color-or-map), $query);
  1154. }
  1155. }
  1156. &.mdc-evolution-chip--disabled {
  1157. @include _checkmark-color(state.get-disabled-state($color-or-map), $query);
  1158. }
  1159. }
  1160. @mixin _checkmark-color($color, $query: feature-targeting.all()) {
  1161. $feat-color: feature-targeting.create-target($query, color);
  1162. .mdc-evolution-chip__checkmark {
  1163. @include feature-targeting.targets($feat-color) {
  1164. @if $color {
  1165. @include theme.property(color, $color);
  1166. }
  1167. }
  1168. }
  1169. }
  1170. ///
  1171. /// Customizes the checkmark container color, using a Color or state Map.
  1172. /// - To set only the default color, provide a single Color.
  1173. /// - To set one or more state colors, provide a state Map with optional keys.
  1174. /// - Supported state Map keys: `default`, `hover`, `focus`, `disabled`.
  1175. ///
  1176. /// @example
  1177. /// @include checkmark-container-color(blue);
  1178. /// @include checkmark-container-color((disabled: gray));
  1179. ///
  1180. /// @param {Color | Map} $color-or-map - The checkmark container's color or a state Map
  1181. ///
  1182. @mixin checkmark-container-color(
  1183. $color-or-map,
  1184. $query: feature-targeting.all()
  1185. ) {
  1186. @include _checkmark-container-color(
  1187. state.get-default-state($color-or-map),
  1188. $query
  1189. );
  1190. &.mdc-evolution-chip--disabled {
  1191. @include _checkmark-container-color(
  1192. state.get-disabled-state($color-or-map),
  1193. $query
  1194. );
  1195. }
  1196. }
  1197. @mixin _checkmark-container-color($color, $query: feature-targeting.all()) {
  1198. $feat-color: feature-targeting.create-target($query, color);
  1199. .mdc-evolution-chip__checkmark-background {
  1200. @include feature-targeting.targets($feat-color) {
  1201. @if $color {
  1202. @include theme.property(background-color, $color);
  1203. }
  1204. }
  1205. }
  1206. }
  1207. ///
  1208. /// Sets the horizontal padding for the chip.
  1209. /// @param {Number} $leading - The leading padding for the chip.
  1210. /// @param {Number} $trailing [$leading] - The trailing padding for the chip.
  1211. ///
  1212. @mixin horizontal-padding(
  1213. $leading,
  1214. $trailing: $leading,
  1215. $query: feature-targeting.all()
  1216. ) {
  1217. $feat-structure: feature-targeting.create-target($query, structure);
  1218. .mdc-evolution-chip__action--primary {
  1219. @include feature-targeting.targets($feat-structure) {
  1220. @include rtl.reflexive-property(padding, $leading, $trailing);
  1221. }
  1222. }
  1223. }
  1224. ///
  1225. /// Sets the horizontal padding for chips with a graphic.
  1226. /// @param {Number} $graphic-leading - The leading padding for the graphic.
  1227. /// @param {Number} $graphic-trailing - The trailing padding for the graphic.
  1228. /// @param {Number} $primary-trailing - The trailing padding for the primary action.
  1229. ///
  1230. @mixin with-graphic-horizontal-padding(
  1231. $graphic-leading,
  1232. $graphic-trailing,
  1233. $primary-trailing,
  1234. $query: feature-targeting.all()
  1235. ) {
  1236. $feat-structure: feature-targeting.create-target($query, structure);
  1237. &.mdc-evolution-chip--with-primary-graphic {
  1238. .mdc-evolution-chip__graphic {
  1239. @include feature-targeting.targets($feat-structure) {
  1240. @include rtl.reflexive-property(
  1241. padding,
  1242. $graphic-leading,
  1243. $graphic-trailing
  1244. );
  1245. }
  1246. }
  1247. .mdc-evolution-chip__action--primary {
  1248. @include feature-targeting.targets($feat-structure) {
  1249. @include rtl.reflexive-property(padding, 0, $primary-trailing);
  1250. }
  1251. }
  1252. }
  1253. }
  1254. ///
  1255. /// Sets the horizontal padding for chips with a trailing action.
  1256. /// @param {Number} $primary-leading - The leading padding for the primary action.
  1257. /// @param {Number} $trailing-action-leading - The leading padding for the trailing action.
  1258. /// @param {Number} $trailing-action-trailing - The trailing padding for the trailing action.
  1259. ///
  1260. @mixin with-trailing-action-horizontal-padding(
  1261. $primary-leading,
  1262. $trailing-action-leading,
  1263. $trailing-action-trailing,
  1264. $query: feature-targeting.all()
  1265. ) {
  1266. $feat-structure: feature-targeting.create-target($query, structure);
  1267. &.mdc-evolution-chip--with-trailing-action {
  1268. .mdc-evolution-chip__action--trailing {
  1269. @include feature-targeting.targets($feat-structure) {
  1270. @include rtl.reflexive-property(
  1271. padding,
  1272. $trailing-action-leading,
  1273. $trailing-action-trailing
  1274. );
  1275. }
  1276. }
  1277. #{$ripple-target-trailing} {
  1278. @include feature-targeting.targets($feat-structure) {
  1279. @include rtl.reflexive-position(left, $trailing-action-leading);
  1280. }
  1281. }
  1282. .mdc-evolution-chip__action--primary {
  1283. @include feature-targeting.targets($feat-structure) {
  1284. @include rtl.reflexive-property(padding, $primary-leading, 0);
  1285. }
  1286. }
  1287. }
  1288. }
  1289. ///
  1290. /// Sets the horizontal padding for chips with a graphic and trailing action.
  1291. /// @param {Number} $graphic-leading - The leading padding for the graphic.
  1292. /// @param {Number} $graphic-trailing - The trailing padding for the graphic.
  1293. /// @param {Number} $trailing-action-leading - The leading padding for the trailing action.
  1294. /// @param {Number} $trailing-action-trailing - The trailing padding for the trailing action.
  1295. ///
  1296. @mixin with-graphic-and-trailing-action-horizontal-padding(
  1297. $graphic-leading,
  1298. $graphic-trailing,
  1299. $trailing-action-leading,
  1300. $trailing-action-trailing,
  1301. $query: feature-targeting.all()
  1302. ) {
  1303. $feat-structure: feature-targeting.create-target($query, structure);
  1304. &.mdc-evolution-chip--with-primary-graphic.mdc-evolution-chip--with-trailing-action {
  1305. .mdc-evolution-chip__graphic {
  1306. @include feature-targeting.targets($feat-structure) {
  1307. @include rtl.reflexive-property(
  1308. padding,
  1309. $graphic-leading,
  1310. $graphic-trailing
  1311. );
  1312. }
  1313. }
  1314. .mdc-evolution-chip__action--trailing {
  1315. @include feature-targeting.targets($feat-structure) {
  1316. @include rtl.reflexive-property(
  1317. padding,
  1318. $trailing-action-leading,
  1319. $trailing-action-trailing
  1320. );
  1321. }
  1322. }
  1323. #{$ripple-target-trailing} {
  1324. @include feature-targeting.targets($feat-structure) {
  1325. @include rtl.reflexive-position(left, $trailing-action-leading);
  1326. }
  1327. }
  1328. .mdc-evolution-chip__action--primary {
  1329. @include feature-targeting.targets($feat-structure) {
  1330. @include rtl.reflexive-property(padding, 0, 0);
  1331. }
  1332. }
  1333. }
  1334. }
  1335. @mixin _container-elevation-theme($theme) {
  1336. @if map.get($theme, shadow) {
  1337. @include elevation-theme.shadow(map.get($theme, shadow));
  1338. }
  1339. @if map.get($theme, overlay-opacity) {
  1340. @include elevation-theme.overlay-opacity(map.get($theme, overlay-opacity));
  1341. }
  1342. // TODO(b/260053182): Remove setting overlay color after migration of customers
  1343. @if map.get($theme, overlay-color) {
  1344. @include elevation-theme.overlay-container-color(
  1345. map.get($theme, overlay-color)
  1346. );
  1347. }
  1348. }
  1349. // TODO(b/259913622): Use elevation's theme-style() mixin.
  1350. @mixin _container-elevation($map) {
  1351. $default-state: state.get-default-state($map);
  1352. @if $default-state {
  1353. @include _container-elevation-theme($default-state);
  1354. }
  1355. &:not(.mdc-evolution-chip--disabled) {
  1356. $enabled-state: state.get-enabled-state($map);
  1357. @if $enabled-state {
  1358. @include _container-elevation-theme($enabled-state);
  1359. }
  1360. }
  1361. @include ripple-theme.hover() {
  1362. $hover-state: state.get-hover-state($map);
  1363. @if $hover-state {
  1364. @include _container-elevation-theme($hover-state);
  1365. }
  1366. }
  1367. @include ripple-theme.focus() {
  1368. $focus-state: state.get-focus-state($map);
  1369. @if $focus-state {
  1370. @include _container-elevation-theme($focus-state);
  1371. }
  1372. }
  1373. @include ripple-theme.pressed() {
  1374. $pressed-state: state.get-pressed-state($map);
  1375. @if $pressed-state {
  1376. @include _container-elevation-theme($pressed-state);
  1377. }
  1378. }
  1379. &.mdc-evolution-chip--disabled {
  1380. $disabled-state: state.get-disabled-state($map);
  1381. @if $disabled-state {
  1382. @include _container-elevation-theme($disabled-state);
  1383. }
  1384. }
  1385. }
  1386. @mixin button-cursor($cursor) {
  1387. .mdc-evolution-chip__action {
  1388. cursor: $cursor;
  1389. }
  1390. }