Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ import { P, divider } from './component/elements.jsx'
import { Router } from './lib/router.js'
import { Profile } from './page/profile.jsx'
import { Home } from './page/home.jsx'
import { Exercise } from './page/exercise.jsx'

const App = () => (
<>
<Header />
<Router>
<Profile path="/profile" />
<Home path="*" />
<Exercise path="/exercise" />
</Router>
<footer>
{divider}
Expand Down
83 changes: 83 additions & 0 deletions component/markdown.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { Span, Color, P, Div, Link } from './elements.jsx'
import { css } from '../lib/dom.js'

css(`
li.mli {
display:block;
}

div.warn{
outline:1px dashed red;
padding:0.8rem;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

padding en rem ca va pas gerer que l'allignement reste sur la grille de characters monospace (mode text quoi)

}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

je pense qu'il faut eviter les noms de class css trop generique si elle ne sont pas scoper dans une classe parente plus specifique.


`)

export const MTitle = Object.fromEntries(
['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].map((el) => [
el,
({ children, ...props }) =>
h(
el,
props,
<>
<Span fg="red">{'#'.repeat(Number(el.slice(1)))}</Span>&nbsp;
</>,
children,
),
]),
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tu peu pre-compute une partie du code:

export const MTitle = Object.fromEntries(
  ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].map((el) => {
    const decoration = <Span fg="red">{'#'.repeat(Number(el.slice(1)))}</Span>
    return [el, ({ children, ...props }) => h(el, props, decoration, children)]
  }),
)

Mais je pense que c'est encore mieu de le generer en css directement, comme c'est fait ici: https://github.com/egoist/hack/blob/master/src/css/markdown.css#L91-L105


const NavLink = (props) => (
<li>
{' '}
- <Link {...props} />
</li>
)

export const MItalicWord = ({ children, color, type }) => {
return (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useless return, I do think a lot of this could be achieve with a class and :before :after elements too

<P>
<Color.Orange>{'>'}</Color.Orange>
<Color.CommentLighter>*</Color.CommentLighter>
<Span fg={color} style={{ fontStyle: 'italic' }}>
{children}
</Span>
<Color.CommentLighter>*</Color.CommentLighter>
{type === 'ps' && <Color.Orange>{'<'}</Color.Orange>}
</P>
)
}

const Text = ({ text, link, ...props }) => {
const Colorize = link ? Color.CyanDarker : Color.CommentLighter
return <Colorize {...props}>{link ? `[${text}]` : `\`${text}\``}</Colorize>
}

export const MLi = ({ children }) => {
return (
<li>
<Span fg="orange"> - </Span>
<Text
text={children}
style={{
padding: '0.1rem',
background: 'rgba(75, 75, 75, 0.63)',
}}
/>
</li>
)
}

export const MLink = ({ children, link }) => {
return (
<NavLink class="mli" href={link}>
<Span fg="orange"> - </Span>
<Text text={children} link style={{ padding: '0.1rem' }} />
</NavLink>
)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

je suis pas convaincu de ce MLi, tu devrais le decouper en 3 components:

  • Les LI
  • Les Liens
  • Le text

et eviter un truc aussi specifique


export const Warning = ({ children }) => {
return <Div class="warn">{children}</Div>
}
6 changes: 0 additions & 6 deletions data/fakeExercise.json

This file was deleted.

37 changes: 37 additions & 0 deletions markdown.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
h1.mark:before {
display:"inine-block";
color: red;
content:"#"
}

h2.mark:before {
display:"inine-block";
color: red;
content:"##"
}


h3.mark:before {
display:"inine-block";
color: red;
content:"###"
}

h4.mark:before {
display:"inine-block";
color: red;
content:"####"
}


h5.mark:before {
display:"inine-block";
color: red;
content:"#####"
}

h6.mark:before {
display:"inine-block";
color: red;
content:"######"
}
134 changes: 0 additions & 134 deletions page/exercise.jsx

This file was deleted.