Skip to content

Commit

Permalink
Fix terminology around scale/scale ratio + change function to 'scale'…
Browse files Browse the repository at this point in the history
… from 'adjustFontSizeToMS'
  • Loading branch information
KyleAMathews committed Sep 22, 2016
1 parent a97488f commit 3c1bc4c
Show file tree
Hide file tree
Showing 37 changed files with 132 additions and 122 deletions.
11 changes: 9 additions & 2 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
[version]
0.32.0

[ignore]
.*/website/.*
.*/test/.*
.*/www/.*
.*/node_modules/typography/.*
.*/node_modules/fbjs/.*
.*/node_modules/react-side-effect/.*

[include]
./*

[libs]

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ npm-debug*
examples/bundle.js
.gatsby-context.js
.idea/
www/public
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ When creating a new instance of Typography, you can pass in an
* **title**: The theme title.
* **baseFontSize**: The base font size in pixels, defaults to `16px`.
* **baseLineHeight**: The base line height using the css unitless number, defaults to `1.5`.
* **scale**: The "scale ratio" for the theme. This scale is the ratio
between the `h1` font size and the `baseFontSize`. So if the scale is `2`
* **scaleRatio**: The "scale ratio" for the theme. This value is the ratio
between the `h1` font size and the `baseFontSize`. So if the scale ratio is `2`
and the `baseFontSize` is `16px` then the `h1` font size is `32px`.
```javascript
{
scale: 2,
scaleRatio: 2,
}
```
* **googleFonts**: An array specifying Google Fonts for this project.
Expand Down
13 changes: 9 additions & 4 deletions Types.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
// @flow
type GoogleFontsType = {name: string; styles: string[]}
type VerticalRhythmType = {
rhythm: (value: number) => string,
scale: (value: number) => Object,
adjustFontSizeTo: (value?: number | string) => Object,
}

export type OptionsType = {
title: string,
baseFontSize?: string,
baseLineHeight?: number,
scale?: number,
scaleRatio?: number,
googleFonts?: GoogleFontsType[],
headerFontFamily?: string[],
bodyFontFamily?: string[],
Expand All @@ -16,15 +21,15 @@ export type OptionsType = {
headerWeight?: number | string,
bodyWeight?: number | string,
boldWeight?: number | string,
blockMarginBottom?: number | string,
blockMarginBottom?: number,
includeNormalize?: boolean,
overrideStyles?: (
verticalRhythm: mixed, // TODO Create flow type for compass-vertical-rhythm and import here.
verticalRhythm: VerticalRhythmType, // TODO Create flow type for compass-vertical-rhythm and import here.
options: OptionsType,
styles: mixed,
) => Object,
overrideThemeStyles?: (
verticalRhythm: mixed, // TODO Create flow type for compass-vertical-rhythm and import here.
verticalRhythm: VerticalRhythmType, // TODO Create flow type for compass-vertical-rhythm and import here.
options: OptionsType,
styles: mixed,
) => Object,
Expand Down
7 changes: 3 additions & 4 deletions docs/what.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,15 @@ font size will be `32px`. If you decide to change the scale ratio to
Typography.js, all sizes should be set using a scale value so all
non-base-font-size text can be resized together.

You can set custom font sizes using the `adjustFontSizeToMSValue`
function.
You can set custom font sizes using the `scale` function.

```javascript
import { adjustFontSizeToMSValue } from '../utils/typography'
import { scale } from '../utils/typography'

<div>
<h1
style={{
...adjustFontSizeToMSValue(1.5),
...scale(1.5),
}}
>
Hello world
Expand Down
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"devDependencies": {
"babel-cli": "^6.10.1",
"babel-cli": "^6.14.0",
"babel-eslint": "^6.1.2",
"babel-plugin-transform-flow-strip-types": "^6.8.0",
"babel-plugin-transform-flow-strip-types": "^6.14.0",
"babel-plugin-transform-object-rest-spread": "^6.8.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-es2015": "^6.14.0",
"babel-preset-stage-0": "^6.5.0",
"eslint": "^3.0.1",
"eslint-config-airbnb": "^9.0.1",
"eslint-plugin-flow-vars": "^0.4.0",
"eslint-plugin-import": "^1.10.2",
"eslint-plugin-jsx-a11y": "^2.0.1",
"eslint-plugin-react": "^5.2.2",
"flow-bin": "^0.28.0",
"glob": "^7.0.5",
"eslint": "^3.5.0",
"eslint-config-airbnb": "^11.1.0",
"eslint-plugin-flow-vars": "^0.5.0",
"eslint-plugin-import": "^1.15.0",
"eslint-plugin-jsx-a11y": "^2.2.2",
"eslint-plugin-react": "^6.3.0",
"flow-bin": "^0.32.0",
"glob": "^7.1.0",
"json2md": "^1.5.2",
"lerna": "^2.0.0-beta.24",
"lodash": "^4.13.1",
"lodash": "^4.16.1",
"phantom": "^2.1.12",
"phantomjs-prebuilt": "^2.1.7"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/typography-design-tools/src/DesignTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ class DesignTool extends React.Component {
<SectionRow>
<ModularScaleTool
key='scale'
scale={this.state.options.scale}
scaleRatio={this.state.options.scaleRatio}
onChange={(newScale) => {
const newOptions = { ...this.state.options }
newOptions.scale = newScale
newOptions.scaleRatio = newScale
this.setState({ options: newOptions })
}}
/>
Expand Down
6 changes: 3 additions & 3 deletions packages/typography-design-tools/src/ModularScaleTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ class ModularScale extends React.Component {
render () {
return (
<SectionTool
title="Scale"
title="Scale Ratio"
>
<NumberEditor
unit="scale"
value={msToRatio(this.props.scale)}
unit="ratio"
value={msToRatio(this.props.scaleRatio)}
min={1}
max={6}
step={0.1}
Expand Down
4 changes: 2 additions & 2 deletions packages/typography-theme-alton/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const theme: OptionsType = {
headerWeight: 700,
bodyWeight: 400,
boldWeight: 700,
overrideStyles: ({ adjustFontSizeTo, adjustFontSizeToMSValue, rhythm }, options) => {
overrideStyles: ({ adjustFontSizeTo, scale, rhythm }, options) => {
const vr = verticalRhythm({
baseFontSize: '16px',
baseLineHeight: '28.44px',
Expand All @@ -47,7 +47,7 @@ const theme: OptionsType = {
color: gray(options.bodyGray),
},
blockquote: {
...adjustFontSizeToMSValue(1/5),
...scale(1/5),
color: gray(41),
fontStyle: 'italic',
paddingLeft: rhythm(13/16),
Expand Down
16 changes: 8 additions & 8 deletions packages/typography-theme-bootstrap/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ const theme: OptionsType = {
bodyWeight: 400,
headerWeight: 500,
boldWeight: 'bold',
overrideStyles: ({ adjustFontSizeTo, adjustFontSizeToMSValue, rhythm }, options) => ({
overrideStyles: ({ adjustFontSizeTo, scale, rhythm }, options) => ({
body: {
color: gray(23, 204),
},
h1: adjustFontSizeToMSValue(4/4),
h2: adjustFontSizeToMSValue(3/4),
h3: adjustFontSizeToMSValue(2/4),
h4: adjustFontSizeToMSValue(1/6),
h5: adjustFontSizeToMSValue(-1/6),
h6: adjustFontSizeToMSValue(-2/6),
h1: scale(4/4),
h2: scale(3/4),
h3: scale(2/4),
h4: scale(1/6),
h5: scale(-1/6),
h6: scale(-2/6),
blockquote: {
...adjustFontSizeToMSValue(1/4),
...scale(1/4),
borderLeft: `${rhythm(1/6)} solid #eceeef`,
paddingTop: rhythm(1/3),
paddingBottom: rhythm(1/3),
Expand Down
2 changes: 1 addition & 1 deletion packages/typography-theme-de-young/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const theme: OptionsType = {
headerWeight: 500,
bodyWeight: 400,
boldWeight: 700,
overrideStyles: ({ adjustFontSizeTo, adjustFontSizeToMSValue, rhythm }, options) => {
overrideStyles: ({ rhythm }) => {
const vr = verticalRhythm({
baseFontSize: '18px',
baseLineHeight: '29.7px',
Expand Down
5 changes: 2 additions & 3 deletions packages/typography-theme-doelger/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const theme: OptionsType = {
headerWeight: '700',
bodyWeight: 400,
boldWeight: 700,
overrideStyles: ({ adjustFontSizeTo, adjustFontSizeToMSValue, rhythm }, options) => {
overrideStyles: ({ adjustFontSizeTo, scale, rhythm }, options) => {
const linkColor = '#ff483b'
return {
a: {
Expand All @@ -49,7 +49,7 @@ const theme: OptionsType = {
},
// Blockquote styles.
blockquote: {
...adjustFontSizeToMSValue(1/5),
...scale(1/5),
borderLeft: `${rhythm(6/16)} solid ${linkColor}`,
color: gray(35),
paddingLeft: rhythm(10/16),
Expand Down Expand Up @@ -83,4 +83,3 @@ const theme: OptionsType = {
}

export default theme

4 changes: 2 additions & 2 deletions packages/typography-theme-elk-glen/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const theme: OptionsType = {
headerWeight: '700',
bodyWeight: 400,
boldWeight: 700,
overrideStyles: ({ adjustFontSizeTo, adjustFontSizeToMSValue, rhythm }, options) => {
overrideStyles: ({ adjustFontSizeTo, scale, rhythm }, options) => {
const linkColor = '#292d35'
const vr = verticalRhythm({
baseFontSize: '17px',
Expand All @@ -53,7 +53,7 @@ const theme: OptionsType = {
},
// Blockquote styles.
blockquote: {
...adjustFontSizeToMSValue(1/5),
...scale(1/5),
borderLeft: `${rhythm(6/16)} solid ${linkColor}`,
color: gray(35),
paddingLeft: rhythm(10/16),
Expand Down
4 changes: 2 additions & 2 deletions packages/typography-theme-fairy-gates/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const theme: OptionsType = {
headerWeight: '600',
bodyWeight: 400,
boldWeight: 700,
overrideStyles: ({ adjustFontSizeTo, adjustFontSizeToMSValue, rhythm }, options) => {
overrideStyles: ({ adjustFontSizeTo, scale, rhythm }, options) => {
const linkColor = '#1ca086'
const vr = verticalRhythm({
baseFontSize: '17px',
Expand All @@ -54,7 +54,7 @@ const theme: OptionsType = {
},
// Blockquote styles.
blockquote: {
...adjustFontSizeToMSValue(1/5),
...scale(1/5),
borderLeft: `${rhythm(6/16)} solid ${linkColor}`,
color: gray(35),
paddingLeft: rhythm(10/16),
Expand Down
4 changes: 2 additions & 2 deletions packages/typography-theme-funston/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const theme: OptionsType = {
headerWeight: '400',
bodyWeight: 400,
boldWeight: 700,
overrideStyles: ({ adjustFontSizeTo, adjustFontSizeToMSValue, rhythm }, options) => ({
overrideStyles: ({ adjustFontSizeTo, scale, rhythm }, options) => ({
html: {
'-webkit-font-smoothing': 'antialiased',
},
Expand All @@ -43,7 +43,7 @@ const theme: OptionsType = {
color: '#3498DB',
},
blockquote: {
...adjustFontSizeToMSValue(1/5),
...scale(1/5),
color: gray(40),
paddingLeft: rhythm(13/16),
marginLeft: rhythm(-1),
Expand Down
4 changes: 2 additions & 2 deletions packages/typography-theme-grand-view/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const theme: OptionsType = {
headerWeight: 700,
bodyWeight: 400,
boldWeight: 700,
overrideStyles: ({ adjustFontSizeTo, adjustFontSizeToMSValue, rhythm }, options) => ({
overrideStyles: ({ adjustFontSizeTo, scale, rhythm }, options) => ({
a: {
color: '#d65947',
textDecoration: 'none',
Expand All @@ -42,7 +42,7 @@ const theme: OptionsType = {
marginTop: rhythm(2),
},
blockquote: {
...adjustFontSizeToMSValue(1/5),
...scale(1/5),
color: gray(41),
paddingLeft: rhythm(13/16),
marginLeft: 0,
Expand Down
6 changes: 3 additions & 3 deletions packages/typography-theme-irving/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const theme: OptionsType = {
headerWeight: 700,
bodyWeight: 400,
boldWeight: 700,
overrideStyles: ({ adjustFontSizeTo, adjustFontSizeToMSValue, rhythm }, options) => {
overrideStyles: ({ adjustFontSizeTo, scale, rhythm }, options) => {
const styles = {
a: {
color: gray(options.bodyGray),
Expand All @@ -39,7 +39,7 @@ const theme: OptionsType = {
color: '#3498DB',
},
blockquote: {
...adjustFontSizeToMSValue(1/5),
...scale(1/5),
color: gray(30),
paddingLeft: rhythm(3/4),
marginLeft: 0,
Expand All @@ -50,7 +50,7 @@ const theme: OptionsType = {
marginBottom: rhythm(1/2),
},
table: {
...adjustFontSizeToMSValue(-1/5),
...scale(-1/5),
},
// Mobile styles.
[TABLET_MEDIA_QUERY]: {
Expand Down
4 changes: 2 additions & 2 deletions packages/typography-theme-judah/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const theme: OptionsType = {
headerWeight: 400,
bodyWeight: 400,
boldWeight: 700,
overrideStyles: ({ adjustFontSizeTo, adjustFontSizeToMSValue, rhythm }, options) => ({
overrideStyles: ({ adjustFontSizeTo, scale, rhythm }, options) => ({
a: {
color: '#e51937',
textDecoration: 'none',
Expand All @@ -41,7 +41,7 @@ const theme: OptionsType = {
textDecoration: 'none',
},
blockquote: {
...adjustFontSizeToMSValue(1/5),
...scale(1/5),
color: gray(0),
fontStyle: 'italic',
paddingLeft: rhythm(13/16),
Expand Down
4 changes: 2 additions & 2 deletions packages/typography-theme-kirkham/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ const theme: OptionsType = {
headerWeight: 700,
bodyWeight: 400,
boldWeight: 700,
overrideStyles: ({ adjustFontSizeTo, adjustFontSizeToMSValue, rhythm }, options) => ({
overrideStyles: ({ adjustFontSizeTo, scale, rhythm }, options) => ({
a: {
color: '#9f392b',
},
blockquote: {
...adjustFontSizeToMSValue(1/5),
...scale(1/5),
color: gray(41),
fontStyle: 'italic',
paddingLeft: rhythm(13/16),
Expand Down
4 changes: 2 additions & 2 deletions packages/typography-theme-lincoln/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const theme: OptionsType = {
headerWeight: '400',
bodyWeight: 400,
boldWeight: 700,
overrideStyles: ({ adjustFontSizeTo, adjustFontSizeToMSValue, rhythm }, options) => {
overrideStyles: ({ adjustFontSizeTo, scale, rhythm }, options) => {
const linkColor = '#134896'
const vr = verticalRhythm({
baseFontSize: '17px',
Expand Down Expand Up @@ -59,7 +59,7 @@ const theme: OptionsType = {
},
// Blockquote styles.
blockquote: {
...adjustFontSizeToMSValue(1/5),
...scale(1/5),
borderLeft: `${rhythm(6/16)} solid ${linkColor}`,
color: gray(35),
paddingLeft: rhythm(10/16),
Expand Down

0 comments on commit 3c1bc4c

Please sign in to comment.