diff --git a/packages/storybook/stories/va-link.stories.jsx b/packages/storybook/stories/va-link.stories.jsx
index 278c3eb9e1..12546cf580 100644
--- a/packages/storybook/stories/va-link.stories.jsx
+++ b/packages/storybook/stories/va-link.stories.jsx
@@ -28,7 +28,9 @@ const defaultArgs = {
'reverse': undefined,
'text': undefined,
'video': undefined,
- 'label': undefined
+ 'label': undefined,
+ 'icon-name': undefined,
+ 'icon-size': undefined,
};
const Template = ({
@@ -96,6 +98,8 @@ const VariantTemplate = ({
text,
video,
label,
+ 'icon-name': iconName,
+ 'icon-size': iconSize,
}) => {
return (
);
};
@@ -155,14 +161,46 @@ Calendar.args = {
text: `Add to calendar`,
};
+export const Icon = VariantTemplate.bind(null);
+Icon.args = {
+ ...defaultArgs,
+ 'href': '#',
+ 'text': `National Cemetery Administration`,
+ 'icon-name': 'mail',
+ 'icon-size': 3,
+};
+
const ReverseTemplate = ({ filename, filetype, href, reverse, text }) => {
return (
-
+
Default Link
-
+
Active Link
-
+
+
+
Icon
+
Download Link
{
/>
Video Link
-
-
Channel Link
-
Calendar Link
- {
`);
});
+ it('renders custom icon link', async () => {
+ const page = await newE2EPage();
+ await page.setContent(
+ ``,
+ );
+
+ const element = await page.find('va-link');
+ expect(element).toEqualHtml(`
+
+
+
+
+ Veteran's Affairs
+
+
+
+ `);
+ });
+
it('renders a link with a screen reader label', async () => {
const page = await newE2EPage();
await page.setContent(``);
diff --git a/packages/web-components/src/components/va-link/va-link.css b/packages/web-components/src/components/va-link/va-link.css
index 3cab802ddd..fe7ea39843 100644
--- a/packages/web-components/src/components/va-link/va-link.css
+++ b/packages/web-components/src/components/va-link/va-link.css
@@ -23,6 +23,10 @@
font-weight: 700;
}
+:host([icon-name]) va-icon {
+ margin-right: 4px;
+}
+
.link-icon--active {
vertical-align: baseline;
position: relative;
@@ -32,10 +36,15 @@
.link-icon--left {
margin-right: 4px;
vertical-align: baseline;
- position: relative;
+ position: relative;
top: 3px;
}
+.link--center {
+ display: inline-flex;
+ align-items: center;
+}
+
dfn {
font-style: normal;
}
diff --git a/packages/web-components/src/components/va-link/va-link.tsx b/packages/web-components/src/components/va-link/va-link.tsx
index caaeda90e6..94f80cedf3 100644
--- a/packages/web-components/src/components/va-link/va-link.tsx
+++ b/packages/web-components/src/components/va-link/va-link.tsx
@@ -81,8 +81,18 @@ export class VaLink {
/**
* Adds an aria-label attribute to the link element.
*/
- @Prop() label?: string = null;
+ @Prop() label?: string = null;
+ /**
+ * The name of the icon to be displayed in the link.
+ */
+ @Prop() iconName?: string = null;
+
+ /**
+ * The size variant of the icon,
+ * an integer between 3 and 9 inclusive.
+ */
+ @Prop() iconSize?: number = 3;
/**
* The event used to track usage of the component.
*/
@@ -130,10 +140,13 @@ export class VaLink {
text,
video,
reverse,
+ iconName,
+ iconSize
} = this;
const linkClass = classNames({
'va-link--reverse': reverse,
+ 'link--center': iconName
});
// Active link variant
@@ -207,6 +220,22 @@ export class VaLink {
);
}
+ // Icon link Variant
+ if (iconName) {
+ return (
+
+
+
+ {text}
+
+
+ );
+ }
+
// Default
return (