UNPKG

5.1 kBSCSSView Raw
1//
2// Copyright IBM Corp. 2016, 2018
3//
4// This source code is licensed under the Apache-2.0 license found in the
5// LICENSE file in the root directory of this source tree.
6//
7
8@import '../../globals/scss/vars';
9@import '../../globals/scss/css--reset';
10@import '../../globals/scss/helper-mixins';
11@import '../../globals/scss/vendor/@carbon/elements/scss/import-once/import-once';
12@import '../../globals/scss/css--typography';
13@import '../button/button';
14@import '../form/form';
15@import '../loading/loading';
16@import '../../globals/scss/vendor/@carbon/elements/scss/type/styles';
17
18@mixin file-uploader {
19 .#{$prefix}--file {
20 width: 100%;
21 }
22
23 .#{$prefix}--file-input {
24 @include hidden;
25 }
26
27 .#{$prefix}--file-btn {
28 display: inline-flex;
29 margin: 0;
30 }
31
32 .#{$prefix}--label-description {
33 @include reset;
34 @include typescale('zeta');
35 @include line-height('body');
36 color: $text-02;
37 margin-bottom: $spacing-lg;
38 }
39
40 .#{$prefix}--file-container {
41 display: block;
42 width: 100%;
43 margin-top: $spacing-lg;
44 }
45
46 .#{$prefix}--file__selected-file {
47 @include text-overflow(300px);
48 display: flex;
49 align-items: center;
50 justify-content: space-between;
51 min-height: rem(30px);
52 background-color: $field-02;
53 border: 1px solid $ui-03;
54 padding: 0 $spacing-md;
55 margin-bottom: $spacing-md;
56
57 &:last-child {
58 margin-bottom: 0;
59 }
60 }
61
62 .#{$prefix}--file-filename {
63 @include typescale('omega');
64 @include text-overflow(100%);
65 display: inline-flex;
66 align-items: center;
67 color: $text-01;
68 margin-right: $spacing-md;
69 height: 1.875rem;
70 /*rtl:ignore*/
71 direction: ltr;
72 justify-content: flex-start; /*rtl:{flex-end}*/
73 }
74
75 .#{$prefix}--file__state-container {
76 display: flex;
77 align-items: center;
78
79 .#{$prefix}--loading {
80 width: 1rem;
81 height: 1rem;
82 margin-right: $spacing-xs;
83 }
84
85 .#{$prefix}--loading__svg {
86 stroke: $ui-05;
87 }
88 }
89
90 .#{$prefix}--file__state-container .#{$prefix}--file-close,
91 .#{$prefix}--file__state-container .#{$prefix}--file-complete {
92 width: 1rem;
93 height: 1rem;
94 fill: $text-01;
95 cursor: pointer;
96
97 &:focus {
98 @include focus-outline('border');
99 }
100 }
101
102 .#{$prefix}--file__state-container .#{$prefix}--file-close {
103 fill: $ui-05;
104 }
105
106 .#{$prefix}--file__state-container .#{$prefix}--file-complete {
107 fill: $support-02;
108 }
109}
110
111@mixin file-uploader--x {
112 .#{$prefix}--file {
113 width: 100%;
114 }
115
116 .#{$prefix}--file--invalid {
117 margin-right: $carbon--spacing-03;
118 fill: $support-01;
119 }
120
121 // TODO: sync with type
122 .#{$prefix}--file--label {
123 @include reset;
124 @include type-style('heading-01');
125
126 color: $text-01;
127 margin-bottom: $carbon--spacing-03;
128 }
129
130 .#{$prefix}--file-input {
131 @include hidden;
132 }
133
134 .#{$prefix}--file-btn {
135 display: inline-flex;
136 margin: 0;
137 padding-right: rem(64px);
138 }
139
140 .#{$prefix}--label-description {
141 @include reset;
142 @include type-style('body-short-01');
143
144 color: $text-02;
145 margin-bottom: $carbon--spacing-05;
146 }
147
148 .#{$prefix}--file-container {
149 display: block;
150 width: 100%;
151 margin-top: $carbon--spacing-06;
152 }
153
154 .#{$prefix}--file__selected-file {
155 display: flex;
156 align-items: center;
157 justify-content: space-between;
158 min-height: rem(40px);
159 max-width: rem(300px);
160 margin-bottom: $carbon--spacing-03;
161 padding: 0 $carbon--spacing-03 0 $carbon--spacing-05;
162 background-color: $field-01;
163 overflow: hidden;
164
165 &:last-child {
166 margin-bottom: 0;
167 }
168
169 .#{$prefix}--inline-loading__animation,
170 .#{$prefix}--loading {
171 right: -0.25rem; // offset for loading svg container
172 width: 1.5rem;
173 height: 1.5rem;
174 }
175 }
176
177 .#{$prefix}--file__selected-file--invalid {
178 @include focus-outline('invalid');
179 margin-bottom: $carbon--spacing-02;
180 }
181
182 .#{$prefix}--file__selected-file--invalid + .#{$prefix}--form-requirement {
183 display: block;
184 max-height: rem(200px);
185 color: $support-01;
186 font-weight: 400;
187 margin: 0 0 $carbon--spacing-03 0;
188 overflow: visible;
189 }
190
191 .#{$prefix}--file-filename {
192 @include type-style('body-short-01');
193 @include text-overflow(300px);
194 display: inline-block;
195 align-items: center;
196 color: $text-01;
197 margin-right: $carbon--spacing-05;
198 /*rtl:ignore*/
199 direction: ltr;
200 justify-content: flex-start; /*rtl:{flex-end}*/
201 }
202
203 .#{$prefix}--file__state-container {
204 display: flex;
205 align-items: center;
206
207 .#{$prefix}--loading__svg {
208 stroke: $ui-05;
209 }
210 }
211
212 .#{$prefix}--file__state-container .#{$prefix}--file-complete {
213 fill: $support-02;
214 cursor: pointer;
215
216 &:focus {
217 @include focus-outline('border');
218 }
219 }
220
221 .#{$prefix}--file__state-container .#{$prefix}--file-close {
222 background: transparent;
223 border: none;
224 cursor: pointer;
225 padding: 0;
226 }
227}
228
229@include exports('file-uploader') {
230 @if feature-flag-enabled('components-x') {
231 @include file-uploader--x;
232 } @else {
233 @include file-uploader;
234 }
235}