This repository is currently being migrated. It's locked while the migration is in progress.
-
Notifications
You must be signed in to change notification settings - Fork 20
<va-tag>: Add new web component #1808
Draft
RyanMunsch
wants to merge
5
commits into
main
Choose a base branch
from
3848-va-tag
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
965d327
Replace USWDS/CSS library tag with new <va-tag> component
RyanMunsch df63cdf
Merge branch 'main' into 3848-va-tag
RyanMunsch f41a849
va-tag: Use nested span el and remove unnecessary sass import
RyanMunsch c7a8a53
Update va-tag unit test to reflect DOM structure change
RyanMunsch 2f255cd
Add old version of Tag to deprecated on Storybook
RyanMunsch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,36 @@ | ||
| import { getWebComponentDocs, propStructure, StoryDocs } from './wc-helpers'; | ||
|
|
||
| const tagDocs = getWebComponentDocs('va-tag'); | ||
|
|
||
| export default { | ||
| title: 'Components/Tag', | ||
| id: 'components/va-tag', | ||
| component: 'va-tag', | ||
| decorators: [ | ||
| (Story) => ( | ||
| <div className="vads-u-margin--1"> | ||
| <Story /> | ||
| </div> | ||
| ), | ||
| ], | ||
| parameters: { | ||
| componentSubtitle: 'va-tag web component', | ||
| docs: { | ||
| page: () => <StoryDocs storyDefault={Default} data={tagDocs} />, | ||
| }, | ||
| }, | ||
| argTypes: { | ||
| ...propStructure(tagDocs), | ||
| } | ||
| }; | ||
|
|
||
| const Template = (args) => { | ||
| return ( | ||
| <va-tag text={args.text}></va-tag> | ||
| ); | ||
| }; | ||
|
|
||
| export const Default = Template.bind({}); | ||
| Default.args = { | ||
| text: 'New', | ||
| }; |
This file contains hidden or 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
27 changes: 27 additions & 0 deletions
27
packages/web-components/src/components/va-tag/test/va-tag.e2e.ts
This file contains hidden or 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,27 @@ | ||
| import { newE2EPage } from '@stencil/core/testing'; | ||
| import { axeCheck } from '../../../testing/test-helpers'; | ||
|
|
||
| describe('va-tag', () => { | ||
| it('renders', async () => { | ||
| const page = await newE2EPage(); | ||
| await page.setContent('<va-tag text="Test tag"></va-tag>'); | ||
|
|
||
| const element = await page.find('va-tag'); | ||
| expect(element).toHaveClass('hydrated'); | ||
| }); | ||
|
|
||
| it('passes accessibility tests', async () => { | ||
| const page = await newE2EPage(); | ||
| await page.setContent('<va-tag></va-tag>'); | ||
|
|
||
| await axeCheck(page); | ||
| }); | ||
|
|
||
| it('respect the text prop', async () => { | ||
| const page = await newE2EPage(); | ||
| await page.setContent('<va-tag text="Test tag"></va-tag>'); | ||
|
|
||
| const element = await page.find('va-tag'); | ||
| expect(element.shadowRoot.innerHTML).toBe('Test tag'); | ||
| }); | ||
| }); |
This file contains hidden or 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,15 @@ | ||
| @import '~@department-of-veterans-affairs/css-library/dist/tokens/scss/variables.scss'; | ||
|
RyanMunsch marked this conversation as resolved.
Outdated
|
||
|
|
||
| :host { | ||
| width: auto; | ||
|
RyanMunsch marked this conversation as resolved.
Outdated
|
||
| padding: 1px .5rem; | ||
| border-radius: 2px; | ||
| color: var(--vads-color-white); | ||
| font-size: 0.938rem; | ||
| background-color: var(--vads-color-base-dark); | ||
| text-transform: uppercase; | ||
|
|
||
| &:only-of-type { | ||
| margin-right: 0; | ||
| } | ||
| } | ||
This file contains hidden or 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 { | ||
| Component, | ||
| Element, | ||
| Host, | ||
| Prop, | ||
| h, | ||
| } from '@stencil/core'; | ||
|
|
||
| /** | ||
| * @componentName Tag | ||
| * @maturityCategory caution | ||
| * @maturityLevel candidate | ||
| */ | ||
| @Component({ | ||
| tag: 'va-tag', | ||
| styleUrl: 'va-tag.scss', | ||
| shadow: true, | ||
| }) | ||
| export class VaTag { | ||
| @Element() el: HTMLElement; | ||
|
|
||
| /** | ||
| * The text to be displayed in the tag element. | ||
| */ | ||
| @Prop() text!: string; | ||
|
|
||
| render() { | ||
| const { text } = this; | ||
|
|
||
| return <Host class="va-tag">{text}</Host>; | ||
|
RyanMunsch marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to understand our deprecation process for this before removing it. It might be better to start with adding it to the deprecated section. There will ideally be some communication around this as well.