From 3c6bff698b281baef456a73c38abe417973e2109 Mon Sep 17 00:00:00 2001 From: TJ Egan Date: Mon, 3 Feb 2020 14:15:31 -0800 Subject: [PATCH] fix(link): remove visited styles by default (#5239) --- .../components/src/components/link/_link.scss | 12 ++++++++++-- packages/components/src/components/link/link.hbs | 11 ++++++++--- packages/react/src/components/Link/Link-story.js | 1 + packages/react/src/components/Link/Link.js | 16 +++++++++++++++- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/packages/components/src/components/link/_link.scss b/packages/components/src/components/link/_link.scss index 6d8897b36c6d..79a29d874a1c 100644 --- a/packages/components/src/components/link/_link.scss +++ b/packages/components/src/components/link/_link.scss @@ -53,11 +53,11 @@ } &:visited { - color: $visited-link; + color: $link-01; } &:visited:hover { - color: $hover-primary-text; + color: $link-01; } } @@ -70,6 +70,14 @@ cursor: not-allowed; } + .#{$prefix}--link.#{$prefix}--link--visited:visited { + color: $visited-link; + } + + .#{$prefix}--link.#{$prefix}--link--visited:visited:hover { + color: $hover-primary-text; + } + .#{$prefix}--link.#{$prefix}--link--inline { text-decoration: underline; diff --git a/packages/components/src/components/link/link.hbs b/packages/components/src/components/link/link.hbs index acf9def0ad5f..d47d8a99c171 100644 --- a/packages/components/src/components/link/link.hbs +++ b/packages/components/src/components/link/link.hbs @@ -5,9 +5,14 @@ LICENSE file in the root directory of this source tree. --> -Link -Placeholder link +Link +Link +Placeholder + link
- Text wrap example for hover, focus, and active state testing. + Text wrap example for + hover, focus, and active state testing.
diff --git a/packages/react/src/components/Link/Link-story.js b/packages/react/src/components/Link/Link-story.js index 77068abf8863..35344080299b 100644 --- a/packages/react/src/components/Link/Link-story.js +++ b/packages/react/src/components/Link/Link-story.js @@ -17,6 +17,7 @@ const props = () => ({ className: 'some-class', href: text('The link href (href)', '#'), inline: boolean('Use the in-line variant (inline)', false), + visited: boolean('Allow visited styles', false), onClick: (handler => evt => { evt.preventDefault(); // Prevent link from being followed for demo purpose handler(evt); diff --git a/packages/react/src/components/Link/Link.js b/packages/react/src/components/Link/Link.js index 6ad85acd8a15..414121dde16c 100644 --- a/packages/react/src/components/Link/Link.js +++ b/packages/react/src/components/Link/Link.js @@ -12,10 +12,19 @@ import { settings } from 'carbon-components'; const { prefix } = settings; -const Link = ({ children, className, href, disabled, inline, ...other }) => { +const Link = ({ + children, + className, + href, + disabled, + inline, + visited, + ...other +}) => { const classNames = classnames(`${prefix}--link`, className, { [`${prefix}--link--disabled`]: disabled, [`${prefix}--link--inline`]: inline, + [`${prefix}--link--visited`]: visited, }); const Tag = disabled ? 'p' : 'a'; return ( @@ -50,6 +59,11 @@ Link.propTypes = { * Specify whether you want the inline version of this control */ inline: PropTypes.bool, + + /** + * Specify whether you want the link to receive visited styles after the link has been clicked + */ + visited: PropTypes.bool, }; export default Link;