This repository has been archived by the owner on Dec 20, 2024. It is now read-only.
-
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.
Merge pull request #106 from ConduitIO/jj/new-links
feat(mox/link-button): add new link-button component
- Loading branch information
Showing
8 changed files
with
254 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"mx-ui-components": minor | ||
--- | ||
|
||
feat(mox/link-button): add new link-button component |
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 @@ | ||
{{#if @route}} | ||
<Mox::LinkTo @route={{@route}} @model={{@model}} | ||
class="mox-link-button cursor-pointer rounded-md p-2 text-gray-800 hover:text-gray-900 hover:bg-gray-300 dark:text-gray-300 transition duration-300" | ||
data-test-mox-link={{@route}} ...attributes> | ||
{{yield}} | ||
</Mox::LinkTo> | ||
{{else}} | ||
<a | ||
href={{@externalUrl}} | ||
target="_blank" | ||
class="mox-link-button cursor-pointer rounded-md p-2 text-gray-800 hover:text-gray-900 hover:bg-gray-300 dark:text-gray-300 transition duration-300" | ||
data-test-mox-link | ||
rel="noopener noreferrer" | ||
...attributes | ||
>{{yield}}</a> | ||
{{/if}} |
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
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 @@ | ||
export { default } from 'mx-ui-components/components/mox/link-button'; |
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,47 @@ | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
|
||
export default { | ||
title: 'Mox Light/Mox::LinkButton', | ||
parameters: { | ||
backgrounds: { | ||
default: 'Light', | ||
}, | ||
}, | ||
}; | ||
|
||
const Template = (args) => ({ | ||
template: hbs` | ||
<Mox::LinkButton @route={{this.route}} @externalUrl={{this.url}} @model={{this.model}} class={{this.activeClass}}> | ||
{{this.text}} | ||
</Mox::LinkButton>`, | ||
context: args, | ||
}); | ||
|
||
export const LinkToInternalPage = Template.bind({}); | ||
LinkToInternalPage.args = { | ||
route: 'application', | ||
model: 3, | ||
url: null, | ||
isButton: false, | ||
text: 'Internal Link', | ||
}; | ||
|
||
export const ActiveLink = Template.bind({}); | ||
ActiveLink.args = { | ||
route: 'application', | ||
model: 3, | ||
url: null, | ||
isButton: false, | ||
text: 'Active Link', | ||
activeClass: 'active', | ||
}; | ||
|
||
export const LinkToExternalPage= Template.bind({}); | ||
LinkToExternalPage.args = { | ||
route: null, | ||
model: null, | ||
url: 'https://github.com/ConduitIO/mx-ui-components', | ||
isButton: false, | ||
text: 'External Link', | ||
}; | ||
|
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,49 @@ | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
|
||
export default { | ||
title: 'Mox Dark/Mox::LinkButton', | ||
parameters: { | ||
backgrounds: { | ||
default: 'Dark', | ||
}, | ||
}, | ||
}; | ||
|
||
const Template = (args) => ({ | ||
template: hbs` | ||
<div class="dark"> | ||
<Mox::LinkButton @route={{this.route}} @externalUrl={{this.url}} @model={{this.model}} class={{this.activeClass}}> | ||
{{this.text}} | ||
</Mox::LinkButton> | ||
</div>`, | ||
context: args, | ||
}); | ||
|
||
export const LinkToInternalPage = Template.bind({}); | ||
LinkToInternalPage.args = { | ||
route: 'application', | ||
model: 3, | ||
url: null, | ||
isButton: false, | ||
text: 'Internal Link', | ||
}; | ||
|
||
export const ActiveLink = Template.bind({}); | ||
ActiveLink.args = { | ||
route: 'application', | ||
model: 3, | ||
url: null, | ||
isButton: false, | ||
text: 'Active Link', | ||
activeClass: 'active', | ||
}; | ||
|
||
export const LinkToExternalPage= Template.bind({}); | ||
LinkToExternalPage.args = { | ||
route: null, | ||
model: null, | ||
url: 'https://github.com/ConduitIO/mx-ui-components', | ||
isButton: false, | ||
text: 'External Link', | ||
}; | ||
|
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,122 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'dummy/tests/helpers'; | ||
import { render } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
import { a11yAudit } from 'ember-a11y-testing/test-support'; | ||
|
||
module('Integration | Component | mox/link-button', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('it renders an empty link by default', async function (assert) { | ||
await render(hbs` | ||
<Mox::LinkButton> | ||
A link | ||
</Mox::LinkButton> | ||
`); | ||
|
||
assert.dom('[data-test-mox-link]').includesText('A link'); | ||
assert.dom('[data-test-mox-link]').doesNotHaveAttribute('href'); | ||
}); | ||
|
||
test('it renders (@route)', async function (assert) { | ||
await render(hbs` | ||
<Mox::LinkButton @route="application"> | ||
Internal link | ||
</Mox::LinkButton> | ||
`); | ||
|
||
assert.dom('[data-test-mox-link]').includesText('Internal link'); | ||
assert.dom('[data-test-mox-link]').hasAttribute('href', '/'); | ||
}); | ||
|
||
test('it renders (@externalUrl)', async function (assert) { | ||
await render(hbs` | ||
<Mox::LinkButton @externalUrl="http://localhost:7357"> | ||
External link | ||
</Mox::LinkButton> | ||
`); | ||
|
||
assert.dom('[data-test-mox-link]').includesText('External link'); | ||
assert | ||
.dom('[data-test-mox-link]') | ||
.hasAttribute('href', 'http://localhost:7357'); | ||
}); | ||
|
||
test('it is accessible (@route + dark mode)', async function (assert) { | ||
await render(hbs` | ||
<div class="bg-gray-900 dark"> | ||
<Mox::LinkButton @route="application"> | ||
Internal link | ||
</Mox::LinkButton> | ||
</div> | ||
`); | ||
|
||
await a11yAudit(); | ||
assert.ok(true, 'no a11y errors detected'); | ||
}); | ||
|
||
test('it is accessible (@externalUrl + dark mode)', async function (assert) { | ||
await render(hbs` | ||
<div class="bg-gray-900 dark"> | ||
<Mox::LinkButton @externalUrl="http://localhost:7357"> | ||
External link | ||
</Mox::LinkButton> | ||
</div> | ||
`); | ||
|
||
await a11yAudit(); | ||
assert.ok(true, 'no a11y errors detected'); | ||
}); | ||
|
||
test('it is accessible (@route + dark mode + active)', async function (assert) { | ||
await render(hbs` | ||
<div class="bg-gray-900 dark"> | ||
<Mox::LinkButton @route="application" class="active"> | ||
Internal link | ||
</Mox::LinkButton> | ||
</div> | ||
`); | ||
|
||
await a11yAudit(); | ||
assert.ok(true, 'no a11y errors detected'); | ||
}); | ||
|
||
test('it is accessible (@route + light mode)', async function (assert) { | ||
await render(hbs` | ||
<div class="bg-gray-50"> | ||
<Mox::LinkButton @route="application"> | ||
Internal link | ||
</Mox::LinkButton> | ||
</div> | ||
`); | ||
|
||
await a11yAudit(); | ||
assert.ok(true, 'no a11y errors detected'); | ||
}); | ||
|
||
test('it is accessible (@route + light mode + active)', async function (assert) { | ||
await render(hbs` | ||
<div class="bg-gray-50"> | ||
<Mox::LinkButton @route="application" class="active"> | ||
Internal link | ||
</Mox::LinkButton> | ||
</div> | ||
`); | ||
|
||
await a11yAudit(); | ||
assert.ok(true, 'no a11y errors detected'); | ||
}); | ||
|
||
test('it is accessible (@externalUrl + light mode)', async function (assert) { | ||
await render(hbs` | ||
<div class="bg-gray-50"> | ||
<Mox::LinkButton @externalUrl="http://localhost:7357"> | ||
External link | ||
</Mox::LinkButton> | ||
</div> | ||
`); | ||
|
||
await a11yAudit(); | ||
assert.ok(true, 'no a11y errors detected'); | ||
}); | ||
}); |