Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(file-upload): Fix focus styles for the browse button - FRONT-3689 #2591

Merged
merged 7 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ exports[`File Upload Default renders correctly 1`] = `
Encrypted documents and those containing macros are not accepted.
</div>
</div>
<input
class="ecl-file-upload"
data-ecl-auto-init="FileUpload"
data-ecl-file-upload-input=""
id="example-input-id-1"
name="file-upload-name"
required=""
type="file"
/>
<label
class="ecl-file-upload__button-container"
for="example-input-id-1"
Expand All @@ -50,15 +59,6 @@ exports[`File Upload Default renders correctly 1`] = `
Choose file
</span>
</label>
<input
class="ecl-file-upload"
data-ecl-auto-init="FileUpload"
data-ecl-file-upload-input=""
id="example-input-id-1"
name="file-upload-name"
required=""
type="file"
/>
<ul
class="ecl-file-upload__list"
data-ecl-file-upload-list=""
Expand Down Expand Up @@ -104,6 +104,16 @@ exports[`File Upload Default renders correctly when disabled 1`] = `
Encrypted documents and those containing macros are not accepted.
</div>
</div>
<input
class="ecl-file-upload"
data-ecl-auto-init="FileUpload"
data-ecl-file-upload-input=""
disabled=""
id="example-input-id-1"
name="file-upload-name"
required=""
type="file"
/>
<label
class="ecl-file-upload__button-container"
for="example-input-id-1"
Expand All @@ -118,16 +128,6 @@ exports[`File Upload Default renders correctly when disabled 1`] = `
Choose file
</span>
</label>
<input
class="ecl-file-upload"
data-ecl-auto-init="FileUpload"
data-ecl-file-upload-input=""
disabled=""
id="example-input-id-1"
name="file-upload-name"
required=""
type="file"
/>
<ul
class="ecl-file-upload__list"
data-ecl-file-upload-list=""
Expand Down Expand Up @@ -187,6 +187,15 @@ exports[`File Upload Default renders correctly when invalid 1`] = `
</svg>
Invalid text
</div>
<input
class="ecl-file-upload ecl-file-upload--invalid"
data-ecl-auto-init="FileUpload"
data-ecl-file-upload-input=""
id="example-input-id-1"
name="file-upload-name"
required=""
type="file"
/>
<label
class="ecl-file-upload__button-container"
for="example-input-id-1"
Expand All @@ -200,15 +209,6 @@ exports[`File Upload Default renders correctly when invalid 1`] = `
Choose file
</span>
</label>
<input
class="ecl-file-upload ecl-file-upload--invalid"
data-ecl-auto-init="FileUpload"
data-ecl-file-upload-input=""
id="example-input-id-1"
name="file-upload-name"
required=""
type="file"
/>
<ul
class="ecl-file-upload__list"
data-ecl-file-upload-list=""
Expand Down Expand Up @@ -254,6 +254,15 @@ exports[`File Upload Default renders correctly when required 1`] = `
Encrypted documents and those containing macros are not accepted.
</div>
</div>
<input
class="ecl-file-upload"
data-ecl-auto-init="FileUpload"
data-ecl-file-upload-input=""
id="example-input-id-1"
name="file-upload-name"
required=""
type="file"
/>
<label
class="ecl-file-upload__button-container"
for="example-input-id-1"
Expand All @@ -267,15 +276,6 @@ exports[`File Upload Default renders correctly when required 1`] = `
Choose file
</span>
</label>
<input
class="ecl-file-upload"
data-ecl-auto-init="FileUpload"
data-ecl-file-upload-input=""
id="example-input-id-1"
name="file-upload-name"
required=""
type="file"
/>
<ul
class="ecl-file-upload__list"
data-ecl-file-upload-list=""
Expand Down Expand Up @@ -321,6 +321,17 @@ exports[`File Upload Default renders correctly with extra attributes 1`] = `
Encrypted documents and those containing macros are not accepted.
</div>
</div>
<input
class="ecl-file-upload"
data-ecl-auto-init="FileUpload"
data-ecl-file-upload-input=""
data-test="data-test-value"
data-test-1="data-test-value-1"
id="example-input-id-1"
name="file-upload-name"
required=""
type="file"
/>
<label
class="ecl-file-upload__button-container"
for="example-input-id-1"
Expand All @@ -334,17 +345,6 @@ exports[`File Upload Default renders correctly with extra attributes 1`] = `
Choose file
</span>
</label>
<input
class="ecl-file-upload"
data-ecl-auto-init="FileUpload"
data-ecl-file-upload-input=""
data-test="data-test-value"
data-test-1="data-test-value-1"
id="example-input-id-1"
name="file-upload-name"
required=""
type="file"
/>
<ul
class="ecl-file-upload__list"
data-ecl-file-upload-list=""
Expand Down Expand Up @@ -390,6 +390,15 @@ exports[`File Upload Default renders correctly with extra class names 1`] = `
Encrypted documents and those containing macros are not accepted.
</div>
</div>
<input
class="ecl-file-upload"
data-ecl-auto-init="FileUpload"
data-ecl-file-upload-input=""
id="example-input-id-1"
name="file-upload-name"
required=""
type="file"
/>
<label
class="ecl-file-upload__button-container"
for="example-input-id-1"
Expand All @@ -403,15 +412,6 @@ exports[`File Upload Default renders correctly with extra class names 1`] = `
Choose file
</span>
</label>
<input
class="ecl-file-upload"
data-ecl-auto-init="FileUpload"
data-ecl-file-upload-input=""
id="example-input-id-1"
name="file-upload-name"
required=""
type="file"
/>
<ul
class="ecl-file-upload__list"
data-ecl-file-upload-list=""
Expand Down Expand Up @@ -457,6 +457,16 @@ exports[`File Upload Multiple renders correctly 1`] = `
Encrypted documents and those containing macros are not accepted.
</div>
</div>
<input
class="ecl-file-upload"
data-ecl-auto-init="FileUpload"
data-ecl-file-upload-input=""
id="example-file-upload-multiple"
multiple=""
name="file-upload-name"
required=""
type="file"
/>
<label
class="ecl-file-upload__button-container"
for="example-file-upload-multiple"
Expand All @@ -470,16 +480,6 @@ exports[`File Upload Multiple renders correctly 1`] = `
Choose files
</span>
</label>
<input
class="ecl-file-upload"
data-ecl-auto-init="FileUpload"
data-ecl-file-upload-input=""
id="example-file-upload-multiple"
multiple=""
name="file-upload-name"
required=""
type="file"
/>
<ul
class="ecl-file-upload__list"
data-ecl-file-upload-list=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@
</div>
{% endif %}

