Skip to content

Commit 1619307

Browse files
authored
Merge pull request #198 from CrowdStrike/fix-file-input-styles
Update file-input styling with latest designs
2 parents 1588e2b + 42da468 commit 1619307

File tree

8 files changed

+59
-42
lines changed

8 files changed

+59
-42
lines changed

.changeset/eleven-crabs-type.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@crowdstrike/ember-toucan-core': patch
3+
---
4+
5+
Updated `<Form::Fields::FileInput` styling to match designs. This included updates to the disabled state as well as the list items.

docs/components/file-input-field/demo/base-demo.md

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
```hbs template
2-
<Form::Fields::FileInput
3-
@deleteLabel='Delete file'
4-
@label='Label'
5-
@files={{this.files}}
6-
@hint='Hint text'
7-
@trigger='Browse Files'
8-
@onChange={{this.handleChange}}
9-
/>
2+
<div class='max-w-md'>
3+
<Form::Fields::FileInput
4+
@deleteLabel='Delete file'
5+
@label='Label'
6+
@files={{this.files}}
7+
@hint='Hint text'
8+
@trigger='Browse Files'
9+
@onChange={{this.handleChange}}
10+
@multiple={{true}}
11+
/>
12+
</div>
1013
```
1114

1215
```js component

docs/components/file-input-field/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ Target the trash icon button via `data-delete-file`.
278278
/>
279279
</div>
280280

281-
### FileInputField with isReadOnly
281+
## FileInputField with isReadOnly
282282

283283
<div class='mb-4 w-64'>
284284
<Form::Fields::FileInput

packages/ember-toucan-core/src/components/form/fields/file-input.hbs

+27-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div
2-
class="inline-flex flex-col {{if @isDisabled 'text-disabled'}}"
2+
class="inline-flex w-full flex-col {{if @isDisabled 'text-disabled'}}"
33
data-root-field={{if @rootTestSelector @rootTestSelector}}
44
>
55
<Form::Field as |field|>
@@ -20,10 +20,6 @@
2020
{{else}}
2121
{{@label}}
2222
{{/if}}
23-
24-
{{#if this.isReadOnlyOrDisabled}}
25-
<this.LockIcon />
26-
{{/if}}
2723
</span>
2824
{{/if}}
2925

@@ -61,22 +57,34 @@
6157
class="{{if @isReadOnly 'shadow-read-only-outline bg-surface-xl'}}"
6258
@variant="secondary"
6359
@onClick={{(fn this.handleChange field)}}
60+
@isDisabled={{@isDisabled}}
6461
>
6562
<span data-trigger>{{@trigger}}</span>
66-
<svg
67-
aria-hidden="true"
68-
class="ml-2"
69-
width="16"
70-
height="16"
71-
viewBox="0 0 16 16"
72-
fill="currentColor"
73-
><g><path
74-
fill-rule="evenodd"
75-
clip-rule="evenodd"
76-
d="M2 10v2.5A1.5 1.5 0 0 0 3.5 14h9a1.5 1.5 0 0 0 1.5-1.5V10h1v2.5a2.5 2.5 0 0 1-2.5 2.5h-9A2.5 2.5 0 0 1 1 12.5V10h1Z"
77-
/><path
78-
d="M8 10.707a.5.5 0 0 1-.5-.5V2.414L4.854 5.061a.5.5 0 1 1-.708-.707L8 .5l3.854 3.854a.5.5 0 0 1-.708.707L8.5 2.414v7.793a.5.5 0 0 1-.5.5Z"
79-
/></g></svg>
63+
64+
{{#if this.isReadOnlyOrDisabled}}
65+
<this.LockIcon class="{{if @isReadOnly 'ml-2'}}" />
66+
{{else}}
67+
<svg
68+
aria-hidden="true"
69+
class="ml-2"
70+
width="16"
71+
height="16"
72+
viewBox="0 0 16 16"
73+
fill="currentColor"
74+
data-upload-icon
75+
>
76+
<g>
77+
<path
78+
fill-rule="evenodd"
79+
clip-rule="evenodd"
80+
d="M2 10v2.5A1.5 1.5 0 0 0 3.5 14h9a1.5 1.5 0 0 0 1.5-1.5V10h1v2.5a2.5 2.5 0 0 1-2.5 2.5h-9A2.5 2.5 0 0 1 1 12.5V10h1Z"
81+
/>
82+
<path
83+
d="M8 10.707a.5.5 0 0 1-.5-.5V2.414L4.854 5.061a.5.5 0 1 1-.708-.707L8 .5l3.854 3.854a.5.5 0 0 1-.708.707L8.5 2.414v7.793a.5.5 0 0 1-.5.5Z"
84+
/>
85+
</g>
86+
</svg>
87+
{{/if}}
8088
</Button>
8189
</field.Control>
8290
</field.Label>
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
<Button
2-
@variant="bare"
3-
type="button"
1+
<button
42
aria-label={{@deleteLabel}}
53
{{! TODO: remove reset-styles https://github.com/CrowdStrike/ember-oss-docs/issues/17 }}
6-
class="reset-styles flex-none bg-transparent"
4+
class="reset-styles focusable focus:interactive-normal hover:interactive-normal rounded-sm transition"
5+
type="button"
76
{{on "click" (fn @onDelete @file)}}
87
data-delete-file
98
...attributes
109
>
1110
<svg
1211
aria-hidden="true"
13-
class="text-text-and-icons h-4 w-4"
12+
class="text-text-and-icons"
1413
width="16"
1514
height="16"
1615
viewBox="0 0 16 16"
@@ -20,4 +19,4 @@
2019
/><path
2120
d="M6 11.5v-6h1v6H6Zm3 0v-6h1v6H9ZM8 1a1.5 1.5 0 0 0-1.5 1.5h-1a2.5 2.5 0 0 1 5 0h-1A1.5 1.5 0 0 0 8 1Z"
2221
/></g></svg>
23-
</Button>
22+
</button>

packages/ember-toucan-core/src/components/form/file-input/list-item.hbs

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<li
2-
class="bg-overlay-1 focus:outline-none focus:shadow-focus-outline m-0 block flex rounded-sm p-1 transition-shadow
2+
class="bg-overlay-1 focus:outline-none focus:shadow-focus-outline m-0 flex items-center justify-between rounded-sm px-2 py-1 transition-shadow
33
{{if @isDisabled 'text-disabled' 'text-titles-and-attributes'}}
44
{{if
55
@hasError
@@ -8,18 +8,17 @@
88
}}"
99
...attributes
1010
>
11-
<div class="flex-1 px-4 py-1">
12-
<p
13-
class="text-titles-and-attributes type-md-tight m-0 truncate p-0"
14-
data-file-name
15-
>{{@file.name}}</p>
11+
{{! The `pl-2` added here is to offset the spacing added by the delete button below so that the horizontal axis spacing appears identical }}
12+
<div class="flex-1 py-1 pl-2">
13+
<p class="type-md-tight m-0 truncate p-0" data-file-name>{{@file.name}}</p>
1614
<span
1715
class="text-body-and-labels type-xs-tight mt-1 block"
1816
data-file-size
1917
>{{(this.formatSize @file.size)}}</span>
2018
</div>
19+
2120
<Form::FileInput::DeleteButton
22-
class="mr-2"
21+
class="p-2"
2322
@deleteLabel={{@deleteLabel}}
2423
@onDelete={{@onDelete}}
2524
@file={{@file}}

packages/ember-toucan-core/src/components/form/file-input/list.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<ul class="m-0 list-none space-y-1 p-0" data-files ...attributes>
1+
<ul class="m-0 list-none space-y-1.5 p-0" data-files ...attributes>
22
{{#each @files as |file|}}
33
{{#if (has-block)}}
44
{{yield

test-app/tests/integration/components/file-input-field-test.gts

+3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ module('Integration | Component | Fields | FileInput', function (hooks) {
7979
'Expected hint block not to be displayed as an error was not provided'
8080
);
8181

82+
assert.dom('[data-upload-icon]').exists();
8283
assert.dom('[data-lock-icon]').doesNotExist();
8384
});
8485

@@ -194,6 +195,7 @@ module('Integration | Component | Fields | FileInput', function (hooks) {
194195
assert.dom('[data-file-input-field]').hasClass('text-disabled');
195196

196197
assert.dom('[data-lock-icon]').exists();
198+
assert.dom('[data-upload-icon]').doesNotExist();
197199

198200
assert.dom('label').hasClass('text-disabled');
199201
});
@@ -213,6 +215,7 @@ module('Integration | Component | Fields | FileInput', function (hooks) {
213215
assert.dom('[data-file-input-field]').hasAttribute('readonly');
214216

215217
assert.dom('[data-lock-icon]').exists();
218+
assert.dom('[data-upload-icon]').doesNotExist();
216219
});
217220

218221
test('it spreads attributes to the underlying file-input-field', async function (assert) {

0 commit comments

Comments
 (0)