-
Notifications
You must be signed in to change notification settings - Fork 833
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c86c088
commit 8c3e111
Showing
22 changed files
with
514 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "evergreen-typography", | ||
"version": "1.0.0", | ||
"description": "React components: Text, Paragraph, Heading, Code, Pre, Label, Small, Strong", | ||
"main": "lib/index.js", | ||
"keywords": [ | ||
"evergreen", | ||
"segment", | ||
"ui", | ||
"react", | ||
"Text", | ||
"Paragraph", | ||
"Heading", | ||
"Code", | ||
"Pre", | ||
"Label", | ||
"Small", | ||
"Strong" | ||
], | ||
"author": "Segment", | ||
"license": "MIT", | ||
"peerDependencies": { | ||
"prop-types": "^15.0.0", | ||
"react": "^0.14.0 || ^15.0.0" | ||
}, | ||
"dependencies": { | ||
"ui-box": "^0.3.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React, { PureComponent } from 'react' | ||
import Text from './Text' | ||
|
||
export default class Pre extends PureComponent { | ||
static defaultProps = { | ||
is: 'code', | ||
fontFamily: 'mono', | ||
} | ||
|
||
render() { | ||
return <Text {...this.props} /> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React, { PureComponent } from 'react' | ||
import Text from './Text' | ||
|
||
export default class Heading extends PureComponent { | ||
static defaultProps = { | ||
is: 'h2', | ||
color: 'dark', | ||
fontFamily: 'display', | ||
marginTop: 0, | ||
marginBottom: '1em', | ||
textStyleTransformation: ({ fontWeight, ...textStyle }) => ({ | ||
...textStyle, | ||
fontWeight: fontWeight + 100, | ||
}), | ||
} | ||
|
||
render() { | ||
return <Text {...this.props} /> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React, { PureComponent } from 'react' | ||
import Text from './Text' | ||
|
||
export default class Label extends PureComponent { | ||
static defaultProps = { | ||
is: 'label', | ||
} | ||
|
||
render() { | ||
return <Text {...this.props} /> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React, { PureComponent } from 'react' | ||
import Text from './Text' | ||
|
||
export default class Paragraph extends PureComponent { | ||
static defaultProps = { | ||
is: 'p', | ||
marginTop: 0, | ||
marginBottom: '1em', | ||
textStyleTransformation: ({ lineHeight, ...textStyle }) => ({ | ||
...textStyle, | ||
// Multiply line height by 1.1 | ||
lineHeight: `${Math.round(parseFloat(lineHeight, 10) * 1.1)}px`, | ||
}), | ||
} | ||
|
||
render() { | ||
return <Text {...this.props} /> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React, { PureComponent } from 'react' | ||
import Text from './Text' | ||
|
||
export default class Pre extends PureComponent { | ||
static defaultProps = { | ||
is: 'pre', | ||
fontFamily: 'mono', | ||
marginTop: 0, | ||
marginBottom: 'standard', | ||
} | ||
|
||
render() { | ||
return <Text {...this.props} /> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React, { PureComponent } from 'react' | ||
import Text from './Text' | ||
|
||
export default class Small extends PureComponent { | ||
static defaultProps = { | ||
is: 'small', | ||
textStyleTransformation: ({ fontSize, ...textStyle }) => ({ | ||
...textStyle, | ||
fontSize: `${Math.round(parseInt(fontSize, 10) * 0.8)}px`, | ||
}), | ||
} | ||
|
||
render() { | ||
return <Text {...this.props} /> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React, { PureComponent } from 'react' | ||
import Text from './Text' | ||
|
||
export default class Strong extends PureComponent { | ||
static defaultProps = { | ||
is: 'strong', | ||
fontWeight: 600, | ||
} | ||
|
||
render() { | ||
return <Text {...this.props} /> | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
packages/evergreen-typography/src/components/SubHeading.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React, { PureComponent } from 'react' | ||
import Text from './Text' | ||
|
||
export default class SubHeading extends PureComponent { | ||
static defaultProps = { | ||
is: 'h3', | ||
color: 'dark', | ||
fontFamily: 'display', | ||
marginTop: 0, | ||
marginBottom: '1em', | ||
textStyleTransformation: ({ fontWeight, ...textStyle }) => ({ | ||
...textStyle, | ||
fontWeight: fontWeight - 100, | ||
}), | ||
} | ||
|
||
render() { | ||
return <Text {...this.props} /> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React, { PureComponent } from 'react' | ||
import PropTypes from 'prop-types' | ||
import Box from 'ui-box' | ||
import FontFamilies from '../styles/font-families' | ||
import TextStyles from '../styles/text-styles' | ||
import TextColors from '../styles/text-colors' | ||
|
||
export default class Text extends PureComponent { | ||
static propTypes = { | ||
size: PropTypes.oneOf(Object.keys(TextStyles).map(Number)).isRequired, | ||
color: PropTypes.string, | ||
fontFamily: PropTypes.oneOf(Object.keys(FontFamilies)).isRequired, | ||
textStyleTransformation: PropTypes.func.isRequired, | ||
} | ||
|
||
static defaultProps = { | ||
is: 'span', | ||
size: 500, | ||
color: 'default', | ||
fontFamily: 'ui', | ||
textStyleTransformation: textStyle => textStyle, | ||
} | ||
|
||
render() { | ||
const { | ||
size, | ||
color, | ||
fontFamily, | ||
textStyleTransformation, | ||
...props | ||
} = this.props | ||
return ( | ||
<Box | ||
color={TextColors[color] || color} | ||
fontFamily={FontFamilies[fontFamily] || fontFamily} | ||
{...textStyleTransformation(TextStyles[size])} | ||
{...props} | ||
/> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export { default as Text } from './components/Text' | ||
export { default as Paragraph } from './components/Paragraph' | ||
export { default as Heading } from './components/Heading' | ||
export { default as SubHeading } from './components/SubHeading' | ||
export { default as Code } from './components/Code' | ||
export { default as Pre } from './components/Pre' | ||
export { default as Label } from './components/Label' | ||
export { default as Small } from './components/Small' | ||
export { default as Strong } from './components/Strong' | ||
export { default as TextStyles } from './styles/text-styles' | ||
export { default as FontFamilies } from './styles/font-families' | ||
export { default as TextColors } from './styles/text-colors' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default { | ||
display: `"SF UI Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"`, | ||
ui: `"SF UI Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"`, | ||
mono: `"SF Mono", "Monaco", "Inconsolata", "Fira Mono", "Droid Sans Mono", "Source Code Pro", monospace`, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import colors from 'evergreen-colors' | ||
|
||
export default { | ||
dark: colors.neutral['800'], | ||
default: colors.neutral['500'], | ||
muted: colors.neutral['300A'], | ||
extraMuted: colors.neutral['200A'], | ||
white: colors.white['500'], | ||
whiteMuted: colors.white['300A'], | ||
whiteExtraMuted: colors.white['200A'], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
export default { | ||
'800': { | ||
fontSize: '29px', | ||
fontWeight: 400, | ||
lineHeight: '32px', | ||
letterSpacing: '-0.2px', | ||
}, | ||
'700': { | ||
fontSize: '28px', | ||
fontWeight: 400, | ||
lineHeight: '28px', | ||
letterSpacing: '-0.2px', | ||
}, | ||
'600': { | ||
fontSize: '20px', | ||
fontWeight: 400, | ||
lineHeight: '24px', | ||
letterSpacing: '-0.05px', | ||
}, | ||
'500': { | ||
fontSize: '16px', | ||
fontWeight: 400, | ||
lineHeight: '24px', | ||
letterSpacing: '-0.05px', | ||
}, | ||
'400': { | ||
fontSize: '14px', | ||
fontWeight: 400, | ||
lineHeight: '22px', | ||
letterSpacing: '-0.05px', | ||
}, | ||
'300': { | ||
fontSize: '12px', | ||
fontWeight: 400, | ||
lineHeight: '16px', | ||
letterSpacing: '0', | ||
}, | ||
'200': { | ||
fontSize: '11px', | ||
fontWeight: 400, | ||
lineHeight: '16px', | ||
letterSpacing: '0.3px', | ||
textTransform: 'uppercase', | ||
}, | ||
'100': { | ||
fontSize: '10px', | ||
fontWeight: 400, | ||
lineHeight: '16px', | ||
letterSpacing: '0.3px', | ||
textTransform: 'uppercase', | ||
}, | ||
} |
Oops, something went wrong.