Update packages + update Typography setup

This commit is contained in:
Kyle Mathews 2015-11-21 16:59:04 -08:00
parent 950e38687e
commit 1043f18f0c
6 changed files with 38 additions and 22 deletions

View file

@ -2,14 +2,12 @@ import React from 'react';
import { Link } from 'react-router'; import { Link } from 'react-router';
import { prune, include as includes } from 'underscore.string'; import { prune, include as includes } from 'underscore.string';
import find from 'lodash/collection/find'; import find from 'lodash/collection/find';
import { rhythm, fontSizeToMS } from 'utils/typography'
import { link } from 'gatsby-helpers'
export default class extends React.Component { export default class extends React.Component {
render() { render() {
let body, fontSizeToMS, html, nextPost, readNext, ref, rhythm; let body, html, nextPost, readNext;
ref = this.props.typography,
rhythm = ref.rhythm,
fontSizeToMS = ref.fontSizeToMS;
readNext = this.props.post.readNext; readNext = this.props.post.readNext;
if (readNext != null) { if (readNext != null) {
nextPost = find(this.props.pages, function(page) { nextPost = find(this.props.pages, function(page) {

View file

@ -20,13 +20,14 @@
}, },
"homepage": "https://github.com/gatsbyjs/gatsby-starter-blog#readme", "homepage": "https://github.com/gatsbyjs/gatsby-starter-blog#readme",
"dependencies": { "dependencies": {
"lodash": "^3.10.0", "lodash": "^3.10.1",
"moment": "^2.10.3", "moment": "^2.10.3",
"react": "^0.13.3", "react": "^0.14.3",
"react-document-title": "^1.0.2", "react-document-title": "^2.0.1",
"react-responsive-grid": "^0.2.0", "react-dom": "^0.14.3",
"react-router": "^0.13.3", "react-responsive-grid": "^0.2.1",
"typography": "^0.3.6", "react-router": "^0.13.5",
"underscore.string": "^3.1.1" "typography": "^0.6.2",
"underscore.string": "^3.2.2"
} }
} }

View file

@ -1,11 +1,8 @@
import React from 'react'; import React from 'react';
import { RouteHandler, Link } from 'react-router'; import { RouteHandler, Link } from 'react-router';
import { Container, Grid, Breakpoint, Span } from 'react-responsive-grid'; import { Container, Grid, Breakpoint, Span } from 'react-responsive-grid';
import Typography from 'typography';
import { link } from 'gatsby-helpers'; import { link } from 'gatsby-helpers';
import { rhythm, fontSizeToMS } from 'utils/typography'
let typography = new Typography();
let rhythm = typography.rhythm, fontSizeToMS = typography.fontSizeToMS;
import '../css/styles.css'; import '../css/styles.css';
@ -55,7 +52,7 @@ export default class extends React.Component {
}} }}
> >
{header} {header}
<RouteHandler typography={typography} {...this.props}/> <RouteHandler {...this.props}/>
</Container> </Container>
); );
} }

View file

@ -3,6 +3,7 @@ import { RouteHandler, Link } from 'react-router';
import sortBy from 'lodash/collection/sortBy'; import sortBy from 'lodash/collection/sortBy';
import DocumentTitle from 'react-document-title'; import DocumentTitle from 'react-document-title';
import { link } from 'gatsby-helpers'; import { link } from 'gatsby-helpers';
import { rhythm, fontSizeToMS } from 'utils/typography'
export default class extends React.Component { export default class extends React.Component {
static data() { static data() {
@ -11,8 +12,7 @@ export default class extends React.Component {
} }
} }
render() { render() {
let i, len, page, pageLinks, ref, ref1, ref2, rhythm, title; let i, len, page, pageLinks, ref, ref1, ref2, title;
rhythm = this.props.typography.rhythm;
pageLinks = []; pageLinks = [];
ref = sortBy(this.props.pages, (page) => { ref = sortBy(this.props.pages, (page) => {
let ref; let ref;

20
utils/typography.js Normal file
View file

@ -0,0 +1,20 @@
import Typography from 'typography';
const options = {
baseFontSize: '18px',
baseLineHeight: '27px',
modularScales: [
{
"scale": "minor third"
}
]
}
const typography = new Typography(options)
// Hot reload typography in development.
if (process.env.NODE_ENV !== "production") {
typography.injectStyles()
}
export default typography

View file

@ -3,13 +3,13 @@ import moment from 'moment';
import DocumentTitle from 'react-document-title'; import DocumentTitle from 'react-document-title';
import { link } from 'gatsby-helpers'; import { link } from 'gatsby-helpers';
import ReadNext from '../components/ReadNext'; import ReadNext from '../components/ReadNext';
import { rhythm, fontSizeToMS } from 'utils/typography'
import '../css/zenburn.css'; import '../css/zenburn.css';
module.exports = React.createClass({ module.exports = React.createClass({
render: function() { render: function() {
var post, rhythm; var post
rhythm = this.props.typography.rhythm;
post = this.props.page.data; post = this.props.page.data;
return ( return (