1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-18 22:24:38 +01:00
slate/examples/index.js

126 lines
2.5 KiB
JavaScript
Raw Normal View History

2016-06-24 10:22:48 -07:00
import React from 'react'
import ReactDOM from 'react-dom'
import { Router, Route, Link, IndexRedirect, hashHistory } from 'react-router'
/**
* Examples.
*/
import AutoMarkdown from './auto-markdown'
import CodeHighlighting from './code-highlighting'
2016-06-28 15:47:29 -07:00
import HoveringMenu from './hovering-menu'
2016-06-28 18:26:56 -07:00
import Images from './images'
2016-06-24 10:22:48 -07:00
import Links from './links'
import PasteHtml from './paste-html'
2016-06-24 10:22:48 -07:00
import PlainText from './plain-text'
2016-07-17 15:57:27 -07:00
import ReadOnly from './read-only'
2016-06-24 10:22:48 -07:00
import RichText from './rich-text'
import Tables from './tables'
import DevPerformancePlain from './development/performance-plain'
import DevPerformanceRich from './development/performance-rich'
2016-06-24 10:22:48 -07:00
2016-07-12 22:26:57 -07:00
/**
* Perf.
*/
import Perf from 'react-addons-perf'
window.Perf = Perf
2016-06-24 10:22:48 -07:00
/**
* Define our example app.
*
* @type {Component} App
*/
class App extends React.Component {
/**
* Render the example app.
*
* @return {Element} element
*/
render() {
return (
<div className="app">
2016-06-24 10:22:48 -07:00
{this.renderTabBar()}
{this.renderExample()}
</div>
)
}
/**
* Render the tab bar.
*
* @return {Element} element
*/
renderTabBar() {
return (
<div className="tabs">
{this.renderTab('Rich Text', 'rich-text')}
{this.renderTab('Plain Text', 'plain-text')}
{this.renderTab('Auto-markdown', 'auto-markdown')}
{this.renderTab('Hovering Menu', 'hovering-menu')}
{this.renderTab('Links', 'links')}
{this.renderTab('Images', 'images')}
{this.renderTab('Tables', 'tables')}
{this.renderTab('Code Highlighting', 'code-highlighting')}
{this.renderTab('Paste HTML', 'paste-html')}
2016-07-17 15:57:27 -07:00
{this.renderTab('Read Only', 'read-only')}
2016-06-24 10:22:48 -07:00
</div>
)
}
/**
* Render a tab with `name` and `slug`.
*
* @param {String} name
* @param {String} slug
*/
renderTab(name, slug) {
return (
<Link className="tab" activeClassName="active" to={slug}>{name}</Link>
)
}
2016-06-24 10:22:48 -07:00
/**
* Render the example.
*
* @return {Element} element
*/
renderExample() {
return (
<div className="example">
{this.props.children}
</div>
)
}
}
/**
* Router.
*
* @type {Element} router
*/
const router = (
<Router history={hashHistory}>
<Route path="/" component={App}>
<Route path="auto-markdown" component={AutoMarkdown} />
</Route>
</Router>
)
/**
* Mount the router.
*/
const root = document.body.querySelector('main')
ReactDOM.render(router, root)