|
@@ -2,59 +2,18 @@ import React from 'react';
|
|
|
import ReactDOM from 'react-dom';
|
|
import ReactDOM from 'react-dom';
|
|
|
import ReactMarkdown from 'react-markdown';
|
|
import ReactMarkdown from 'react-markdown';
|
|
|
import { Switch, Route, HashRouter, Link } from 'react-router-dom';
|
|
import { Switch, Route, HashRouter, Link } from 'react-router-dom';
|
|
|
-const markdown = require('./markdown.json');
|
|
|
|
|
-const intro = `
|
|
|
|
|
-Cette appli est un petit guide pour débuter en JavaScript, qui s'adresse à ceux
|
|
|
|
|
-qui connaissent déjà un autre langage - Java en l'occurence.
|
|
|
|
|
|
|
+import About from './components/About';
|
|
|
|
|
+import Home from './components/Home';
|
|
|
|
|
+import Navbar from './components/Navbar';
|
|
|
|
|
+import Page from './components/Page';
|
|
|
|
|
+const markdown = require('./resources/markdown.json');
|
|
|
|
|
|
|
|
-On va présenter les bases nécessaires pour interagir avec une page web, sans
|
|
|
|
|
-entrer dans les détails du langage.
|
|
|
|
|
-
|
|
|
|
|
-Précisons que le fait qu'il soit disponible sur tous les navigateurs et machines
|
|
|
|
|
-(ordinateurs, tablettes, smartphones), fait de JavaScript la plate-forme d'exécution
|
|
|
|
|
-de programmes **la plus répandue**.
|
|
|
|
|
-`;
|
|
|
|
|
-
|
|
|
|
|
-class Page extends React.Component {
|
|
|
|
|
- componentDidMount() {
|
|
|
|
|
- Prism.highlightAll();
|
|
|
|
|
- $('.page ul').addClass('browser-default');
|
|
|
|
|
- }
|
|
|
|
|
- render() {
|
|
|
|
|
- const { title, content } = this.props.page;
|
|
|
|
|
- const { section } = this.props;
|
|
|
|
|
- return (
|
|
|
|
|
- <div className="page">
|
|
|
|
|
- <div className="breadcrumb-wrapper">
|
|
|
|
|
- <Link to='/' className="breadcrumb light-blue-text"><i className="material-icons">home</i></Link>
|
|
|
|
|
- <Link to={section.path} className="breadcrumb light-blue-text">{section.title}</Link>
|
|
|
|
|
- <span className="breadcrumb grey-text">{title}</span>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <h4 className="header orange-text">{title}</h4>
|
|
|
|
|
- <ReactMarkdown source={content} escapeHtml={false} />
|
|
|
|
|
- </div>
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
|
|
+const $leftPanel = $('#left-panel');
|
|
|
|
|
+const $window = $(window);
|
|
|
|
|
+function onResize() {
|
|
|
|
|
+ $leftPanel.css('max-height', $window.height());
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-class Home extends React.Component {
|
|
|
|
|
- render() {
|
|
|
|
|
- return (
|
|
|
|
|
- <div>
|
|
|
|
|
- <div className="breadcrumb-wrapper">
|
|
|
|
|
- <span className="breadcrumb light-blue-text"><i className="material-icons">home</i></span>
|
|
|
|
|
- <span className="breadcrumb grey-text">Accueil</span>
|
|
|
|
|
- </div>
|
|
|
|
|
- <h4 className="header orange-text">Accueil</h4>
|
|
|
|
|
- <ReactMarkdown source={intro} />
|
|
|
|
|
- {getSectionLinks()}
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
|
|
+$window.on('resize', onResize);
|
|
|
|
|
|
|
|
function getSection(sectionIndex) {
|
|
function getSection(sectionIndex) {
|
|
|
const section = markdown[sectionIndex];
|
|
const section = markdown[sectionIndex];
|
|
@@ -119,16 +78,6 @@ function getSectionPageLinks(section) {
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function getSectionLinks() {
|
|
|
|
|
- return (
|
|
|
|
|
- <ul>
|
|
|
|
|
- {markdown.map((section, sIndex) => (
|
|
|
|
|
- <li key={sIndex}><Link to={section.path}>{section.title}</Link></li>
|
|
|
|
|
- ))}
|
|
|
|
|
- </ul>
|
|
|
|
|
- );
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
function getSectionRoutes(section, sIndex) {
|
|
function getSectionRoutes(section, sIndex) {
|
|
|
const routes = [{
|
|
const routes = [{
|
|
|
key: sIndex, path: section.path, component: getSection(sIndex)
|
|
key: sIndex, path: section.path, component: getSection(sIndex)
|
|
@@ -137,29 +86,23 @@ function getSectionRoutes(section, sIndex) {
|
|
|
path: section.path + page.path,
|
|
path: section.path + page.path,
|
|
|
component: getPage(sIndex, pIndex)
|
|
component: getPage(sIndex, pIndex)
|
|
|
})));
|
|
})));
|
|
|
- // return <Route key={sIndex} exact path={section.path} component={getSection(sIndex)} />;
|
|
|
|
|
return routes.map(r => <Route key={r.key} exact path={r.path} component={r.component} />);
|
|
return routes.map(r => <Route key={r.key} exact path={r.path} component={r.component} />);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(
|
|
ReactDOM.render(
|
|
|
<HashRouter>
|
|
<HashRouter>
|
|
|
- <div>
|
|
|
|
|
- {/*}<ul>{
|
|
|
|
|
- markdown.map((section, sIndex) => (
|
|
|
|
|
- <li key={sIndex}><Link to={section.path}>{section.title}</Link>
|
|
|
|
|
- {getSectionPageLinks(section)}
|
|
|
|
|
- </li>
|
|
|
|
|
- ))
|
|
|
|
|
- }
|
|
|
|
|
- <li><Link to="/">Home</Link></li>
|
|
|
|
|
- </ul>*/}
|
|
|
|
|
- <Switch>
|
|
|
|
|
- <Route exact path="/" component={Home} />
|
|
|
|
|
- {
|
|
|
|
|
- markdown.map(getSectionRoutes)
|
|
|
|
|
- }
|
|
|
|
|
- </Switch>
|
|
|
|
|
|
|
+ <div id="react-wrapper">
|
|
|
|
|
+ <Navbar />
|
|
|
|
|
+ <div className="main">
|
|
|
|
|
+ <Switch>
|
|
|
|
|
+ <Route exact path="/" component={Home} />
|
|
|
|
|
+ <Route exact path="/a-propos" component={About} />
|
|
|
|
|
+ {
|
|
|
|
|
+ markdown.map(getSectionRoutes)
|
|
|
|
|
+ }
|
|
|
|
|
+ </Switch>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
</HashRouter>,
|
|
</HashRouter>,
|
|
|
- document.getElementById('root')
|
|
|
|
|
|
|
+ document.getElementById('left-panel')
|
|
|
);
|
|
);
|