generated from helsingborg-stad/Wordpress-Plugin-Boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move filter select functionality to select with multiple choices (#276)
* Fix undefined helper text parameter. * Developlement * Cap icon size to md. Add class to icons. * Add device detection support * Add required attribute. * feat: add attribute maxSelections * feat: add clear button to select * feat: accesibility tabbing for select component * fix: Select component aria states * fix: adapt select component for safari/ios --------- Co-authored-by: Sebastian Thulin <sebastian.thulin@helsingborg.se> Co-authored-by: Thor Brink <thor.brink@helsingborg.se> Co-authored-by: NiclasNorin <103985736+NiclasNorin@users.noreply.github.com>
- Loading branch information
1 parent
52ad2f4
commit 2bd1c33
Showing
9 changed files
with
204 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div class="c-field__inner"> | ||
<div tabindex="0" data-select-preserve-native-behavior></div> | ||
<div class="{{ $baseClass }}__action-overlay" tabindex="0" data-js-select-action-overlay data-js-toggle-trigger="{{$id}}-open-dropdown" data-js-placeholder="{{ $placeholder && $isMultiSelect ? $placeholder : '' }}"> | ||
{{ $placeholder && $isMultiSelect ? $placeholder : '' }} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@button([ | ||
'style' => 'basic', | ||
'icon' => 'close', | ||
'size' => 'md', | ||
'color' => 'secondary', | ||
'classList' => [$baseClass . '__clear-button'], | ||
'attributeList' => ['data-js-select-clear' => '1'] | ||
]) | ||
@endbutton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!-- Visual dropdown list --> | ||
<div class="{{$baseClass}}__dropdown" data-js-dropdown-element="true" aria-hidden="true"> | ||
<ul class="{{$baseClass}}__options u-unlist u-padding--0 u-margin--0" role="listbox"> | ||
@foreach ($options as $value => $name) | ||
<li class="{{$baseClass}}__option {{ $isSelected($value, true) ? 'is-selected' : '' }}" data-js-dropdown-option="{{$value}}" role="option" aria-selected="{{ $isSelected($value, true) ? 'true' : 'false' }}" tabindex="0"> | ||
@icon([ | ||
'icon' => $itemStateIcons->inactive, | ||
'size' => $iconSize, | ||
'classList' => [ | ||
$baseClass . '__option-icon', | ||
$baseClass . '__unchecked-icon' | ||
], | ||
'attributeList' => [ | ||
'aria-hidden' => $isSelected($value, true) ? 'true' : 'false' | ||
] | ||
]) | ||
@endicon | ||
@icon([ | ||
'icon' => $itemStateIcons->active, | ||
'size' => $iconSize, | ||
'classList' => [ | ||
$baseClass . '__option-icon', | ||
$baseClass . '__checked-icon' | ||
], | ||
'attributeList' => [ | ||
'aria-hidden' => $isSelected($value, true) ? 'false' : 'true' | ||
] | ||
]) | ||
@endicon | ||
<span class="{{$baseClass}}__option-label">{{ $name }}</span> | ||
</li> | ||
@endforeach | ||
</ul> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="c-select__select-invalid-message" id="error_input_{{ $id }}_message"> | ||
@icon([ | ||
'icon' => 'error', | ||
'size' => 'sm' | ||
]) | ||
@endicon | ||
<span class="errorText"></span> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<div class="{{$baseClass}}__expand-button" role="button" > | ||
@icon([ | ||
'icon' => 'expand_less', | ||
'size' => 'md', | ||
'classList' => [$baseClass . '__expand-less-icon'], | ||
'attributeList' => ['aria-hidden' => 'true'] | ||
]) | ||
@endicon | ||
@icon([ | ||
'icon' => 'expand_more', | ||
'size' => 'md', | ||
'classList' => [$baseClass . '__expand-more-icon'], | ||
'attributeList' => ['aria-hidden' => 'false'] | ||
]) | ||
@endicon | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div class="{{ $baseClass }}_focus-styler u-level-top"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,62 @@ | ||
<div class="{{ $class }} c-field"> | ||
@if ($label) | ||
<label class="c-field__label {{$hideLabel ? 'u-sr__only' : ''}}" for="select_{{ $id }}">{{ $label }} | ||
<div class="c-field {{ $class }}" {!! $attribute !!}> | ||
@if ($label && $hideLabel) | ||
<label class="u-sr__only" for="select_{{ $id }}"> | ||
{{ $label }} | ||
</label> | ||
@endif | ||
|
||
@if ($label && !$hideLabel) | ||
<label class="c-field__label" for="select_{{ $id }}"> | ||
{{ $label }} | ||
@if ($required) | ||
<span class="u-color__text--danger">*</span> | ||
{{-- | ||
Field has aria attribute required, this will be read as required. | ||
Aria hidden in place here, to avoid duplicate notations in screenreader. | ||
--}} | ||
<span class="u-color__text--danger" aria-hidden="true">*</span> | ||
@endif | ||
</label> | ||
@endif | ||
|
||
@if (!empty($description)) | ||
@typography([ | ||
'element' => 'div', | ||
'classList' => ['text-sm', 'text-dark-gray'] | ||
'classList' => [ | ||
$baseClass . '__description', | ||
'text-sm', | ||
'text-dark-gray' | ||
] | ||
]) | ||
{{ $description }} | ||
@endtypography | ||
@endif | ||
|
||
<div class="u-position--relative"> | ||
<select {!! $attribute !!}> | ||
@if ($label && empty($hidePlaceholder)) | ||
<option class="c-select__option" value="" {{ $preselected === '' ? 'selected' : '' }}> | ||
{!! $label !!}</option> | ||
<div class="{{ $baseClass }}__field-container"> | ||
<select {!! $selectAttributes !!} class="{{ $baseClass }}__select-element" tabindex="-1"> | ||
|
||
@if ($preselected !== '' && !$isMultiSelect) | ||
<option class="c-select__select-option" value="">{{$placeholder ? $placeholder : ""}}</option> | ||
@endif | ||
|
||
@foreach ($options as $key => $name) | ||
<option class="c-select__option" value="{!! $key !!}" | ||
{{ $preselected === $key || isset($intersection[$key]) ? 'selected' : '' }}> | ||
{!! $name !!}</option> | ||
<option class="c-select__select-option" value="{!! $key !!}" {{ $isSelected($key, false) }}> | ||
{!! $name !!} | ||
</option> | ||
@endforeach | ||
|
||
{!! $slot !!} | ||
@if(!empty($slot)) | ||
{!! $slot !!} | ||
@endif | ||
</select> | ||
<div class="{{ $baseClass }}_focus-styler u-level-top"></div> | ||
@icon([ | ||
'classList' => ['c-select__icon'], | ||
'icon' => 'expand_more', | ||
'size' => 'md' | ||
]) | ||
@endicon | ||
@include('Select.partials.focus') | ||
@include('Select.partials.expand') | ||
@includeWhen($clearButtonEnabled, 'Select.partials.clear') | ||
@include('Select.partials.action') | ||
</div> | ||
@include('Select.partials.dropdown') | ||
@include('Select.partials.error') | ||
|
||
<div class="c-select__select-invalid-message" id="error_input_{{ $id }}_message"> | ||
@icon([ | ||
'icon' => 'error', | ||
'size' => 'sm' | ||
]) | ||
@endicon | ||
<span class="errorText"></span> | ||
</div> | ||
@if ($helperText) | ||
@if (!empty($helperText)) | ||
<small class="c-field__helper">{{ $helperText }}</small> | ||
@endif | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters