chore: 🤖 add select field component
This commit is contained in:
12 files changed
+335
-2
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import Component from '@ember/component';
|
||||
import layout from '../../../templates/components/rose/form/select';
|
||||
|
||||
/**
|
||||
* A `<select>` element context component which yields option components.
|
||||
*
|
||||
* @example
|
||||
* <Rose::Form::Select
|
||||
* @id="select-id-1"
|
||||
* name="select-field-name"
|
||||
* @value="current-value"
|
||||
* @label="Label"
|
||||
* @helperText="Helper text"
|
||||
* @error={{true}}
|
||||
* @onChange={{fn this.selectChange}}
|
||||
* disabled={{true}}
|
||||
* as |select|
|
||||
* >
|
||||
* <select.option>Choose an option</select.option>
|
||||
* <select.option @value="current-value">Curret value</select.option>
|
||||
* </Rose::Form::Select>
|
||||
*/
|
||||
export default Component.extend({
|
||||
layout,
|
||||
|
||||
tagName: '',
|
||||
});
|
||||
@@ -1,2 +1,3 @@
|
||||
@import 'input';
|
||||
@import 'checkbox';
|
||||
@import 'select';
|
||||
@@ -0,0 +1,69 @@
|
||||
@use '../../variables/sizing';
|
||||
@use '../../utilities/type';
|
||||
|
||||
.rose-form-select {
|
||||
margin-bottom: sizing.rems(m);
|
||||
|
||||
.rose-form-select-label {
|
||||
@include type.type(s, semibold);
|
||||
display: block;
|
||||
margin-bottom: sizing.rems(xxs);
|
||||
}
|
||||
|
||||
.rose-form-select-helper-text {
|
||||
@include type.type(xs);
|
||||
display: block;
|
||||
color: var(--ui-gray);
|
||||
margin-bottom: sizing.rems(xxs);
|
||||
}
|
||||
|
||||
.rose-form-select-field {
|
||||
@include type.type(s);
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
vertical-align: middle;
|
||||
display: inline-block;
|
||||
padding: sizing.rems(xs) sizing.rems(xxl) sizing.rems(xs) sizing.rems(xs);
|
||||
border: sizing.rems(xxxxs) solid var(--ui-gray-subtler-2);
|
||||
border-radius: sizing.rems(xxxs);
|
||||
box-shadow: 0 $size-xxs $size-xxs
|
||||
rgba(var(--stark-components), var(--opacity-2));
|
||||
background: var(--ui-gray-subtler-5)
|
||||
url('data:image/svg+xml;charset=utf8,%3Csvg%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M12%205.83L15.17%209l1.41-1.41L12%203%207.41%207.59%208.83%209%2012%205.83zm0%2012.34L8.83%2015l-1.41%201.41L12%2021l4.59-4.59L15.17%2015%2012%2018.17z%22%20fill%3D%22%23525761%22%2F%3E%3C%2Fsvg%3E')
|
||||
no-repeat right sizing.rems(xs) center;
|
||||
background-size: sizing.rems(l);
|
||||
|
||||
&:not(:disabled) {
|
||||
&:hover {
|
||||
border-color: var(--ui-gray-subtler-1);
|
||||
background-color: transparent;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
&:focus {
|
||||
border-color: var(--info);
|
||||
background-color: var(--ui-gray-subtler-5);
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
cursor: not-allowed;
|
||||
color: var(--ui-gray-subtler-1);
|
||||
background-image: url('data:image/svg+xml;charset=utf8,%3Csvg%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M12%205.83L15.17%209l1.41-1.41L12%203%207.41%207.59%208.83%209%2012%205.83zm0%2012.34L8.83%2015l-1.41%201.41L12%2021l4.59-4.59L15.17%2015%2012%2018.17z%22%20fill%3D%22%238E96A3%22%2F%3E%3C%2Fsvg%3E');
|
||||
}
|
||||
}
|
||||
|
||||
&.error {
|
||||
color: var(--failure);
|
||||
|
||||
.rose-form-select-helper-text {
|
||||
color: currentColor;
|
||||
}
|
||||
|
||||
.rose-form-select-field {
|
||||
border-color: var(--failure);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<div class="rose-form-select{{if @error " error"}}">
|
||||
|
||||
<label class="rose-form-select-label" for={{@id}}>
|
||||
{{@label}}
|
||||
</label>
|
||||
|
||||
{{#if @helperText}}
|
||||
<span class="rose-form-select-helper-text">{{@helperText}}</span>
|
||||
{{/if}}
|
||||
|
||||
<XSelect
|
||||
...attributes
|
||||
class="rose-form-select-field"
|
||||
id={{@id}}
|
||||
@value={{@value}}
|
||||
@onChange={{@onChange}}
|
||||
as |xs|
|
||||
>
|
||||
{{yield xs}}
|
||||
</XSelect>
|
||||
|
||||
</div>
|
||||
Reference in new issue
Block a user