Skip to content

Commit cab4489

Browse files
committed
refactor(storybook): address PR comments
1 parent c45f8e8 commit cab4489

25 files changed

+116
-15757
lines changed

Diff for: .storybook/main.js

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ module.exports = {
99
'@storybook/addon-essentials',
1010
'@storybook/preset-create-react-app'
1111
],
12+
// Ensures that, when running storybook, webpack rules (loaders for css, file,
13+
// etc.) from the custom config are used.
1214
webpackFinal: (config) => {
1315
return { ...config, module: { ...config.module, rules: custom.module.rules } };
1416
}

Diff for: .storybook/preview.js

-4
This file was deleted.

Diff for: .storybook/webpack.config.js

+48-64
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,72 @@
11
const path = require('path');
22
const webpack = require('webpack');
33

4-
/*
5-
* SplitChunksPlugin is enabled by default and replaced
6-
* deprecated CommonsChunkPlugin. It automatically identifies modules which
7-
* should be splitted of chunk by heuristics using module duplication count and
8-
* module category (i. e. node_modules). And splits the chunks…
9-
*
10-
* It is safe to remove "splitChunks" from the generated configuration
11-
* and was added as an educational example.
12-
*
13-
* https://webpack.js.org/plugins/split-chunks-plugin/
14-
*
15-
*/
16-
17-
/*
18-
* We've enabled TerserPlugin for you! This minifies your app
19-
* in order to load faster and run less javascript.
20-
*
21-
* https://github.com/webpack-contrib/terser-webpack-plugin
22-
*
4+
/**
5+
* This is a (mostly) auto-generated webpack config that storybook created when
6+
* initializing the storybook.
237
*/
248

259
const TerserPlugin = require('terser-webpack-plugin');
2610

2711
module.exports = {
28-
mode: 'development',
29-
entry: '../lib/transitive.js',
12+
mode: 'development',
13+
entry: '../lib/transitive.js',
3014

31-
output: {
32-
path: path.resolve(__dirname, 'build'),
33-
},
15+
output: {
16+
path: path.resolve(__dirname, 'build'),
17+
},
3418

35-
plugins: [new webpack.ProgressPlugin()],
19+
plugins: [new webpack.ProgressPlugin()],
3620

37-
module: {
38-
rules: [
39-
{
40-
test: /\.(js|jsx)$/,
41-
include: [path.resolve(__dirname, '../lib'), path.resolve(__dirname, '../stories')],
42-
loader: 'babel-loader',
43-
},
44-
{
21+
module: {
22+
rules: [
23+
{
24+
test: /\.(js|jsx)$/,
25+
include: [path.resolve(__dirname, '../lib'), path.resolve(__dirname, '../stories')],
26+
loader: 'babel-loader',
27+
},
28+
{
4529
test: /\.(png|jpe?g|gif)$/i,
4630
use: [
4731
{
4832
loader: 'file-loader',
4933
},
5034
],
5135
},
52-
{
53-
test: /.css$/,
36+
{
37+
test: /.css$/,
5438

55-
use: [
56-
{
57-
loader: 'style-loader',
58-
},
59-
{
60-
loader: 'css-loader',
39+
use: [
40+
{
41+
loader: 'style-loader',
42+
},
43+
{
44+
loader: 'css-loader',
6145

62-
options: {
63-
sourceMap: true,
64-
},
65-
},
66-
],
67-
},
68-
],
69-
},
46+
options: {
47+
sourceMap: true,
48+
},
49+
},
50+
],
51+
},
52+
],
53+
},
7054

71-
optimization: {
72-
minimizer: [new TerserPlugin()],
55+
optimization: {
56+
minimizer: [new TerserPlugin()],
7357

74-
splitChunks: {
75-
cacheGroups: {
76-
vendors: {
77-
priority: -10,
78-
test: /[\\/]node_modules[\\/]/,
79-
},
80-
},
58+
splitChunks: {
59+
cacheGroups: {
60+
vendors: {
61+
priority: -10,
62+
test: /[\\/]node_modules[\\/]/,
63+
},
64+
},
8165

82-
chunks: 'async',
83-
minChunks: 1,
84-
minSize: 30000,
85-
name: false,
86-
},
87-
},
66+
chunks: 'async',
67+
minChunks: 1,
68+
minSize: 30000,
69+
name: false,
70+
},
71+
},
8872
};

Diff for: README.md

+32
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,38 @@ A Transitive map can be embedded as a freestanding web element or overlaid onto
1212

1313
Transitive is supported by the [Mobility Lab](http://mobilitylab.org/) [Transit Tech Initiative](http://mobilitylab.org/tech/transit-tech-initiative/). Read more in [this Mobility Lab article](http://mobilitylab.org/2014/04/16/the-technology-behind-a-new-kind-of-travel-planning/).
1414

15+
## Storybook
16+
17+
To view samples of Transitive in action, follow these steps:
18+
19+
```bash
20+
git clone https://github.com/conveyal/transitive.js
21+
cd transitive.js
22+
yarn start
23+
# Go to http://localhost:5555 to view the storybook (the web page should open automatically)
24+
```
25+
26+
### Usage of otp-ui
27+
28+
These stories rely on the [otp-ui](https://github.com/opentripplanner/otp-ui)
29+
project to render transitive data on a Leaflet map. Specifically, it uses:
30+
- @opentripplanner/base-map - renders a Leaflet base map
31+
- @opentripplanner/core-utils - converts an OpenTripPlanner itinerary object into
32+
data that Transitive can read.
33+
- @opentripplanner/transitive-overlay - copied from the otp-ui project and
34+
replaces the Transitive import with the local copy (useful for testing local
35+
changes)
36+
37+
### BYOD - Bring your own data
38+
39+
To test out how your own data (e.g., an OpenTripPlanner itinerary) would appear in
40+
Transitive, try replacing the `itinerary` prop in the [Itinerary](http://localhost:5555/?path=/story/example-transitive--itinerary) (for OpenTripPlanner itineraries) story (or `transitiveData`
41+
in the [Profile](http://localhost:5555/?path=/story/example-transitive--profile)
42+
story).
43+
44+
You can also override the default style by adding a `style` prop. See a style
45+
example here: https://github.com/conveyal/transitive-demo/blob/master/styles.js
46+
1547
## Demo
1648

1749
* [Demo of a freestanding Transitive map](http://conveyal.github.io/transitive.js)

0 commit comments

Comments
 (0)