diff --git a/packages/gitbook-core/src/components/Link.js b/packages/gitbook-core/src/components/Link.js index 145486e0e..65f4eb524 100644 --- a/packages/gitbook-core/src/components/Link.js +++ b/packages/gitbook-core/src/components/Link.js @@ -28,7 +28,6 @@ const Link = React.createClass({ } href = currentFile.relative(href); - return {children}; } }); diff --git a/packages/gitbook-core/src/models/File.js b/packages/gitbook-core/src/models/File.js index 88138c3b5..3ec613053 100644 --- a/packages/gitbook-core/src/models/File.js +++ b/packages/gitbook-core/src/models/File.js @@ -32,12 +32,22 @@ class File extends Record(DEFAULTS) { ); } + /** + * Return true if file is an instance of File + * @param {Mixed} file + * @return {Boolean} + */ static is(file) { return (file instanceof File); } + /** + * Create a file instance + * @param {Mixed|File} file + * @return {File} + */ static create(file) { - return file instanceof File ? + return File.is(file) ? file : new File(file); } } diff --git a/packages/gitbook-core/src/models/Readme.js b/packages/gitbook-core/src/models/Readme.js new file mode 100644 index 000000000..f275ca296 --- /dev/null +++ b/packages/gitbook-core/src/models/Readme.js @@ -0,0 +1,21 @@ +const { Record } = require('immutable'); +const File = require('./File'); + +const DEFAULTS = { + file: new File() +}; + +class Readme extends Record(DEFAULTS) { + constructor(state = {}) { + super({ + file: File.create(state.file) + }); + } + + static create(state) { + return state instanceof Readme ? + state : new Readme(state); + } +} + +module.exports = Readme; diff --git a/packages/gitbook-core/src/reducers/readme.js b/packages/gitbook-core/src/reducers/readme.js index d88f9ec0a..9e8656a87 100644 --- a/packages/gitbook-core/src/reducers/readme.js +++ b/packages/gitbook-core/src/reducers/readme.js @@ -1,21 +1,5 @@ -const { Record } = require('immutable'); -const File = require('../models/file'); - -class ReadmeState extends Record({ - file: new File() -}) { - constructor(state = {}) { - super({ - file: new File(state.file) - }); - } - - static create(state) { - return state instanceof ReadmeState ? - state : new ReadmeState(state); - } -} +const Readme = require('../models/Readme'); module.exports = (state, action) => { - return ReadmeState.create(state); + return Readme.create(state); }; diff --git a/packages/gitbook-core/src/shapes/Readme.js b/packages/gitbook-core/src/shapes/Readme.js new file mode 100644 index 000000000..8414f05c2 --- /dev/null +++ b/packages/gitbook-core/src/shapes/Readme.js @@ -0,0 +1,11 @@ +const React = require('react'); + +const { + shape +} = React.PropTypes; + +const File = require('./File'); + +module.exports = shape({ + file: File.isRequired +}); diff --git a/packages/gitbook-core/src/shapes/index.js b/packages/gitbook-core/src/shapes/index.js index c372c259e..b019756c8 100644 --- a/packages/gitbook-core/src/shapes/index.js +++ b/packages/gitbook-core/src/shapes/index.js @@ -8,6 +8,7 @@ module.exports = { Context: require('./Context'), Page: require('./Page'), File: require('./File'), + Readme: require('./Readme'), Summary: require('./Summary'), SummaryPart: require('./SummaryPart'), SummaryArticle: require('./SummaryArticle') diff --git a/packages/gitbook-plugin-search/src/actions/search.js b/packages/gitbook-plugin-search/src/actions/search.js index 6cea419ee..861db8488 100644 --- a/packages/gitbook-plugin-search/src/actions/search.js +++ b/packages/gitbook-plugin-search/src/actions/search.js @@ -73,7 +73,6 @@ function handleQuery(q) { function refresh() { return (dispatch, getState) => { const q = getState().search.query; - console.log('refresh search with', q); if (q) { dispatch(handleQuery(q)); } diff --git a/packages/gitbook-plugin-theme-default/less/Toolbar.less b/packages/gitbook-plugin-theme-default/less/Toolbar.less index b396300de..8c59d96e7 100644 --- a/packages/gitbook-plugin-theme-default/less/Toolbar.less +++ b/packages/gitbook-plugin-theme-default/less/Toolbar.less @@ -1,3 +1,27 @@ .Toolbar { + .Toolbar-Title { + padding: 0px 20px; + margin: 0; + font-size: 20px; + font-weight: 200; + text-align: center; + line-height: 50px; + opacity: 0; + .transition(~"opacity ease .2s"); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + color: @button-hover-color; + a, a:hover { + text-decoration: none; + color: inherit; + } + } + + &:hover { + .Toolbar-Title { + opacity: 1; + } + } } diff --git a/packages/gitbook-plugin-theme-default/src/components/Body.js b/packages/gitbook-plugin-theme-default/src/components/Body.js index b4d9fe6d4..4f51f0faa 100644 --- a/packages/gitbook-plugin-theme-default/src/components/Body.js +++ b/packages/gitbook-plugin-theme-default/src/components/Body.js @@ -6,15 +6,16 @@ const Toolbar = require('./Toolbar'); const Body = React.createClass({ propTypes: { - page: GitBook.Shapes.Page + page: GitBook.Shapes.Page, + readme: GitBook.Shapes.Readme }, render() { - const { page } = this.props; + const { page, readme } = this.props; return (