Skip to content

Commit 99b821d

Browse files
committed
Clean up stories
1 parent f5d1cca commit 99b821d

File tree

7 files changed

+56
-44
lines changed

7 files changed

+56
-44
lines changed

.storybook/main.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ module.exports = {
33
addons: [
44
'@storybook/addon-links',
55
'@storybook/addon-essentials',
6-
'@storybook/addon-interactions',
7-
'@storybook/addon-knobs'
6+
'@storybook/addon-interactions'
87
],
98
framework: '@storybook/react',
109
core: {

README.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,21 @@ To see how your component looks and behaves while you are developing it, you hav
6464

6565
If you prefer, you can also test your component inside of storybook. To do this, create a new story within the `src/stories` directory. See the Storybook section below for more info about Storybook.
6666

67-
### Classes and Styles
67+
### Classes
6868

6969
By convention, almost all components are given a top-level class which is the name of the component converted into kabob-case and prefixed with "mpc-". For example, the `DataBlock` component has the class `mpc-data-block`. The `className` prop for any component should extend the default class rather than replace it.
7070

71-
The components in this library are intended to be used with the Bulma CSS Framework. For that reason, many bulma classes and component patterns are utilized within the components.
71+
The components in this library are intended to be used with the [Bulma CSS Framework](https://bulma.io/). For that reason, many bulma classes and component patterns are utilized within the components.
72+
73+
### Styles
74+
75+
Components should come with styles that are important for their usage. To include styles for a component, add a CSS file named `MyComponent.css` in the component's folder and import that CSS file into the main component file.
76+
77+
```
78+
import './MyComponent.css';
79+
```
80+
81+
Remember that these components are intended to be used with the [Bulma CSS framework](https://bulma.io/), so the styles in the custom stylesheet can (and often do) take this into account.
7282

7383
### Test IDs
7484

@@ -163,7 +173,17 @@ Storybook is configured using webpack and various plugins offered by Storybook.
163173

164174
The order and hierarchy of the stories are set in `.storybook/preview.js`. This file is also where styles are imported into the storybook. Any styles that the storybook needs that aren't already imported into the components themselves should be included here.
165175

166-
### Deploy storybook to github pages
176+
### Run Storybook Locally
177+
178+
Run the story book locally:
179+
180+
```
181+
npm run storybook
182+
```
183+
184+
You should be able to access the storybook at http://localhost:6006
185+
186+
### Deploy Storybook to GitHub Pages
167187

168188
This will **build** and **deploy** the storybook.
169189
Stories are defined in `./src/stories`
@@ -172,6 +192,8 @@ Stories are defined in `./src/stories`
172192
npm deploy-storybook
173193
```
174194

195+
If successful, the changes will be live at https://materialsproject.github.io/mp-react-components/
196+
175197
### Build Tools
176198

177-
This repo uses Parcel to build and run the app locally and Rollup to publish the app. Parcel does not have a config file, but it does use Babel to transpile the code for this repo. The babel configuration exists in `.babelrc` and `babel.config.js`. The Rollup configuration is defined in `rollup.config.js`.
199+
This repo uses Parcel to build and run the app locally and Rollup to publish the app. Parcel does not have a config file, but it does use Babel to transpile the code for this repo. The babel configuration exists in `.babelrc` and `babel.config.js`. The Rollup configuration is defined in `rollup.config.js`. In the future, both of these build tools may be removed in favor of a single unified tool (potentially webpack as it is used in dash-mp-components).

src/components/crystal-toolkit/DynamicCrystalToolkitScene/DynamicCrystalToolkitScene.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { useState, useEffect, useRef } from 'react';
22
import { CrystalToolkitScene } from '../CrystalToolkitScene';
3-
import { boolean, number, object, select, withKnobs } from '@storybook/addon-knobs';
43
import { AnimationStyle, Renderer } from '../scene/constants';
54

65
/**
@@ -38,17 +37,12 @@ export const DynamicCrystalToolkitScene: React.FC = () => {
3837
<button onClick={remove}>remove</button>
3938
{showScene && sceneData ? (
4039
<CrystalToolkitScene
41-
debug={boolean('DEBUG', false)}
42-
animation={select(
43-
'Animation',
44-
[AnimationStyle.SLIDER, AnimationStyle.PLAY, AnimationStyle.NONE] as string[],
45-
AnimationStyle.NONE as string
46-
)}
47-
axisView={select('Axis position', ['SW', 'SE', 'NW', 'NE', 'HIDDEN'], 'SW')}
48-
inletPadding={number('padding', 10)}
49-
inletSize={number('size', 100)}
50-
data={object('scene', sceneData)}
51-
sceneSize={object('Size', 400)}
40+
debug={false}
41+
animation={AnimationStyle.NONE}
42+
inletPadding={10}
43+
inletSize={100}
44+
data={sceneData}
45+
sceneSize={400}
5246
toggleVisibility={emptyObject}
5347
/>
5448
) : null}

src/components/crystal-toolkit/scene/Scene.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import {
1010
Renderer,
1111
ThreePosition
1212
} from './constants';
13-
import { TooltipHelper } from '../scene/tooltip-helper';
14-
import { InsetHelper, ScenePosition } from '../scene/inset-helper';
13+
import { TooltipHelper } from './tooltip-helper';
14+
import { InsetHelper, ScenePosition } from './inset-helper';
1515
import { getSceneWithBackground, ThreeBuilder } from './three_builder';
16-
import { DebugHelper } from '../scene/debug-helper';
16+
import { DebugHelper } from './debug-helper';
1717
import {
1818
disposeSceneHierarchy,
1919
getScreenCoordinate,
@@ -25,9 +25,9 @@ import {
2525
//import img from './glass.png';
2626
import { OutlineEffect } from 'three/examples/jsm/effects/OutlineEffect';
2727
import { TrackballControls } from 'three/examples/jsm/controls/TrackballControls';
28-
import { SceneJsonObject } from '../scene/simple-scene';
28+
import { SceneJsonObject } from './simple-scene';
2929
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
30-
import { AnimationHelper } from '../scene/animation-helper';
30+
import { AnimationHelper } from './animation-helper';
3131
import '../CrystalToolkitScene/CrystalToolkitScene.less';
3232
import { CameraState } from '../CameraContextProvider/camera-reducer';
3333

src/pages/CrystalStructureViewer/CrystalStructureViewer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export const CrystalStructureViewer: React.FC = () => {
188188
// showImageButton={false}
189189
showExportButton={false}
190190
>
191-
{null}
191+
<p>Settings panel</p>
192192
<p>This could be a legend</p>
193193
</CrystalToolkitScene>
194194
</div>

src/stories/crystal-toolkit/CrystalToolkitScene.stories.tsx

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { boolean, number, object, select, withKnobs } from '@storybook/addon-knobs';
21
import * as React from 'react';
32
import {
43
s2,
@@ -17,9 +16,7 @@ import { Story } from '@storybook/react';
1716

1817
export default {
1918
component: CrystalToolkitScene,
20-
title: 'Crystal Toolkit/CrystalToolkitScene',
21-
decorators: [withKnobs],
22-
stories: []
19+
title: 'Crystal Toolkit/CrystalToolkitScene'
2320
};
2421

2522
const Template: Story<React.PropsWithChildren<CrystalToolkitSceneProps>> = (args) => (
@@ -28,18 +25,19 @@ const Template: Story<React.PropsWithChildren<CrystalToolkitSceneProps>> = (args
2825

2926
export const Basic = Template.bind({});
3027
Basic.args = {
31-
debug: boolean('DEBUG', false),
32-
animation: select(
33-
'Animation',
34-
[AnimationStyle.SLIDER, AnimationStyle.PLAY, AnimationStyle.NONE] as string[],
35-
AnimationStyle.NONE as string
36-
),
37-
axisView: select('Axis position', ['SW', 'SE', 'NW', 'NE', 'HIDDEN'], 'SW'),
38-
inletPadding: number('padding', 10),
39-
inletSize: number('size', 100),
40-
data: object('scene', sceneJson),
41-
sceneSize: object('Size', 400),
42-
toggleVisibility: {}
28+
debug: false,
29+
animation: AnimationStyle.NONE,
30+
// axisView: select('Axis position', ['SW', 'SE', 'NW', 'NE', 'HIDDEN'], 'SW'),
31+
inletPadding: 10,
32+
inletSize: 100,
33+
data: sceneJson,
34+
sceneSize: 400,
35+
toggleVisibility: {},
36+
settings: {
37+
renderer: Renderer.WEBGL,
38+
extractAxis: false,
39+
zoomToFit2D: true
40+
}
4341
};
4442

4543
export const AnimatedScene = Template.bind({});
@@ -85,7 +83,7 @@ TubeScene.args = {
8583
isMultiSelectionEnabled: false,
8684
secondaryObjectView: true
8785
},
88-
data: object('scene', bezierScene),
86+
data: bezierScene,
8987
debug: false
9088
};
9189
const TubeSceneDescription = `

src/stories/crystal-toolkit/ReactGraphComponent.stories.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from 'react';
22
import { Story } from '@storybook/react';
33
import { InferProps } from 'prop-types';
44
import ReactGraphComponent from '../../components/crystal-toolkit/graph.component';
5-
import { object } from '@storybook/addon-knobs';
65
import { DEFAULT_OPTIONS, GRAPH } from '../constants';
76

87
export default {
@@ -16,6 +15,6 @@ const Template: Story<React.PropsWithChildren<InferProps<typeof ReactGraphCompon
1615

1716
export const Basic = Template.bind({});
1817
Basic.args = {
19-
graph: object('scene', GRAPH),
20-
options: object('options', DEFAULT_OPTIONS)
18+
graph: GRAPH,
19+
options: DEFAULT_OPTIONS
2120
};

0 commit comments

Comments
 (0)