Skip to content
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

(3rd review round) riot integration (good luck) #4070

Merged
merged 45 commits into from
Aug 30, 2018
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3893d52
riot integration
libetl Aug 27, 2018
f04574f
fixing the locks thanks to my home computer using linux
libetl Aug 27, 2018
0749e26
symlink for built storybook
libetl Aug 27, 2018
9118d11
starting storyshots (not finished)
libetl Aug 27, 2018
8773d1f
cheating on the riot jest transformer to use babel 7
libetl Aug 28, 2018
db365f0
fixing cli failure
libetl Aug 28, 2018
19f5650
storyshots
libetl Aug 28, 2018
d385ebc
reverting yarn.lock (pretty sure it won't work unfortunately)
libetl Aug 28, 2018
9951a49
Merge remote-tracking branch 'origin2/master' into task/riot-integration
libetl Aug 28, 2018
299d7b9
up
libetl Aug 28, 2018
5fcda5e
moving down the official-storybook build
libetl Aug 28, 2018
3f03a39
enforcing axe-core (we never know)
libetl Aug 28, 2018
be1a0dd
Merge remote-tracking branch 'origin2/master' into task/riot-integration
libetl Aug 28, 2018
5e6bb41
fixing the CI for the html kitchen sink
libetl Aug 28, 2018
2fcd84b
fixes in the kitchen sink for addon-actions and addon-links
libetl Aug 28, 2018
9178857
up
libetl Aug 28, 2018
94630b8
trying to fix html kitchen sink
libetl Aug 28, 2018
c7b7c52
riot integration
libetl Aug 28, 2018
d3a89ac
fixing yarn.lock
libetl Aug 28, 2018
09f0f9d
up
libetl Aug 29, 2018
172c361
up
libetl Aug 29, 2018
17094d4
forgot one story in the official storybook
libetl Aug 29, 2018
facff92
fix for official-storybook
libetl Aug 29, 2018
1560d81
wip
libetl Aug 29, 2018
7aec530
Merge remote-tracking branch 'origin2/master' into task/riot-integration
libetl Aug 29, 2018
2c090e2
fix storyshots
libetl Aug 29, 2018
3ba7058
igor's suggestions
libetl Aug 29, 2018
e2badba
fixing a bug with the selector
libetl Aug 29, 2018
56ac7f3
up
libetl Aug 30, 2018
d33c1db
wip
libetl Aug 30, 2018
ecd8c1e
fixing unit tests
libetl Aug 30, 2018
f4caa57
fixing unit tests
libetl Aug 30, 2018
3b519dc
Merge remote-tracking branch 'origin2/master' into task/riot-integration
libetl Aug 30, 2018
2b413a5
yes it works now....
libetl Aug 30, 2018
67595c8
moving compileNow inside @storybook/riot
libetl Aug 30, 2018
6dd0837
moving compileNow inside @storybook/riot
libetl Aug 30, 2018
d2dccac
changing the doc
libetl Aug 30, 2018
7b8d35c
compileNow should not need tag as param
libetl Aug 30, 2018
4b851f3
fixes
libetl Aug 30, 2018
dce0411
fixes
libetl Aug 30, 2018
68a8300
removed yarn from package.json
libetl Aug 30, 2018
7eb8044
removing unneeded yarn.lock
libetl Aug 30, 2018
f555ce0
simplifying the render method (no more context object needed)
libetl Aug 30, 2018
6a56f86
changing CONTRIBUTING.md
libetl Aug 30, 2018
eda3f40
update of yarn.lock
libetl Aug 30, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 21 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ jobs:
- examples/vue-kitchen-sink/node_modules
- examples/svelte-kitchen-sink/node_modules
- examples/marko-cli/node_modules
- examples/html-kitchen-sink/node_modules
- examples/riot-kitchen-sink/node_modules
- addons
- app
- lib
Expand Down Expand Up @@ -87,14 +89,24 @@ jobs:
cd examples/marko-cli
yarn build-storybook
- run:
name: Build official-storybook
name: Build mithril kitchen-sink
command: |
cd examples/official-storybook
cd examples/mithril-kitchen-sink
yarn build-storybook
- run:
name: Build mithril kitchen-sink
name: Build html kitchen-sink
command: |
cd examples/mithril-kitchen-sink
cd examples/html-kitchen-sink
yarn build-storybook
- run:
name: Build riot kitchen-sink
command: |
cd examples/riot-kitchen-sink
yarn build-storybook
- run:
name: Build official-storybook
command: |
cd examples/official-storybook
yarn build-storybook
- run:
name: Run image snapshots
Expand Down Expand Up @@ -148,6 +160,11 @@ jobs:
command: |
cd examples/mithril-kitchen-sink
yarn storybook --smoke-test
- run:
name: Run riot kitchen-sink (smoke test)
command: |
cd examples/riot-kitchen-sink
yarn storybook --smoke-test
react-native:
<<: *defaults
steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ enum class StorybookApp(val appName: String, val exampleDir: String, val merged:
MARKO("Marko", "marko-cli"),
HYPERAPP("Hyperapp", "hyperapp-kitchen-sink", false),
SVELTE("Svelte", "svelte-kitchen-sink"),
RIOT("Riot", "riot-kitchen-sink", false);
RIOT("Riot", "riot-kitchen-sink");

val lowerName = appName.toLowerCase()

Expand Down
38 changes: 19 additions & 19 deletions ADDONS_SUPPORT.md
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)| [Mithril](app/mithril)| [HTML](app/html)| [Marko](app/marko)| [Svelte](app/svelte)|
| ----------- |:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|
|[a11y](addons/a11y) |+| |+|+|+|+|+|+| |
|[actions](addons/actions) |+|+|+|+|+|+|+|+|+|
|[backgrounds](addons/backgrounds) |+| |+|+|+|+|+|+|+|
|[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) |+| |+|+|+|+|+|+|+|
## Addon / Framework Support Table
| | [React](app/react)|[React Native](app/react-native)|[Vue](app/vue)|[Angular](app/angular)| [Polymer](app/polymer)| [Mithril](app/mithril)| [HTML](app/html)| [Marko](app/marko)| [Svelte](app/svelte)| [Riot](app/riot)|
| ----------- |:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|
|[a11y](addons/a11y) |+| |+|+|+|+|+|+| | |
|[actions](addons/actions) |+|+|+|+|+|+|+|+|+|+|
|[backgrounds](addons/backgrounds) |+| |+|+|+|+|+|+|+|+|
|[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) |+| |+|+|+|+|+|+|+|+|
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ You can use the `--update` flag to update snapshots or screenshots as needed.

You can also pick suites from CLI. Suites available are listed below.

##### Core & React & Vue & Svelte Tests
##### Core & React & Vue & Svelte && Riot Tests

`yarn test --core`

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![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)
[![Backers on Open Collective](https://opencollective.com/storybook/backers/badge.svg)](#backers)
[![Sponsors on Open Collective](https://opencollective.com/storybook/sponsors/badge.svg)](#sponsors)
[![License](https://img.shields.io/github/license/storybooks/storybook.svg)](https://github.com/storybooks/storybook/blob/master/LICENSE)
<!-- [![BrowserStack Status](https://www.browserstack.com/automate/badge.svg?badge_key=<badge_key>)](https://www.browserstack.com/automate/public-build/<badge_key>) -->
Expand Down Expand Up @@ -87,6 +87,7 @@ For additional help, join us [in our Slack](https://now-examples-slackin-rrirkqo
- [Marko](app/marko) <sup>alpha</sup> [![Marko](https://img.shields.io/npm/dt/@storybook/marko.svg)](app/marko)
- [HTML](app/html) <sup>alpha</sup> [![HTML](https://img.shields.io/npm/dt/@storybook/html.svg)](app/html)
- [Svelte](app/svelte) <sup>alpha</sup> [![Svelte](https://img.shields.io/npm/dt/@storybook/svelte.svg)](app/svelte)
- [Riot](app/riot) <sup>alpha</sup> [![Riot](https://img.shields.io/npm/dt/@storybook/riot.svg)](app/riot)

### Sub Projects

Expand Down Expand Up @@ -126,6 +127,7 @@ See [Addon / Framework Support Table](ADDONS_SUPPORT.md)
- [Marko](https://storybooks-marko.netlify.com/)
- [HTML](https://storybooks-html.netlify.com/)
- [Svelte](https://storybooks-svelte.netlify.com/)
- [Riot](https://storybooks-riot.netlify.com/)

### 3.4
- [React Official](https://release-3-4--storybooks-official.netlify.com)
Expand Down
35 changes: 35 additions & 0 deletions addons/storyshots/storyshots-core/src/frameworks/riot/loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import global from 'global';
import hasDependency from '../hasDependency';
import configure from '../configure';

function mockRiotToIncludeCompiler() {
jest.mock('riot', () => require.requireActual('riot/riot.js'));
}

function test(options) {
return options.framework === 'riot' || (!options.framework && hasDependency('@storybook/riot'));
}

function load(options) {
global.STORYBOOK_ENV = 'riot';
mockRiotToIncludeCompiler();

const { configPath, config } = options;
const storybook = require.requireActual('@storybook/riot');

configure({ configPath, config, storybook });

return {
framework: 'riot',
renderTree: require.requireActual('./renderTree').default,
renderShallowTree: () => {
throw new Error('Shallow renderer is not supported for riot');
},
storybook,
};
}

export default {
load,
test,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { document } from 'global';

const riotForStorybook = require.requireActual('@storybook/riot');

function bootstrapADocumentAndReturnANode() {
const rootElement = document.createElement('div');
rootElement.id = 'root';
document.body = document.createElement('body');
document.body.appendChild(rootElement);
return rootElement;
}

function makeSureThatResultIsRenderedSomehow({ context, result, rootElement }) {
if (!rootElement.firstChild) {
riotForStorybook.render({
story: () => result,
selectedKind: context.kind,
selectedStory: context.story,
});
}
}

function getRenderedTree(story, context) {
const rootElement = bootstrapADocumentAndReturnANode();

const result = story.render(context);

makeSureThatResultIsRenderedSomehow({ context, result, rootElement });

return rootElement;
}

export default getRenderedTree;
2 changes: 2 additions & 0 deletions app/riot/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src
.babelrc
26 changes: 26 additions & 0 deletions app/riot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Storybook for Riot <sup>alpha</sup>

* * *

Storybook for Riot is a UI development environment for the components written with riot.js.
With it, you can visualize different states of your UI components and develop them interactively.

![Storybook Screenshot](https://github.com/storybooks/storybook/blob/master/media/storybook-intro.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-app
getstorybook --riot
```

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.
4 changes: 4 additions & 0 deletions app/riot/bin/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node

process.env.NODE_ENV = process.env.NODE_ENV || 'production';
require('../dist/server/build');
3 changes: 3 additions & 0 deletions app/riot/bin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

require('../dist/server');
49 changes: 49 additions & 0 deletions app/riot/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "@storybook/riot",
"version": "4.0.0-alpha.18",
"description": "Storybook for riot.js: View riot snippets in isolation with Hot Reloading.",
"homepage": "https://github.com/storybooks/storybook/tree/master/app/riot",
"bugs": {
"url": "https://github.com/storybooks/storybook/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/storybooks/storybook.git"
},
"license": "MIT",
"main": "dist/client/index.js",
"bin": {
"build-storybook": "./bin/build.js",
"start-storybook": "./bin/index.js",
"storybook-server": "./bin/index.js"
},
"scripts": {
"prepare": "node ../../scripts/prepare.js"
},
"dependencies": {
"@babel/runtime": "^7.0.0-rc.2",
"@storybook/core": "4.0.0-alpha.18",
"common-tags": "^1.8.0",
"global": "^4.3.2",
"moment": "^2.22.2",
"raw-loader": "^0.5.1",
"react": "^16.4.2",
"react-dom": "^16.4.2"
},
"devDependencies": {
"cross-env": "^5.2.0",
"@babel/preset-flow": "^7.0.0-rc.2",
"@babel/preset-react": "^7.0.0-rc.2",
"@babel/runtime": "^7.0.0-rc.2",
"@babel/preset-env": "^7.0.0-rc.2",
"@babel/plugin-transform-runtime": "^7.0.0-rc.2",
"@babel/plugin-transform-modules-commonjs": "^7.0.0-rc.2"
},
"peerDependencies": {
"babel-loader": "^7.0.0 || ^8.0.0 || ^8.0.0-beta.6",
"riot": "^3.0.0 || ^4.0.0",
"riot-compiler": "^3.5.1 || ^4.0.0",
"riot-hot-reload": "^1.0.0",
"riot-tag-loader": "^2.0.0 || ^3.0.0"
}
}
14 changes: 14 additions & 0 deletions app/riot/src/client/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export {
storiesOf,
setAddon,
addDecorator,
addParameters,
configure,
getStorybook,
forceReRender,
render,
mount,
tag,
compileNow,
asCompiledCode,
} from './preview';
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`render a riot element can nest several tags 1`] = `"<matriochka><div><tag1><div>Inside tag1:<ul><li><tag2><div>Inside tag2:<ul><li><tag3><div>Inside tag3:<ul><li><tag4><div>Inside tag4:<ul><li><tag5><div>Inside tag5:<ul><li>Content</li></ul></div></tag5></li></ul></div></tag4></li></ul></div></tag3></li></ul></div></tag2></li></ul></div></tag1></div></matriochka>"`;

exports[`render a riot element can template some vars 1`] = `"<simpletest test=\\"with a parameter\\"><div>simple test (with a parameter). Oh, by the way (value is mapped to riotValue)</div></simpletest>"`;
13 changes: 13 additions & 0 deletions app/riot/src/client/preview/compileNow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import compiler from 'riot-compiler';

export function asCompiledCode(text) {
return compiler
.compile(text, {})
.replace('var riot = require("riot")', '')
.replace('riot.tag2(', 'tag2(');
}

export function compileNow(tag2, text) {
// eslint-disable-next-line no-eval
return tag2 && eval(asCompiledCode(text));
}
3 changes: 3 additions & 0 deletions app/riot/src/client/preview/globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { window } from 'global';

window.STORYBOOK_ENV = 'riot';
22 changes: 22 additions & 0 deletions app/riot/src/client/preview/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { start } from '@storybook/core/client';

import './globals';
import riot, { tag2, mount as vendorMount } from 'riot';
import render from './render';
import { compileNow as unboundCompileNow, asCompiledCode } from './compileNow';

const { clientApi, configApi, forceReRender } = start(render);

export const {
storiesOf,
setAddon,
addDecorator,
addParameters,
clearDecorators,
getStorybook,
} = clientApi;

export const { configure } = configApi;
const mount = vendorMount.bind(riot, '#root');
const compileNow = unboundCompileNow.bind(null, tag2);
export { forceReRender, render, tag2 as tag, mount, compileNow, asCompiledCode };