Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Commit

Permalink
add semi-bold text weight
Browse files Browse the repository at this point in the history
  • Loading branch information
sejoker committed Apr 18, 2017
1 parent 174d6ba commit f885ae8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/cf-component-text/example/basic/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const TextComponent = () => (
<p>Specify a <code>size</code></p>
<Text size="normal">Hello World</Text>
<Text size="small">Hello World</Text>
<Text size="normal" weight="semi-bold">Hello World</Text>
<Text size="normal" weight="bold">Hello World</Text>

<p>and/or an <code>align</code></p>
Expand Down
6 changes: 4 additions & 2 deletions packages/cf-component-text/src/Text.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { PropTypes } from 'react';
import { createComponent } from 'cf-style-container';
import capitalize from 'capitalize';
import capitalizeWord from 'capitalize';

const capitalize = str => str.split('-').map(w => capitalizeWord(w)).join('');

const styles = ({ theme, size, weight, align, type, case: textCase }) => ({
color: type && theme[`color${capitalize(type)}`],
Expand Down Expand Up @@ -28,7 +30,7 @@ class Text extends React.Component {

Text.propTypes = {
size: PropTypes.oneOf(['normal', 'small']),
weight: PropTypes.oneOf(['normal', 'bold']),
weight: PropTypes.oneOf(['normal', 'semi-bold', 'bold']),
align: PropTypes.oneOf(['start', 'center', 'justify', 'end']),
type: PropTypes.oneOf(['info', 'success', 'warning', 'error', 'muted']),
case: PropTypes.oneOf(['capitalize', 'titlecase', 'lowercase', 'uppercase']),
Expand Down
3 changes: 2 additions & 1 deletion packages/cf-component-text/src/TextTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ export default baseTheme => ({
fontSizeNormal: '1em',
fontSizeSmall: '.8em',
fontWeightNormal: 400,
fontWeightBold: 600,
fontWeightBold: 700,
fontWeightSemiBold: 600,
lineHeightSmall: 1.3,
textAlignStart: 'left',
textAlignCenter: 'center',
Expand Down
14 changes: 13 additions & 1 deletion packages/cf-component-text/test/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test('should render small size', () => {
test('should render bold size', () => {
const Text = applyTheme(TextUnstyled, () => ({
fontSizeNormal: '1rem',
fontWeightBold: 600
fontWeightBold: 700
}));

const component = renderer.create(
Expand All @@ -40,6 +40,18 @@ test('should render bold size', () => {
expect(component.toJSON()).toMatchSnapshot();
});

test('should render semi-bold size', () => {
const Text = applyTheme(TextUnstyled, () => ({
fontSizeNormal: '1rem',
fontWeightSemiBold: 600
}));

const component = renderer.create(
felaTestContext(<Text size="normal" weight="semi-bold">Hello</Text>)
);
expect(component.toJSON()).toMatchSnapshot();
});

test('should render align', () => {
const Text = applyTheme(TextUnstyled, () => ({
textAlignCenter: 'center'
Expand Down
10 changes: 9 additions & 1 deletion packages/cf-component-text/test/__snapshots__/Text.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports[`should render align 1`] = `

exports[`should render bold size 1`] = `
<div
className="cf-z310y"
className="cf-e0qi9f"
>
Hello
</div>
Expand All @@ -32,6 +32,14 @@ exports[`should render normal size 1`] = `
</div>
`;

exports[`should render semi-bold size 1`] = `
<div
className="cf-z310y"
>
Hello
</div>
`;

exports[`should render small size 1`] = `
<div
className="cf-xk5sq7"
Expand Down

0 comments on commit f885ae8

Please sign in to comment.