|
| 1 | +@use 'sass:map'; |
| 2 | +@use '../../config'; |
| 3 | +@use '../../functions' as *; |
| 4 | +@use '../../schemas/' as *; |
| 5 | +@use '../../../utils/map' as *; |
| 6 | +@use '../../../color/functions' as *; |
| 7 | +@use '../../../elevations/' as *; |
| 8 | + |
| 9 | +//// |
| 10 | +/// @group themes |
| 11 | +/// @package theming |
| 12 | +/// @access public |
| 13 | +//// |
| 14 | + |
| 15 | +/// @param {Map} $schema [$light-material-schema] - The schema used as basis for styling the component. |
| 16 | +/// @param {Color} $file-names-background [null] - The file names container background color. |
| 17 | +/// @param {Color} $file-names-background--focused [null] - The file names container background color when the file input is focused. |
| 18 | +/// @param {Color} $file-names-background--filled [null] - The file names container background color when the file input is filled. |
| 19 | +/// @param {Color} $file-names-background--disabled [null] - The file names container background color when the file input is disabled. |
| 20 | +/// @param {Color} $file-names-foreground [null] - The file names color. |
| 21 | +/// @param {Color} $file-names-foreground--focused [null] - The file names color when the file input is focused. |
| 22 | +/// @param {Color} $file-names-foreground--filled [null] - The file names color when the file input is filled. |
| 23 | +/// @param {Color} $file-names-foreground--disabled [null] - The file names color when the file input is disabled. |
| 24 | +/// @param {Color} $file-selector-button-background [null] - The file input selector button background color. |
| 25 | +/// @param {Color} $file-selector-button-background--focused [null] - The selector button background color when the file input is focused. |
| 26 | +/// @param {Color} $file-selector-button-background--filled [null] - The selector button background color when the file input is filled. |
| 27 | +/// @param {Color} $file-selector-button-background--disabled [null] - The selector button background color when the file input is disabled. |
| 28 | +/// @param {Color} $file-selector-button-foreground [null] - The file input selector button foreground color. |
| 29 | +/// @param {Color} $file-selector-button-foreground--focused [null] - The selector button foreground color when the file input is focused. |
| 30 | +/// @param {Color} $file-selector-button-foreground--filled [null] - The selector button foreground color when the file input is filled. |
| 31 | +/// @param {Color} $file-selector-button-foreground--disabled [null] - The selector button foreground color when the file input is disabled. |
| 32 | +/// @example scss Change the focused border and label colors |
| 33 | +/// $my-file-input-theme: file-input-theme($file-names-foreground: #09f); |
| 34 | +/// // Pass the theme to the css-vars() mixin |
| 35 | +/// @include css-vars($my-file-input-theme); |
| 36 | +@function file-input-theme( |
| 37 | + $schema: $light-material-schema, |
| 38 | + $file-names-background: null, |
| 39 | + $file-names-background--focused: null, |
| 40 | + $file-names-background--filled: null, |
| 41 | + $file-names-background--disabled: null, |
| 42 | + $file-names-foreground: null, |
| 43 | + $file-names-foreground--focused: null, |
| 44 | + $file-names-foreground--filled: null, |
| 45 | + $file-names-foreground--disabled: null, |
| 46 | +
|
| 47 | + $file-selector-button-background: null, |
| 48 | + $file-selector-button-background--focused: null, |
| 49 | + $file-selector-button-background--filled: null, |
| 50 | + $file-selector-button-background--disabled: null, |
| 51 | + $file-selector-button-foreground: null, |
| 52 | + $file-selector-button-foreground--focused: null, |
| 53 | + $file-selector-button-foreground--filled: null, |
| 54 | + $file-selector-button-foreground--disabled: null |
| 55 | +) { |
| 56 | + $name: 'igx-file-input'; |
| 57 | + $file-input-schema: (); |
| 58 | + |
| 59 | + @if map.has-key($schema, 'file-input') { |
| 60 | + $file-input-schema: map.get($schema, 'file-input'); |
| 61 | + } @else { |
| 62 | + $file-input-schema: $schema; |
| 63 | + } |
| 64 | + |
| 65 | + $theme: digest-schema($file-input-schema); |
| 66 | + |
| 67 | + @if $file-names-background != transparent { |
| 68 | + @if not($file-names-background--focused) and $file-names-background { |
| 69 | + $file-names-background--focused: dynamic-shade(var(--file-names-background)); |
| 70 | + } |
| 71 | + |
| 72 | + @if not($file-names-background--filled) and $file-names-background { |
| 73 | + $file-names-background--filled: $file-names-background; |
| 74 | + } |
| 75 | + |
| 76 | + @if not($file-names-background--disabled) and $file-names-background { |
| 77 | + $file-names-background--disabled: hsla(from $file-names-background h s l / 0.4); |
| 78 | + } |
| 79 | + |
| 80 | + @if not($file-names-foreground) and $file-names-background { |
| 81 | + $file-names-foreground: adaptive-contrast($file-names-background); |
| 82 | + } |
| 83 | + |
| 84 | + @if not($file-names-foreground--focused) and $file-names-background--focused { |
| 85 | + $file-names-foreground--focused: adaptive-contrast($file-names-background--focused); |
| 86 | + } |
| 87 | + |
| 88 | + @if not($file-names-foreground--filled) and $file-names-background--filled { |
| 89 | + $file-names-foreground--filled: adaptive-contrast($file-names-background--filled); |
| 90 | + } |
| 91 | + |
| 92 | + @if not($file-names-foreground--disabled) and $file-names-background--disabled { |
| 93 | + $file-names-foreground--disabled: adaptive-contrast($file-names-background--disabled); |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | + @if $file-selector-button-background != transparent { |
| 98 | + @if not($file-selector-button-background--focused) and $file-selector-button-background { |
| 99 | + $file-selector-button-background--focused: dynamic-shade(var(--file-selector-button-background)); |
| 100 | + } |
| 101 | + |
| 102 | + @if not($file-selector-button-background--filled) and $file-selector-button-background { |
| 103 | + $file-selector-button-background--filled: $file-selector-button-background; |
| 104 | + } |
| 105 | + |
| 106 | + @if not($file-selector-button-background--disabled) and $file-selector-button-background { |
| 107 | + $file-selector-button-background--disabled: hsla(from $file-selector-button-background h s l / 0.4); |
| 108 | + } |
| 109 | + |
| 110 | + @if not($file-selector-button-foreground) and $file-selector-button-background { |
| 111 | + $file-selector-button-foreground: adaptive-contrast($file-selector-button-background); |
| 112 | + } |
| 113 | + |
| 114 | + @if not($file-selector-button-foreground--focused) and $file-selector-button-background--focused { |
| 115 | + $file-selector-button-foreground--focused: adaptive-contrast($file-selector-button-background--focused); |
| 116 | + } |
| 117 | + |
| 118 | + @if not($file-selector-button-foreground--filled) and $file-selector-button-background--filled { |
| 119 | + $file-selector-button-foreground--filled: adaptive-contrast($file-selector-button-background--filled); |
| 120 | + } |
| 121 | + |
| 122 | + @if not($file-selector-button-foreground--disabled) and $file-selector-button-background--disabled { |
| 123 | + $file-selector-button-foreground--disabled: adaptive-contrast($file-selector-button-background--disabled); |
| 124 | + } |
| 125 | + } |
| 126 | + |
| 127 | + @return extend( |
| 128 | + $theme, |
| 129 | + ( |
| 130 | + name: $name, |
| 131 | + file-names-background: $file-names-background, |
| 132 | + file-names-background--focused: $file-names-background--focused, |
| 133 | + file-names-background--filled: $file-names-background--filled, |
| 134 | + file-names-background--disabled: $file-names-background--disabled, |
| 135 | + file-names-foreground: $file-names-foreground, |
| 136 | + file-names-foreground--focused: $file-names-foreground--focused, |
| 137 | + file-names-foreground--filled: $file-names-foreground--filled, |
| 138 | + file-names-foreground--disabled: $file-names-foreground--disabled, |
| 139 | + |
| 140 | + file-selector-button-background: $file-selector-button-background, |
| 141 | + file-selector-button-background--focused: $file-selector-button-background--focused, |
| 142 | + file-selector-button-background--filled: $file-selector-button-background--filled, |
| 143 | + file-selector-button-background--disabled: $file-selector-button-background--disabled, |
| 144 | + file-selector-button-foreground: $file-selector-button-foreground, |
| 145 | + file-selector-button-foreground--focused: $file-selector-button-foreground--focused, |
| 146 | + file-selector-button-foreground--filled: $file-selector-button-foreground--filled, |
| 147 | + file-selector-button-foreground--disabled: $file-selector-button-foreground--disabled, |
| 148 | + ) |
| 149 | + ); |
| 150 | +} |
0 commit comments