-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mox:typeahead): add light mode to mox/t-ahead component
- Loading branch information
Showing
5 changed files
with
286 additions
and
121 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
{{#if @label}} | ||
<Mox::Label for={{@id}} @isRequired={{@isRequired}}>{{@label}}</Mox::Label> | ||
{{/if}} | ||
<input | ||
id={{@id}} | ||
type="text" | ||
class="px-4 py-2 w-full text-gray-800 dark:text-white text-sm rounded bg-white dark:bg-gray-800 | ||
read-only:text-gray-800 dark:read-only:text-white disabled:text-gray-600 dark:disabled:text-gray-500 | ||
disabled:bg-gray-200 read-only:bg-gray-50 disabled:border-gray-200 read-only:border-gray-400 | ||
dark:disabled:bg-gray-700 dark:read-only:bg-gray-700 dark:disabled:border-gray-700 dark:read-only:border-gray-700 disabled:cursor-not-allowed | ||
read-only:focus:border-cyan-500 dark:read-only:focus:border-white dark:ready-only:focus:ring-white | ||
{{if this.isValid 'border-gray-400 dark:border-gray-500 focus:border-cyan-500 focus:ring-cyan-500' | ||
'border-red-500 dark:border-red-800 active:border-red-500 dark:active:border-red-900 focus:border-red-500 dark:focus:border-red-900 focus:ring-red-500 dark:focus:ring-red-900'}}" | ||
value={{@value}} | ||
placeholder={{@placeholder}} | ||
aria-invalid={{not this.isValid}} {{on "input" this.onInput}} | ||
data-test-mox-input | ||
...attributes | ||
/> | ||
<Mox::FormError @error={{@error}} id={{concat @id "-error-message"}} data-test-mox-input-error /> | ||
<div class="flex flex-col"> | ||
<input | ||
id={{@id}} | ||
type="text" | ||
class="px-4 py-2 w-full text-gray-800 dark:text-white text-sm rounded bg-white dark:bg-gray-800 | ||
read-only:text-gray-800 dark:read-only:text-white disabled:text-gray-600 dark:disabled:text-gray-500 | ||
disabled:bg-gray-200 read-only:bg-gray-50 disabled:border-gray-200 read-only:border-gray-400 | ||
dark:disabled:bg-gray-700 dark:read-only:bg-gray-700 dark:disabled:border-gray-700 dark:read-only:border-gray-700 disabled:cursor-not-allowed | ||
read-only:focus:border-cyan-500 dark:read-only:focus:border-white dark:ready-only:focus:ring-white | ||
{{if this.isValid 'border-gray-400 dark:border-gray-500 focus:border-cyan-500 focus:ring-cyan-500' | ||
'border-red-500 dark:border-red-800 active:border-red-500 dark:active:border-red-900 focus:border-red-500 dark:focus:border-red-900 focus:ring-red-500 dark:focus:ring-red-900'}}" | ||
value={{@value}} | ||
placeholder={{@placeholder}} | ||
aria-invalid={{not this.isValid}} {{on "input" this.onInput}} | ||
data-test-mox-input | ||
...attributes | ||
/> | ||
<Mox::FormError @error={{@error}} id={{concat @id "-error-message"}} data-test-mox-input-error /> | ||
</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
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,129 @@ | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
import { action } from '@ember/object'; | ||
|
||
const options = [ | ||
{ name: 'Apple', value: 'apple' }, | ||
{ name: 'Banana', value: 'banana' }, | ||
{ name: 'Carrot', value: 'carrot' }, | ||
]; | ||
|
||
export default { | ||
title: 'Mox Light/Mox::TypeaheadSelect', | ||
argTypes: { | ||
options: { control: 'text' }, | ||
buttonType: { control: 'text' }, | ||
}, | ||
parameters: { | ||
backgrounds: { | ||
default: 'Mute', | ||
values: [ | ||
{ | ||
name: 'White', | ||
value: '#ffffff', | ||
}, | ||
{ | ||
name: 'Mute', | ||
value: '#F3F4F6', | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
|
||
const Template = (args) => ({ | ||
template: hbs` | ||
<div class={{this.wrapperClass}}> | ||
<Mox::TypeaheadSelect | ||
@options={{this.connectorTypes}} | ||
@selectedOption={{this.selectedConnectorType}} | ||
@onChange={{this.setConnectorType}} | ||
@isDisabled={{this.isEditing}} | ||
@label={{this.label}} | ||
@id={{this.id}} | ||
@isValid={{this.isValid}} | ||
@error={{this.error}} | ||
/> | ||
</div> | ||
`, | ||
context: args, | ||
}); | ||
|
||
const LabelledTemplate = (args) => ({ | ||
template: hbs` | ||
<Mox::Label for={{this.id}}>Food</Mox::Label> | ||
<div class={{this.wrapperClass}}> | ||
<Mox::TypeaheadSelect | ||
@options={{this.connectorTypes}} | ||
@selectedOption={{this.selectedConnectorType}} | ||
@onChange={{this.setConnectorType}} | ||
@isDisabled={{this.isEditing}} | ||
@id={{this.id}} | ||
/> | ||
</div> | ||
`, | ||
context: args, | ||
}); | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
connectorTypes: options, | ||
selectedConnectorType: options[0], | ||
isEditing: false, | ||
setConnectorType: action(function (value) { | ||
this.set('selectedConnectorType', value); | ||
}), | ||
wrapperClass: null, | ||
label: 'Fruit', | ||
id: 'fruit-basket', | ||
}; | ||
|
||
export const Short = Template.bind({}); | ||
Short.args = { | ||
connectorTypes: options, | ||
selectedConnectorType: options[0], | ||
isEditing: false, | ||
setConnectorType: action(function (value) { | ||
this.set('selectedConnectorType', value); | ||
}), | ||
wrapperClass: 'w-20', | ||
label: 'Fruit', | ||
id: 'fruit-basket', | ||
}; | ||
|
||
export const ExternalLabel = LabelledTemplate.bind({}); | ||
ExternalLabel.args = { | ||
connectorTypes: options, | ||
selectedConnectorType: options[0], | ||
isEditing: false, | ||
setConnectorType: action(function (value) { | ||
this.set('selectedConnectorType', value); | ||
}), | ||
wrapperClass: null, | ||
id: 'fruit-basket', | ||
}; | ||
|
||
export const Disabled = Template.bind({}); | ||
Disabled.args = { | ||
connectorTypes: options, | ||
selectedConnectorType: options[0], | ||
isEditing: true, | ||
setConnectorType: action(function (value) { | ||
this.set('selectedConnectorType', value); | ||
}), | ||
label: 'Fruit', | ||
id: 'fruit-basket', | ||
}; | ||
|
||
export const Errors = Template.bind({}); | ||
Errors.args = { | ||
connectorTypes: options, | ||
selectedConnectorType: options[0], | ||
isEditing: true, | ||
setConnectorType: action(function (value) { | ||
this.set('selectedConnectorType', value); | ||
}), | ||
label: 'Fruit', | ||
id: 'fruit-basket', | ||
isValid: false, | ||
error: 'No more fruit', | ||
}; |
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
Oops, something went wrong.