Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/trainyard/choodown

A simple markdown component for choo-js
https://github.com/trainyard/choodown

Last synced: 3 months ago
JSON representation

A simple markdown component for choo-js

Awesome Lists containing this project

README

        

[![built with choo v3](https://img.shields.io/badge/built%20with%20choo-v3-ffc3e4.svg?style=flat-square)](https://github.com/yoshuawuyts/choo)
[![npm version](https://badge.fury.io/js/choodown.svg)](https://badge.fury.io/js/choodown)
# Choodown

A simple markdown/textarea component with ability to preview your changes. Made for choo.

## How to use:

```
npm install choodown -S
```

Add the following to your app model:

```javascript
app.model({
namespace: 'choodown',
state: {
text: '',
mode: 'EDIT'
},
reducers: {
updateText: (data, state) => ({text: data}),
toggleMode: (mode, state) => ({mode: state.mode === 'PREVIEW' ? 'EDIT' : 'PREVIEW'})
}
});
```

Add to your view like this:

```javascript
const choodown = Choodown({
text: state.choodown.text,
mode: state.choodown.mode,
onChange: (e) => send('choodown:updateText', e.target.value),
onToggle: () => send('choodown:toggleMode')
});

return html`

Choodown demo


${choodown}
`
```

## Example

You can see a full working example by cloning this repo:

1. clone this repo
2. run `npm install`
3. run `npm start`
4. go to `localhost:8080`