-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Amélioration des performances (#400)
* Amélioration des performances * Diminue le throttle
- Loading branch information
1 parent
441d11f
commit 31c0b69
Showing
14 changed files
with
273 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,6 @@ module.exports = { | |
'@snowpack/plugin-react-refresh', | ||
], | ||
devOptions: { | ||
port: 3000, | ||
port: 3000 | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,35 @@ | ||
import React, { useState } from 'react' | ||
|
||
import { ChevronDown, ChevronRight, Bookmark } from 'react-feather' | ||
import { ChevronDown, ChevronRight } from 'react-feather' | ||
|
||
import styles from './sommaire.module.scss' | ||
import menuStyles from './menu.module.scss' | ||
import { connect } from 'react-redux' | ||
|
||
export default function Sommaire (props) { | ||
const [expand, setExpand] = useState(true) | ||
// eslint-disable-next-line | ||
const lines = props.md | ||
.split('\n') | ||
.map((l, i) => { | ||
return { line: i, payload: l } | ||
}) | ||
.filter((l) => l.payload.match(/^##+\ /)) | ||
const mapStateToProps = ({ articleStructure }) => ({ articleStructure }) | ||
|
||
//arrow backspace \u21B3 | ||
// right arrow \u2192 | ||
// nbsp \xa0 | ||
// down arrow \u2223 | ||
// right tack \u22A2 | ||
// bottom left box drawing \u2514 | ||
// left drawing \u2502 | ||
//23B8 | ||
function Sommaire (props) { | ||
const [expand, setExpand] = useState(true) | ||
const { articleStructure } = props | ||
|
||
return ( | ||
<section className={[styles.section, menuStyles.section].join(' ')}> | ||
<h1 onClick={() => setExpand(!expand)}> | ||
{expand ? <ChevronDown/> : <ChevronRight/>} Table of contents | ||
</h1> | ||
{expand && (<ul> | ||
{lines.map((l) => ( | ||
{articleStructure.map((item) => ( | ||
<li | ||
className={styles.headlineItem} | ||
key={`line-${l.line}-${l.payload}`} | ||
onClick={() => props.setCodeMirrorCursor(l.line)} | ||
key={`line-${item.index}-${item.line}`} | ||
onClick={() => props.setCodeMirrorCursor(item.index)} | ||
> | ||
{l.payload | ||
.replace(/##/, '') | ||
.replace(/#\s/g, '\u21B3') | ||
.replace(/#/g, '\u00B7\xa0')} | ||
{item.title} | ||
</li> | ||
))} | ||
</ul>)} | ||
</section> | ||
) | ||
} | ||
|
||
export default connect(mapStateToProps)(Sommaire) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.