@@ -52,7 +52,7 @@
id={{concat "typeaheadselectlistbox" @id}}
tabindex="1"
role="listbox"
- class="max-h-56 rounded-md text-base overflow-auto focus:outline-none sm:text-sm border border-gray-500"
+ class="max-h-56 rounded-md text-base overflow-auto focus:outline-none sm:text-sm border border-gray-300 dark:border-gray-500"
>
{{!-- template-lint-enable no-positive-tabindex --}}
{{#each this.matches as |match idx|}}
@@ -60,13 +60,14 @@
{{@name}}
- {{@category}}
+ {{@category}}
diff --git a/package.json b/package.json
index ed03774f..7370599e 100644
--- a/package.json
+++ b/package.json
@@ -91,6 +91,7 @@
"ember-concurrency": "^3.0.0",
"ember-keyboard": "8.2.0",
"ember-load-initializers": "^2.1.2",
+ "ember-modifier": "^4.1.0",
"ember-page-title": "^7.0.0",
"ember-qunit": "^6.2.0",
"ember-resolver": "^10.1.0",
diff --git a/stories/mox-select-light.stories.js b/stories/mox-select-light.stories.js
new file mode 100644
index 00000000..640e198b
--- /dev/null
+++ b/stories/mox-select-light.stories.js
@@ -0,0 +1,220 @@
+import { hbs } from 'ember-cli-htmlbars';
+import { action } from '@ember/object';
+
+const connectorTypes = [
+ { name: 'source', value: 'source' },
+ { name: 'sink', value: 'sink' },
+];
+
+const connectorTypesCustom = [
+ { name: 'My environment', value: 'my-environment', type: 'Self-Hosted' },
+ { name: 'Meroxa environment', value: 'meroxa-environment', type: 'Private' },
+ { name: 'Common', value: 'common', type: 'Common' },
+];
+
+const connectorTypesDisabled = [
+ { name: 'My environment', value: 'my-environment', isDisabled: false },
+ { name: 'Meroxa environment', value: 'meroxa-environment', isDisabled: true },
+ { name: 'Common', value: 'common', isDisabled: false },
+];
+
+const resourceTypes = [
+ { name: 'Postgres', value: 'postgres' },
+ { name: 'MongoDB', value: 'mongodb' },
+];
+
+export default {
+ title: 'Mox Light/Mox::Select',
+ parameters: {
+ backgrounds: {
+ default: 'Mute',
+ values: [
+ {
+ name: 'White',
+ value: '#ffffff',
+ },
+ {
+ name: 'Mute',
+ value: '#F3F4F6',
+ },
+ ],
+ },
+ },
+ argTypes: {
+ options: { control: 'text' },
+ buttonType: { control: 'text' },
+ },
+};
+
+const Template = (args) => ({
+ template: hbs`
+
-
+
`,
context: args,
@@ -62,7 +74,7 @@ Default.args = {
setConnectorType: action(function (value) {
this.set('selectedConnectorType', value);
}),
- wrapperClass: null,
+ wrapperClass: 'dark',
label: 'Fruit',
id: 'fruit-basket',
};
@@ -75,7 +87,7 @@ Short.args = {
setConnectorType: action(function (value) {
this.set('selectedConnectorType', value);
}),
- wrapperClass: 'w-20',
+ wrapperClass: 'dark w-20',
label: 'Fruit',
id: 'fruit-basket',
};
@@ -88,7 +100,7 @@ ExternalLabel.args = {
setConnectorType: action(function (value) {
this.set('selectedConnectorType', value);
}),
- wrapperClass: null,
+ wrapperClass: 'dark',
id: 'fruit-basket',
};
@@ -102,6 +114,7 @@ Disabled.args = {
}),
label: 'Fruit',
id: 'fruit-basket',
+ wrapperClass: 'dark',
};
export const Errors = Template.bind({});
@@ -116,4 +129,5 @@ Errors.args = {
id: 'fruit-basket',
isValid: false,
error: 'No more fruit',
+ wrapperClass: 'dark',
};
diff --git a/tests/integration/components/mox/input-test.js b/tests/integration/components/mox/input-test.js
index 289dd97c..87ef6a82 100644
--- a/tests/integration/components/mox/input-test.js
+++ b/tests/integration/components/mox/input-test.js
@@ -65,10 +65,14 @@ module('Integration | Component | mox/input', function (hooks) {
`);
let secondField = await find('[data-test-second-field]');
+ let initialPosition = secondField.getBoundingClientRect().top;
assert
.dom('[data-test-first-field] [data-test-mox-input-error]')
.doesNotExist();
- assert.strictEqual(secondField.offsetTop, 54);
+ assert.strictEqual(
+ secondField.getBoundingClientRect().top,
+ initialPosition
+ );
this.set('error', 'message1');
@@ -76,10 +80,20 @@ module('Integration | Component | mox/input', function (hooks) {
.dom('[data-test-first-field] + [data-test-mox-input-error]')
.includesText('message1');
assert.strictEqual(
- secondField.offsetTop,
- 54,
+ secondField.getBoundingClientRect().top,
+ initialPosition,
'the second field does not change its position relative to the top'
);
+
+ this.set('error', null);
+
+ assert
+ .dom('[data-test-first-field] [data-test-mox-input-error]')
+ .doesNotExist();
+ assert.strictEqual(
+ secondField.getBoundingClientRect().top,
+ initialPosition
+ );
});
module('light mode', function () {
diff --git a/tests/integration/components/mox/select-test.js b/tests/integration/components/mox/select-test.js
index 07f67d1a..a1ab4615 100644
--- a/tests/integration/components/mox/select-test.js
+++ b/tests/integration/components/mox/select-test.js
@@ -51,114 +51,6 @@ module('Integration | Component | mox/select', function (hooks) {
assert.dom('[data-test-select-button]').isDisabled();
});
- test('it highlights the field if it is invalid (dark mode)', async function (assert) {
- this.set('onInput', () => {});
-
- await render(hbs`
-
-
-
`);
-
- assert.dom('[data-test-select-button]').hasClass('border-red-800');
- assert.dom('[data-test-select-button]').hasStyle({
- borderColor: 'rgb(153, 27, 27)',
- });
- });
-
- test('it allows to validate and invalidate the field after rendering (dark mode)', async function (assert) {
- this.set('onInput', () => {});
- this.set('isValid', null);
-
- await render(hbs`
-
-
-
`);
-
- assert.dom('[data-test-select-button]').doesNotHaveClass('border-red-800');
- assert.dom('[data-test-select-button]').hasStyle({
- borderColor: 'rgb(107, 114, 128)',
- });
-
- this.set('isValid', false);
-
- assert.dom('[data-test-select-button]').hasClass('border-red-800');
- assert.dom('[data-test-select-button]').hasStyle({
- borderColor: 'rgb(153, 27, 27)',
- });
-
- this.set('isValid', true);
-
- assert.dom('[data-test-select-button]').doesNotHaveClass('border-red-800');
- assert.dom('[data-test-select-button]').hasStyle({
- borderColor: 'rgb(107, 114, 128)',
- });
- });
-
- test('it may display a validation error alongside the field', async function (assert) {
- this.set('onInput', () => {});
-
- await render(hbs`
`);
-
- assert
- .dom('[data-test-mox-select-error]')
- .includesText(`Connector missing`);
- });
-
- test('it is accessible (dark mode)', async function (assert) {
- await render(hbs`
-
-
-
`);
-
- await a11yAudit();
- assert.ok(true, 'no a11y detected');
- });
-
- test('the invalid input state is accessible', async function (assert) {
- this.set('onInput', () => {});
-
- await render(hbs`
-
-
`);
- await a11yAudit();
- assert.ok(true, 'no accessibility errors');
- });
-
module('when toggled', function (hooks) {
hooks.beforeEach(async function () {
await render(hbs`
@@ -267,6 +159,56 @@ module('Integration | Component | mox/select', function (hooks) {
.includesText('Self-Hosted');
});
+ test('it is accessible with custom options (dark mode)', async function (assert) {
+ await render(hbs`
+
+
+ {{#each this.options as |option|}}
+
+ {{/each}}
+
+
`);
+
+ await click('[data-test-select-button]');
+
+ await a11yAudit();
+ assert.ok(true, 'it has no accessibility errors');
+ });
+
+ test('it is accessible with custom options (light mode)', async function (assert) {
+ await render(hbs`
+
+
+ {{#each this.options as |option|}}
+
+ {{/each}}
+
+
`);
+
+ await click('[data-test-select-button]');
+
+ await a11yAudit();
+ assert.ok(true, 'it has no accessibility errors');
+ });
+
test('it allows selecting customized options', async function (assert) {
await render(hbs`
+
- {{#each this.options as |option|}}
-
- {{/each}}
- `);
+ {{#each this.options as |option|}}
+
+ {{/each}}
+
+
`);
+
+ await click('[data-test-select-button]');
+ assert.dom('[data-test-select-option]').exists({ count: 3 });
+ const options = this.element.querySelectorAll(
+ '[data-test-select-option]'
+ );
+
+ assert.dom(options[0]).includesText('My environment');
+ assert.dom(options[0]).hasClass('dark:text-white');
+
+ assert.dom(options[2]).includesText('Common');
+ assert.dom(options[2]).hasClass('dark:text-white');
+
+ assert.dom(options[1]).includesText('Meroxa environment');
+ assert.dom(options[1]).hasClass('dark:text-gray-500');
+ assert.dom(options[1]).hasClass('dark:bg-gray-700');
+ });
+
+ test('it renders disabled options (light mode)', async function (assert) {
+ await render(hbs`
+