-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
39b75de
commit 308f2a9
Showing
8 changed files
with
153 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
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,14 @@ | ||
# sage-link | ||
|
||
Link is mainly used as navigational element and usually appear within or directly following a paragraph or sentence. The "plain link" is used for interactive user generated text like product, post, and offer titles. | ||
|
||
<!-- Auto Generated Below --> | ||
|
||
## Properties | ||
|
||
| Property | Attribute | Description | Type | Default | | ||
| ------------------- | --------- | ------------------------------------- | -------- | ----------- | | ||
| `href` _(required)_ | `href` | The URL that the hyperlink points to. | `string` | `undefined` | | ||
| `text` _(required)_ | `text` | The text content that is rendered. | `string` | `undefined` | | ||
|
||
--- |
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,32 @@ | ||
import { newE2EPage } from '@stencil/core/testing'; | ||
|
||
describe('sage-link', () => { | ||
it('renders', async () => { | ||
const page = await newE2EPage(); | ||
|
||
await page.setContent('<sage-link></sage-link>'); | ||
const element = await page.find('sage-link'); | ||
expect(element).toHaveClass('hydrated'); | ||
}); | ||
|
||
it('renders changes to the name data', async () => { | ||
const page = await newE2EPage(); | ||
|
||
await page.setContent('<sage-link></sage-link>'); | ||
const component = await page.find('sage-link'); | ||
const element = await page.find('sage-link >>> div'); | ||
expect(element.textContent).toEqual(`Hello, World! I'm `); | ||
|
||
component.setProperty('first', 'James'); | ||
await page.waitForChanges(); | ||
expect(element.textContent).toEqual(`Hello, World! I'm James`); | ||
|
||
component.setProperty('last', 'Quincy'); | ||
await page.waitForChanges(); | ||
expect(element.textContent).toEqual(`Hello, World! I'm James Quincy`); | ||
|
||
component.setProperty('middle', 'Earl'); | ||
await page.waitForChanges(); | ||
expect(element.textContent).toEqual(`Hello, World! I'm James Earl Quincy`); | ||
}); | ||
}); |
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,7 @@ | ||
:host { | ||
display: block; | ||
|
||
a { | ||
color: #202327; | ||
} | ||
} |
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,35 @@ | ||
import { newSpecPage } from '@stencil/core/testing'; | ||
import { SageLink } from './sage-link'; | ||
|
||
describe('sage-link', () => { | ||
it('renders', async () => { | ||
const { root } = await newSpecPage({ | ||
components: [SageLink], | ||
html: '<sage-link></sage-link>', | ||
}); | ||
expect(root).toEqualHtml(` | ||
<sage-link> | ||
<mock:shadow-root> | ||
<a> | ||
</a> | ||
</mock:shadow-root> | ||
</sage-link> | ||
`); | ||
}); | ||
|
||
it('renders with values', async () => { | ||
const { root } = await newSpecPage({ | ||
components: [SageLink], | ||
html: `<sage-link href="#" text="'Don't call me a framework' JS"></sage-link>`, | ||
}); | ||
expect(root).toEqualHtml(` | ||
<sage-link href="#" text="'Don't call me a framework' JS"> | ||
<mock:shadow-root> | ||
<a href="#"> | ||
'Don't call me a framework' JS | ||
</a> | ||
</mock:shadow-root> | ||
</sage-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,12 @@ | ||
import { h } from '@stencil/core'; | ||
import { SageLink } from '@sage/core/sage-link'; | ||
|
||
export default { | ||
title: 'webcomponents/Link', | ||
component: SageLink, | ||
}; | ||
|
||
const Template = args => <sage-link href={args.href} text={args.text}></sage-link>; | ||
|
||
export const Plain = Template.bind({}); | ||
Plain.args = { text: 'Sage 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,23 @@ | ||
import { Component, h, Prop } from '@stencil/core'; | ||
|
||
@Component({ | ||
tag: 'sage-link', | ||
styleUrl: 'sage-link.scss', | ||
shadow: true, | ||
}) | ||
export class SageLink { | ||
/** | ||
* The URL that the hyperlink points to. | ||
*/ | ||
|
||
@Prop() href!: string; | ||
|
||
/** | ||
* The text content that is rendered. | ||
*/ | ||
@Prop() text!: string; | ||
|
||
render() { | ||
return <a href={this.href}>{this.text}</a>; | ||
} | ||
} |
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