<input
type="file"
class="{{ _component_class }}"
{{- _main_attributes -}}
{% if _extra_attributes is not empty %}
{{- _extra_attributes -}}
{% endif %}
/>

<label
class="ecl-file-upload__button-container"
{% if _id is not empty %}
Expand All @@ -169,15 +178,6 @@
</span>
</label>

<input
type="file"
class="{{ _component_class }}"
{{- _main_attributes -}}
{% if _extra_attributes is not empty %}
{{- _extra_attributes -}}
{% endif %}
/>

<ul
class="ecl-file-upload__list"
data-ecl-file-upload-list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,41 @@
@use 'sass:map';
@use '@ecl/theme-dev/theme';

$_border-radius: null !default;
$_border-width: 2px !default;
$_font-weight: null !default;
$_outline-color: null !default;
$_outline-width: null !default;
$_padding-horizontal: map.get(theme.$spacing, 'm') !default;
$_padding-vertical: map.get(theme.$spacing, 's') !default;
$_shadow-hover: null !default;

@mixin browse-button() {
appearance: none;
background: none;
background-color: map.get(theme.$color, 'blue-100');
border-radius: 0;
border-radius: $_border-radius;
border-width: 0;
box-shadow: 0;
box-sizing: border-box;
color: map.get(theme.$color, 'white-100');
display: inline-block;
font: map.get(theme.$font, 'm');
font-weight: map.get(theme.$font-weight, 'bold');
font-weight: $_font-weight;
margin: 0;
padding: map.get(theme.$spacing, 's') map.get(theme.$spacing, 'm');
padding: $_padding-vertical $_padding-horizontal;
text-decoration: none;

// stylelint-disable plugin/selector-bem-pattern
&:hover,
&:active {
background-color: map.get(theme.$color, 'blue-130');
box-shadow: $_shadow-hover;
text-decoration: none;
}

&:focus {
outline: 3px solid map.get(theme.$color, 'yellow');
outline-offset: -(3px);
border: $_outline-width solid $_outline-color;
outline: none;
padding: calc(#{$_padding-vertical} - #{$_outline-width})
calc(#{$_padding-horizontal} - #{$_outline-width});
text-decoration: none;
}
// stylelint-enable plugin/selector-bem-pattern
}

@mixin browse-button-disabled() {
Expand All @@ -45,23 +51,36 @@
}

.ecl-file-upload {
display: none;
clip: rect(1px, 1px, 1px, 1px);
height: 1px;
overflow: hidden;
position: absolute !important;
width: 1px;
margin: 0;

.no-js & {
clip: initial;
color: map.get(theme.$color, 'grey');
display: block;
font: map.get(theme.$font, 'm');
height: auto;
overflow: initial;
position: initial;
width: auto;
margin: 0;
}

// stylelint-disable max-nesting-depth
&:active,
&:focus {
outline: 3px solid map.get(theme.$color, 'yellow');
outline-offset: -3px;
// stylelint-disable max-nesting-depth
&:active,
&:focus {
+ .ecl-file-upload__button-container .ecl-file-upload__button {
border: $_outline-width solid $_outline-color;
outline: none;
padding: calc(#{$_padding-vertical} - #{$_outline-width})
calc(#{$_padding-horizontal} - #{$_outline-width});
text-decoration: none;
}
// stylelint-enable max-nesting-depth
}
// stylelint-enable max-nesting-depth
}

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@use 'sass:map';
@use '@ecl/theme-dev/theme';
@use 'file-upload' with (
$_border-radius: 0,
$_font-weight: map.get(theme.$font-weight, 'bold'),
$_outline-color: map.get(theme.$color, 'yellow-100'),
$_outline-width: 3px,
$_shadow-hover: none
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@use 'sass:map';
@use '@ecl/theme-dev/theme';
@use 'file-upload' with (
$_border-radius: 4px,
$_font-weight: map.get(theme.$font-weight, 'regular'),
$_outline-color: map.get(theme.$color, 'accent-blue-100'),
$_outline-width: 2px,
$_shadow-hover: 0 0 4px rgba(9, 49, 142, 0.5)
);
2 changes: 1 addition & 1 deletion src/presets/ec/src/ec.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@use '@ecl/vanilla-component-form/form-ec';
@use '@ecl/vanilla-component-checkbox/checkbox-ec';
@use '@ecl/vanilla-component-datepicker/datepicker-ec';
@use '@ecl/vanilla-component-file-upload/file-upload';
@use '@ecl/vanilla-component-file-upload/file-upload-ec';
@use '@ecl/vanilla-component-radio/radio-ec';
@use '@ecl/vanilla-component-select/select-ec';
@use '@ecl/vanilla-component-text-area/text-area-ec';
Expand Down
2 changes: 1 addition & 1 deletion src/presets/eu/src/eu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@use '@ecl/vanilla-component-form/form-eu';
@use '@ecl/vanilla-component-checkbox/checkbox-eu';
@use '@ecl/vanilla-component-datepicker/datepicker-eu';
@use '@ecl/vanilla-component-file-upload/file-upload';
@use '@ecl/vanilla-component-file-upload/file-upload-eu';
@use '@ecl/vanilla-component-radio/radio-eu';
@use '@ecl/vanilla-component-select/select-eu';
@use '@ecl/vanilla-component-text-area/text-area-eu';
Expand Down