-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App for Mithril #3244
Merged
Merged
App for Mithril #3244
Changes from 16 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
0c1c2dd
create app/mithril by copying app/react
sixmen aa2eb52
implement Mithril app
sixmen 33edc20
add Mithril support to addon-knobs
sixmen 3e050ac
add Mithril support to addon-background
sixmen 5c9a26c
add Mithril support in CLI
sixmen ff8a14a
add Mithril support to addon-centered
sixmen 3948142
add Mithril kitchen sink
sixmen 424c01f
fix test
sixmen 6b9a073
remove demo components from Mithril app
sixmen 9e50f6e
remove unused code
sixmen cf0c198
Add documentation for Mithril app & addons
sixmen 5a1627d
build Mithril kitchen-sink in CircleCI
sixmen b32418f
add Mithril demo components for CLI
sixmen df62729
fix build mithril-kitchen-sink
sixmen d5eaf71
Add guide documents for Mithril
sixmen 682c899
Add netlify build for Mithril
sixmen 56ea9d9
Merge branch 'master' into app-mithril-3.4.0-rc.3
igor-dv 538a2bf
mark Mithril app as alpha
sixmen 78ec915
Remove addon dependency from demo component
sixmen 576b3bc
Merge branch 'master' into app-mithril-3.4.0-rc.3
ndelangen f8818e4
Merge branch 'master' into app-mithril-3.4.0-rc.3
danielduan 2c658b8
update Mithril app for Webpack 4
sixmen 56d2320
Apply startup code change to the Mithril app
sixmen 414b84c
update Mithril kitchen sink for Webpack 4
sixmen d839afd
update yarn.lock
sixmen a0773c7
Merge branch 'master' into app-mithril-3.4.0-rc.3
Hypnosphi fab5d35
Merge remote-tracking branch 'origin/master' into app-mithril-3.4.0-rc.3
Hypnosphi 4eeda3d
Update common deps
Hypnosphi ff22716
Add mithril acceptance story
Hypnosphi 26222a7
Update live examples
Hypnosphi 36379bb
Update storyshot
Hypnosphi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,19 +1,19 @@ | ||
## Addon / Framework Support Table | ||
|
||
| |[React](app/react)|[React Native](app/react-native)|[Vue](app/vue)|[Angular](app/angular)| [Polymer](app/polymer)| | ||
| ----------- |:-------:|:-------:|:-------:|:-------:|:-------:| | ||
|[a11y](addons/a11y) |+| | | | | | ||
|[actions](addons/actions) |+|+|+|+|+| | ||
|[background](addons/background) |+| | | | | | ||
|[centered](addons/centered) |+| |+| | | | ||
|[events](addons/events) |+| | | | | | ||
|[graphql](addons/graphql) |+| | | | | | ||
|[info](addons/info) |+| | | | | | ||
|[jest](addons/jest) |+| | | | | | ||
|[knobs](addons/knobs) |+|+|+|+|+| | ||
|[links](addons/links) |+|+|+|+|+| | ||
|[notes](addons/notes) |+| |+|+|+| | ||
|[options](addons/options) |+|+|+|+|+| | ||
|[storyshots](addons/storyshots) |+|+|+|+| | | ||
|[storysource](addons/storysource)|+| |+|+|+| | ||
|[viewport](addons/viewport) |+| |+|+|+| | ||
| |[React](app/react)|[React Native](app/react-native)|[Vue](app/vue)|[Angular](app/angular)| [Polymer](app/polymer)| [Mithril](app/mithril)| | ||
| ----------- |:-------:|:-------:|:-------:|:-------:|:-------:|:-------:| | ||
|[a11y](addons/a11y) |+| | | | | | | ||
|[actions](addons/actions) |+|+|+|+|+|+| | ||
|[background](addons/background) |+| | | | |+| | ||
|[centered](addons/centered) |+| |+| | |+| | ||
|[events](addons/events) |+| | | | | | | ||
|[graphql](addons/graphql) |+| | | | | | | ||
|[info](addons/info) |+| | | | | | | ||
|[jest](addons/jest) |+| | | | | | | ||
|[knobs](addons/knobs) |+|+|+|+|+|+| | ||
|[links](addons/links) |+|+|+|+|+|+| | ||
|[notes](addons/notes) |+| |+|+|+|+| | ||
|[options](addons/options) |+|+|+|+|+|+| | ||
|[storyshots](addons/storyshots) |+|+|+|+| | | | ||
|[storysource](addons/storysource)|+| |+|+|+|+| | ||
|[viewport](addons/viewport) |+| |+|+|+|+| |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./dist/mithril'); |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** @jsx m */ | ||
|
||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import m from 'mithril'; | ||
|
||
import addons from '@storybook/addons'; | ||
|
||
export class BackgroundDecorator { | ||
constructor(vnode) { | ||
this.props = vnode.attrs; | ||
|
||
const { channel, story } = vnode.attrs; | ||
|
||
// A channel is explicitly passed in for testing | ||
if (channel) { | ||
this.channel = channel; | ||
} else { | ||
this.channel = addons.getChannel(); | ||
} | ||
|
||
this.story = story(); | ||
} | ||
|
||
oncreate() { | ||
this.channel.emit('background-set', this.props.backgrounds); | ||
} | ||
|
||
onremove() { | ||
this.channel.emit('background-unset'); | ||
} | ||
|
||
view() { | ||
return m(this.story); | ||
} | ||
} | ||
|
||
export default backgrounds => story => ({ | ||
view: () => <BackgroundDecorator story={story} backgrounds={backgrounds} />, | ||
}); |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./dist/mithril'); |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** @jsx m */ | ||
|
||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import m from 'mithril'; | ||
|
||
const style = { | ||
position: 'fixed', | ||
top: 0, | ||
left: 0, | ||
bottom: 0, | ||
right: 0, | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
overflow: 'auto', | ||
}; | ||
|
||
const innerStyle = { | ||
margin: 'auto', | ||
}; | ||
|
||
export default function(storyFn) { | ||
return { | ||
view: () => ( | ||
<div style={style}> | ||
<div style={innerStyle}>{m(storyFn())}</div> | ||
</div> | ||
), | ||
}; | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./dist/mithril'); |
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import m from 'mithril'; | ||
|
||
export default class WrapStory { | ||
constructor(vnode) { | ||
this.knobChanged = this.knobChanged.bind(this); | ||
this.knobClicked = this.knobClicked.bind(this); | ||
this.resetKnobs = this.resetKnobs.bind(this); | ||
this.setPaneKnobs = this.setPaneKnobs.bind(this); | ||
this.props = vnode.attrs; | ||
this.storyContent = vnode.attrs.initialContent; | ||
} | ||
|
||
oncreate() { | ||
// Watch for changes in knob editor. | ||
this.props.channel.on('addon:knobs:knobChange', this.knobChanged); | ||
// Watch for clicks in knob editor. | ||
this.props.channel.on('addon:knobs:knobClick', this.knobClicked); | ||
// Watch for the reset event and reset knobs. | ||
this.props.channel.on('addon:knobs:reset', this.resetKnobs); | ||
// Watch for any change in the knobStore and set the panel again for those | ||
// changes. | ||
this.props.knobStore.subscribe(this.setPaneKnobs); | ||
// Set knobs in the panel for the first time. | ||
this.setPaneKnobs(); | ||
} | ||
|
||
onremove() { | ||
this.props.channel.removeListener('addon:knobs:knobChange', this.knobChanged); | ||
this.props.channel.removeListener('addon:knobs:knobClick', this.knobClicked); | ||
this.props.channel.removeListener('addon:knobs:reset', this.resetKnobs); | ||
this.props.knobStore.unsubscribe(this.setPaneKnobs); | ||
} | ||
|
||
setPaneKnobs(timestamp = +new Date()) { | ||
const { channel, knobStore } = this.props; | ||
channel.emit('addon:knobs:setKnobs', { knobs: knobStore.getAll(), timestamp }); | ||
} | ||
|
||
knobChanged(change) { | ||
const { name, value } = change; | ||
const { knobStore, storyFn, context } = this.props; | ||
// Update the related knob and it's value. | ||
const knobOptions = knobStore.get(name); | ||
|
||
knobOptions.value = value; | ||
knobStore.markAllUnused(); | ||
this.storyContent = storyFn(context); | ||
m.redraw(); | ||
} | ||
|
||
knobClicked(clicked) { | ||
const knobOptions = this.props.knobStore.get(clicked.name); | ||
knobOptions.callback(); | ||
} | ||
|
||
resetKnobs() { | ||
const { knobStore, storyFn, context } = this.props; | ||
knobStore.reset(); | ||
this.storyContent = storyFn(context); | ||
m.redraw(); | ||
this.setPaneKnobs(false); | ||
} | ||
|
||
view() { | ||
return m(this.storyContent); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** @jsx m */ | ||
|
||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import m from 'mithril'; | ||
import addons from '@storybook/addons'; | ||
|
||
import WrapStory from './WrapStory'; | ||
|
||
import { | ||
knob, | ||
text, | ||
boolean, | ||
number, | ||
color, | ||
object, | ||
array, | ||
date, | ||
select, | ||
selectV2, | ||
button, | ||
manager, | ||
} from '../base'; | ||
|
||
export { knob, text, boolean, number, color, object, array, date, select, selectV2, button }; | ||
|
||
export const mithrilHandler = (channel, knobStore) => getStory => context => { | ||
const initialContent = getStory(context); | ||
const props = { context, storyFn: getStory, channel, knobStore, initialContent }; | ||
return { | ||
view: () => <WrapStory {...props} />, | ||
}; | ||
}; | ||
|
||
function wrapperKnobs(options) { | ||
const channel = addons.getChannel(); | ||
manager.setChannel(channel); | ||
|
||
if (options) channel.emit('addon:knobs:setOptions', options); | ||
|
||
return mithrilHandler(channel, manager.knobStore); | ||
} | ||
|
||
export function withKnobs(storyFn, context) { | ||
return wrapperKnobs()(storyFn)(context); | ||
} | ||
|
||
export function withKnobsOptions(options = {}) { | ||
return (storyFn, context) => wrapperKnobs(options)(storyFn)(context); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
docs | ||
.babelrc |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Storybook for Mithril | ||
|
||
[![Build Status on CircleCI](https://circleci.com/gh/storybooks/storybook.svg?style=shield)](https://circleci.com/gh/storybooks/storybook) | ||
[![CodeFactor](https://www.codefactor.io/repository/github/storybooks/storybook/badge)](https://www.codefactor.io/repository/github/storybooks/storybook) | ||
[![Known Vulnerabilities](https://snyk.io/test/github/storybooks/storybook/8f36abfd6697e58cd76df3526b52e4b9dc894847/badge.svg)](https://snyk.io/test/github/storybooks/storybook/8f36abfd6697e58cd76df3526b52e4b9dc894847) | ||
[![BCH compliance](https://bettercodehub.com/edge/badge/storybooks/storybook)](https://bettercodehub.com/results/storybooks/storybook) [![codecov](https://codecov.io/gh/storybooks/storybook/branch/master/graph/badge.svg)](https://codecov.io/gh/storybooks/storybook) | ||
[![Storybook Slack](https://now-examples-slackin-rrirkqohko.now.sh/badge.svg)](https://now-examples-slackin-rrirkqohko.now.sh/) | ||
[![Backers on Open Collective](https://opencollective.com/storybook/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/storybook/sponsors/badge.svg)](#sponsors) | ||
|
||
* * * | ||
|
||
Storybook for Mithril is a UI development environment for your Mithril components. | ||
With it, you can visualize different states of your UI components and develop them interactively. | ||
|
||
![Storybook Screenshot](docs/demo.gif) | ||
|
||
Storybook runs outside of your app. | ||
So you can develop UI components in isolation without worrying about app specific dependencies and requirements. | ||
|
||
## Getting Started | ||
|
||
```sh | ||
npm i -g @storybook/cli | ||
cd my-mithril-app | ||
getstorybook | ||
``` | ||
|
||
For more information visit: [storybook.js.org](https://storybook.js.org) | ||
|
||
* * * | ||
|
||
Storybook also comes with a lot of [addons](https://storybook.js.org/addons/introduction) and a great API to customize as you wish. | ||
You can also build a [static version](https://storybook.js.org/basics/exporting-storybook) of your storybook and deploy it anywhere you want. |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env node | ||
|
||
require('../dist/server/build'); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's make it alpha as well?