Skip to content

Commit

Permalink
Use classnames package to apply component classes. Ensure specified v…
Browse files Browse the repository at this point in the history
…ariant is supported.
  • Loading branch information
dan-searle committed Nov 27, 2018
1 parent 0cef6df commit cef0d8f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion components/x-follow-button/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
},
"dependencies": {
"@financial-times/x-interaction": "file:../x-interaction",
"@financial-times/x-engine": "file:../../packages/x-engine"
"@financial-times/x-engine": "file:../../packages/x-engine",
"classnames": "^2.2.6"
}
}
6 changes: 5 additions & 1 deletion components/x-follow-button/src/FollowButton.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { h } from '@financial-times/x-engine';
import classNames from 'classnames';
import styles from './styles/main.scss';

export const FollowButton = (props) => {
Expand All @@ -11,6 +12,7 @@ export const FollowButton = (props) => {
followPlusDigestEmail,
variant
} = props;
const VARIANTS = ['standard', 'inverse', 'opinion', 'monochrome'];

const getFormAction = () => {
if (followPlusDigestEmail) {
Expand Down Expand Up @@ -61,7 +63,9 @@ export const FollowButton = (props) => {
title={isFollowed ? followedConceptNameText : unfollowedConceptNameText}
aria-label={isFollowed ? followedConceptNameText : unfollowedConceptNameText}
aria-pressed={isFollowed ? 'true' : 'false'}
className={`${styles['button']} ${styles[`button--${variant}`]}`}
className={classNames(styles['button'], {
[styles[`button--${variant}`]]: VARIANTS.includes(variant)
})}
data-concept-id={conceptId}
data-trackable-context-messaging={
followPlusDigestEmail ? 'add-to-myft-plus-digest-button' : null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@import '../mixins/lozenge/main';

/* Mixins: are going to be reused accross various components */
/* Mixins: are going to be reused across various components */

.button {
@include myftLozenge($with-toggle-icon: true);
Expand Down

0 comments on commit cef0d8f

Please sign in to comment.