|
| 1 | +@use 'sass:map'; |
| 2 | +@use 'sass:meta'; |
| 3 | +@use '../../base' as *; |
| 4 | +@use '../../themes/schemas' as *; |
| 5 | +@use 'igniteui-theming/sass/animations/easings' as *; |
| 6 | + |
| 7 | +//// |
| 8 | +/// @group themes |
| 9 | +/// @access public |
| 10 | +//// |
| 11 | + |
| 12 | +/// @param {Map} $schema [$light-material-schema] - The schema used as basis for styling the component. |
| 13 | +/// @param {Color} $file-names-background [null] - The file names container background color. |
| 14 | +/// @param {Color} $file-names-background--focused [null] - The file names container background color when the file input is focused. |
| 15 | +/// @param {Color} $file-names-background--filled [null] - The file names container background color when the file input is filled. |
| 16 | +/// @param {Color} $file-names-background--disabled [null] - The file names container background color when the file input is disabled. |
| 17 | +/// @param {Color} $file-names-foreground [null] - The file names color. |
| 18 | +/// @param {Color} $file-names-foreground--focused [null] - The file names color when the file input is focused. |
| 19 | +/// @param {Color} $file-names-foreground--filled [null] - The file names color when the file input is filled. |
| 20 | +/// @param {Color} $file-names-foreground--disabled [null] - The file names color when the file input is disabled. |
| 21 | +/// @param {Color} $file-selector-button-background [null] - The file input selector button background color. |
| 22 | +/// @param {Color} $file-selector-button-background--focused [null] - The selector button background color when the file input is focused. |
| 23 | +/// @param {Color} $file-selector-button-background--filled [null] - The selector button background color when the file input is filled. |
| 24 | +/// @param {Color} $file-selector-button-background--disabled [null] - The selector button background color when the file input is disabled. |
| 25 | +/// @param {Color} $file-selector-button-foreground [null] - The file input selector button foreground color. |
| 26 | +/// @param {Color} $file-selector-button-foreground--focused [null] - The selector button foreground color when the file input is focused. |
| 27 | +/// @param {Color} $file-selector-button-foreground--filled [null] - The selector button foreground color when the file input is filled. |
| 28 | +/// @param {Color} $file-selector-button-foreground--disabled [null] - The selector button foreground color when the file input is disabled. |
| 29 | +/// @example scss Change the focused border and label colors |
| 30 | +/// $my-file-input-theme: file-input-theme($file-names-foreground: #09f); |
| 31 | +/// // Pass the theme to the css-vars() mixin |
| 32 | +/// @include css-vars($my-file-input-theme); |
| 33 | +@function file-input-theme( |
| 34 | + $schema: $light-material-schema, |
| 35 | + $file-names-background: null, |
| 36 | + $file-names-background--focused: null, |
| 37 | + $file-names-background--filled: null, |
| 38 | + $file-names-background--disabled: null, |
| 39 | + $file-names-foreground: null, |
| 40 | + $file-names-foreground--focused: null, |
| 41 | + $file-names-foreground--filled: null, |
| 42 | + $file-names-foreground--disabled: null, |
| 43 | +
|
| 44 | + $file-selector-button-background: null, |
| 45 | + $file-selector-button-background--focused: null, |
| 46 | + $file-selector-button-background--filled: null, |
| 47 | + $file-selector-button-background--disabled: null, |
| 48 | + $file-selector-button-foreground: null, |
| 49 | + $file-selector-button-foreground--focused: null, |
| 50 | + $file-selector-button-foreground--filled: null, |
| 51 | + $file-selector-button-foreground--disabled: null, |
| 52 | +) { |
| 53 | + $name: 'igx-file-input'; |
| 54 | + |
| 55 | + // the variable are scoped to the selector so no other input except the file type will have them. |
| 56 | + $selector: '.igx-file-input'; |
| 57 | + |
| 58 | + $file-input-schema: (); |
| 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 | + @return extend( |
| 68 | + $theme, |
| 69 | + ( |
| 70 | + name: $name, |
| 71 | + selector: $selector, |
| 72 | + file-names-background: $file-names-background, |
| 73 | + file-names-background--focused: $file-names-background--focused, |
| 74 | + file-names-background--filled: $file-names-background--filled, |
| 75 | + file-names-background--disabled: $file-names-background--disabled, |
| 76 | + file-names-foreground: $file-names-foreground, |
| 77 | + file-names-foreground--focused: $file-names-foreground--focused, |
| 78 | + file-names-foreground--filled: $file-names-foreground--filled, |
| 79 | + file-names-foreground--disabled: $file-names-foreground--disabled, |
| 80 | + |
| 81 | + file-selector-button-background: $file-selector-button-background, |
| 82 | + file-selector-button-background--focused: $file-selector-button-background--focused, |
| 83 | + file-selector-button-background--filled: $file-selector-button-background--filled, |
| 84 | + file-selector-button-background--disabled: $file-selector-button-background--disabled, |
| 85 | + file-selector-button-foreground: $file-selector-button-foreground, |
| 86 | + file-selector-button-foreground--focused: $file-selector-button-foreground--focused, |
| 87 | + file-selector-button-foreground--filled: $file-selector-button-foreground--filled, |
| 88 | + file-selector-button-foreground--disabled: $file-selector-button-foreground--disabled, |
| 89 | + ), |
| 90 | + ); |
| 91 | +} |
| 92 | + |
| 93 | +/// @deprecated Use the `css-vars` mixin instead. |
| 94 | +/// @see {mixin} css-vars |
| 95 | +/// @param {Map} $theme - The theme used to style the component. |
| 96 | +@mixin file-input($theme) { |
| 97 | + @include css-vars($theme); |
| 98 | + $variant: map.get($theme, '_meta', 'theme'); |
| 99 | + |
| 100 | + %file-names { |
| 101 | + color: var-get($theme, 'file-names-foreground'); |
| 102 | + background-color: var-get($theme, 'file-names-background'); |
| 103 | + } |
| 104 | + |
| 105 | + %file-names--filled { |
| 106 | + color: var-get($theme, 'file-names-foreground--filled'); |
| 107 | + background-color: var-get($theme, 'file-names-background--filled'); |
| 108 | + } |
| 109 | + |
| 110 | + %file-names--focused { |
| 111 | + color: var-get($theme, 'file-names-foreground--focused'); |
| 112 | + background-color: var-get($theme, 'file-names-background--focused'); |
| 113 | + } |
| 114 | + |
| 115 | + %file-names--disabled { |
| 116 | + color: var-get($theme, 'file-names-foreground--disabled'); |
| 117 | + background-color: var-get($theme, 'file-names-background--disabled'); |
| 118 | + } |
| 119 | + |
| 120 | + %upload-button-wrapper { |
| 121 | + background: #{var-get($theme, 'file-selector-button-background')} |
| 122 | + } |
| 123 | + |
| 124 | + %upload-button { |
| 125 | + border-inline: 0; |
| 126 | + |
| 127 | + // That button can't have :focus, :active, :hover states, that's why we dont need to override them here. |
| 128 | + --foreground: #{var-get($theme, 'file-selector-button-foreground')}; |
| 129 | + --background: transparent; |
| 130 | + --resting-elevation: none; |
| 131 | + --shadow-color: none; |
| 132 | + --border-radius: 0; |
| 133 | + } |
| 134 | + |
| 135 | + |
| 136 | + %upload-button-wrapper--filled { |
| 137 | + color: #{var-get($theme, 'file-selector-button-foreground--filled')}; |
| 138 | + background: #{var-get($theme, 'file-selector-button-background--filled')}; |
| 139 | + } |
| 140 | + |
| 141 | + %upload-button--filled { |
| 142 | + --foreground: #{var-get($theme, 'file-selector-button-foreground--filled')}; |
| 143 | + --background: transparent; |
| 144 | + } |
| 145 | + |
| 146 | + %upload-button-wrapper--focused { |
| 147 | + color: #{var-get($theme, 'file-selector-button-foreground--focused')}; |
| 148 | + background: #{var-get($theme, 'file-selector-button-background--focused')}; |
| 149 | + } |
| 150 | + |
| 151 | + %upload-button--focused { |
| 152 | + --foreground: #{var-get($theme, 'file-selector-button-foreground--focused')}; |
| 153 | + --background: transparent; |
| 154 | + } |
| 155 | + |
| 156 | + %upload-button-wrapper--disabled { |
| 157 | + color: #{var-get($theme, 'file-selector-button-foreground--disabled')}; |
| 158 | + background: #{var-get($theme, 'file-selector-button-background--disabled')}; |
| 159 | + } |
| 160 | + |
| 161 | + %upload-button--disabled { |
| 162 | + --disabled-foreground: #{var-get($theme, 'file-selector-button-foreground--disabled')}; |
| 163 | + --disabled-background: transparent; |
| 164 | + } |
| 165 | + |
| 166 | + %clear-icon { |
| 167 | + &:focus { |
| 168 | + @if $variant == 'indigo' or $variant == 'fluent' { |
| 169 | + background-color: color($color: 'primary', $variant: 500); |
| 170 | + color: contrast-color($color: 'primary', $variant: 600); |
| 171 | + } |
| 172 | + |
| 173 | + @if $variant == 'material' { |
| 174 | + background-color: transparent; |
| 175 | + color: color($color: 'secondary', $variant: 500); |
| 176 | + } |
| 177 | + |
| 178 | + @if $variant == 'bootstrap' { |
| 179 | + color: contrast-color($color: 'primary', $variant: 600); |
| 180 | + background-color: color($color: 'primary', $variant: 500); |
| 181 | + } |
| 182 | + } |
| 183 | + } |
| 184 | +} |
| 185 | + |
| 186 | +/// Adds typography styles for the .igx-file-input. |
| 187 | +/// Uses the 'subtitle-1', 'caption' |
| 188 | +/// category from the typographic scale. |
| 189 | +/// @group typography |
| 190 | +/// @param {Map} $categories [(file-text: 'subtitle-1')] - The categories from the typographic scale used for type styles. |
| 191 | +@mixin file-input-typography( |
| 192 | + $categories: ( |
| 193 | + file-text: 'subtitle-1' |
| 194 | + ) |
| 195 | +) { |
| 196 | + $file-text: map.get($categories, 'file-text'); |
| 197 | + |
| 198 | + %file-names { |
| 199 | + @include type-style($file-text) { |
| 200 | + margin: 0; |
| 201 | + } |
| 202 | + } |
| 203 | +} |
0 commit comments