Skip to content

Commit

Permalink
feat(paragraph): Join class names with a space instead of new lines.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanoglesby08 committed Sep 27, 2017
1 parent 134480b commit 9abac7b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 41 deletions.
12 changes: 2 additions & 10 deletions src/components/Input/__tests__/__snapshots__/Input.spec.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ exports[`Input renders 1`] = `
for="the-input"
>
<span
class="
medium
boldFont
color
"
class="medium boldFont color"
>
The input
</span>
Expand Down Expand Up @@ -49,11 +45,7 @@ exports[`Input renders with a feedback state and icon 1`] = `
for="the-input"
>
<span
class="
medium
boldFont
color
"
class="medium boldFont color"
>
The input
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@ exports[`<Notification /> renders 1`] = `
class="row"
>
<p
class="
noSpacing
color
medium
mediumFont
leftAlign
"
class="noSpacing color medium mediumFont leftAlign"
>
Some content
</p>
Expand Down
15 changes: 8 additions & 7 deletions src/components/Typography/Paragraph/Paragraph.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'
import PropTypes from 'prop-types'

import safeRest from '../../../utils/safeRest'
import joinClassNames from '../../../utils/joinClassNames'

import spacingStyles from '../../Spacing/Spacing.modules.scss'
import styles from './Paragraph.modules.scss'
Expand All @@ -15,13 +16,13 @@ import textStyles from '../Text/Text.modules.scss'
const Paragraph = ({ bold, size, align, invert, children, ...rest }, context) => {
const paragraphColor = invert ? textStyles.invertedColor : textStyles.color

const classes = `
${spacingStyles.noSpacing}
${context.inheritColor ? textStyles.inheritColor : paragraphColor}
${textStyles[size]}
${bold ? textStyles.boldFont : textStyles[`${size}Font`]}
${styles[`${align}Align`]}
`
const classes = joinClassNames(
spacingStyles.noSpacing,
context.inheritColor ? textStyles.inheritColor : paragraphColor,
textStyles[size],
bold ? textStyles.boldFont : textStyles[`${size}Font`],
styles[`${align}Align`]
)

return (
<p {...safeRest(rest)} className={classes}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@

exports[`Paragraph renders 1`] = `
<p
className="
noSpacing
color
medium
mediumFont
leftAlign
"
className="noSpacing color medium mediumFont leftAlign"
>
Some content
</p>
Expand Down
12 changes: 7 additions & 5 deletions src/components/Typography/Text/Text.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from 'react'
import PropTypes from 'prop-types'

import safeRest from '../../../utils/safeRest'
import joinClassNames from '../../../utils/joinClassNames'

import TextSup from './TextSup/TextSup'
import TextSub from './TextSub/TextSub'

Expand All @@ -15,11 +17,11 @@ import styles from './Text.modules.scss'
const Text = ({ bold, size, invert, children, ...rest }, context) => {
const textColor = invert ? styles.invertedColor : styles.color

const classes = `
${styles[size]}
${bold ? styles.boldFont : styles[`${size}Font`]}
${context.inheritColor ? styles.inheritColor : textColor}
`
const classes = joinClassNames(
styles[size],
bold ? styles.boldFont : styles[`${size}Font`],
context.inheritColor ? styles.inheritColor : textColor
)

return (
<span {...safeRest(rest)} className={classes}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

exports[`Text renders 1`] = `
<span
className="
base
baseFont
color
"
className="base baseFont color"
>
Some content
</span>
Expand Down

0 comments on commit 9abac7b

Please sign in to comment.