Skip to content

Commit

Permalink
refactor(display-heading): Cleaned up css now that Responsive compone…
Browse files Browse the repository at this point in the history
…nt is used
  • Loading branch information
lzcabrera committed Nov 17, 2017
1 parent c49cd74 commit 35e8d72
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 44 deletions.
28 changes: 11 additions & 17 deletions src/components/Typography/DisplayHeading/DisplayHeading.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import safeRest from '../../../utils/safeRest'
import joinClassNames from '../../../utils/joinClassNames'

import Responsive from '../../Responsive/Responsive'
import DisplayHeadingSup from './DisplayHeadingSup/DisplayHeadingSup'
Expand All @@ -9,30 +10,23 @@ import DisplayHeadingSub from './DisplayHeadingSub/DisplayHeadingSub'
import styles from './DisplayHeading.modules.scss'

const getClassName = (invert, desktop) => {
if (invert && desktop) {
return styles.invertedDesktop
} else if (!invert && desktop) {
return styles.defaultDesktop
} else if (invert && !desktop) {
return styles.inverted
}
return styles.default
return joinClassNames(
styles.heading,
desktop ? styles.headingSizeDesktop : styles.headingSize,
invert ? styles.inverted : styles.default
)
}

/**
* Large page titles. Renders an HTML `<h1>` element.
*/
const DisplayHeading = ({ invert, children, ...rest }) => (
<Responsive minWidth="md">
{matches => {
const desktop = !!matches

return (
<h1 {...safeRest(rest)} className={getClassName(invert, desktop)}>
{children}
</h1>
)
}}
{desktop => (
<h1 {...safeRest(rest)} className={getClassName(invert, desktop)}>
{children}
</h1>
)}
</Responsive>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,55 +11,42 @@
composes: baseSupSubScripts from '../Text/Text.modules.scss';
}

.displayHeading {
.heading {
composes: noSpacing from '../../Spacing.modules.scss';

@include helvetica-neue-thin-35;
}

.headingSize {
font-size: 2.75rem;
line-height: 1.14; // 48px

.sup,
.sub {
font-size: 1.25rem;
}

.sup {
font-size: 1.25rem;
top: -1.2em;
}

.sub {
font-size: 1.25rem;
bottom: -0.5em;
}
}

.inverted {
composes: displayHeading;
color: $color-white;
}

.default {
composes: displayHeading;
color: $color-secondary;
}

.desktop {
.headingSizeDesktop {
font-size: 4.5rem;
line-height: 1.11; // 80px
letter-spacing: 0.2px;
}

.invertedDesktop {
composes: inverted;
composes: desktop;
.sup {
font-size: 1.25rem;
top: -2.2em;
}
}

.defaultDesktop {
composes: default;
composes: desktop;
.inverted {
color: $color-white;
}

.invertedDesktop .sup,
.defaultDesktop .sup {
top: -2.2em;
.default {
color: $color-secondary;
}

0 comments on commit 35e8d72

Please sign in to comment.