Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a13d4f
commit b651fca
Showing
15 changed files
with
280 additions
and
178 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -22,6 +22,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
Oops, something went wrong.