Skip to content

Commit

Permalink
feat: add 'visited state' to CvLink
Browse files Browse the repository at this point in the history
Update CvLink prop list with 'visited' field and add 'link--visited'
class to component when it is true
  • Loading branch information
felipebritor committed Mar 24, 2023
1 parent 33c3ce3 commit 92de599
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/components/CvLink/CvLink.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ export default {
description:
"Replace `<a>` node for vue-router's `router-link`, providing `to` property to it. Cannot be used with href.",
},
visited: {
type: 'boolean',
table: {
type: { summary: 'boolean' },
category: 'props',
},
defaultValue: false,
description:
'Specify whether you want the link to receive visited styles after the link has been clicked.',
},
default: {
type: 'string',
table: {
Expand Down
2 changes: 2 additions & 0 deletions src/components/CvLink/CvLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
{
[`${carbonPrefix}--link--disabled`]: disabled,
[`${carbonPrefix}--link--inline`]: inline,
[`${carbonPrefix}--link--visited`]: visited,
},
]"
>
Expand All @@ -25,6 +26,7 @@ import {
const props = defineProps({
inline: Boolean,
visited: Boolean,
...linkPropsDefinition,
});
const linkProps = useLinkProps(props);
Expand Down
9 changes: 9 additions & 0 deletions src/components/CvLink/__tests__/CvLink.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,13 @@ describe('CvLink', () => {
const element = container.firstElementChild;
expect(element.classList.contains('bx--link--inline')).toBe(true);
});

it("sets link in visited state when 'visited' is true", () => {
const { container } = render(CvLink, {
props: { visited: true },
});

const element = container.firstElementChild;
expect(element.classList.contains('bx--link--visited')).toBe(true);
});
});

0 comments on commit 92de599

Please sign in to comment.