|
| 1 | +import {createElement as h} from 'react'; |
| 2 | +import {storiesOf} from '@storybook/react'; |
| 3 | +const {action} = require('@storybook/addon-actions'); |
| 4 | +const {linkTo} = require('@storybook/addon-links'); |
| 5 | +import {create} from '../index'; |
| 6 | +import {addon as addonRule} from '../addon/rule'; |
| 7 | +import {addon as addonCache} from '../addon/cache'; |
| 8 | +import {addon as addonComponent} from '../addon/component'; |
| 9 | +const renderer = create({h}); |
| 10 | +addonRule(renderer); |
| 11 | +addonCache(renderer); |
| 12 | +addonComponent(renderer); |
| 13 | +const {Component} = renderer; |
| 14 | + |
| 15 | + |
| 16 | +class CssTest extends Component { |
| 17 | + static css = { |
| 18 | + border: '1px solid red' |
| 19 | + }; |
| 20 | + |
| 21 | + render () { |
| 22 | + return <div>Hello there</div>; |
| 23 | + } |
| 24 | +} |
| 25 | + |
| 26 | +class Dynamic extends Component { |
| 27 | + static css = { |
| 28 | + border: '1px solid red' |
| 29 | + }; |
| 30 | + |
| 31 | + css() { |
| 32 | + return { |
| 33 | + color: 'green' |
| 34 | + }; |
| 35 | + } |
| 36 | + |
| 37 | + render () { |
| 38 | + return <div>Hello there</div>; |
| 39 | + } |
| 40 | +} |
| 41 | + |
| 42 | +class Static extends Component { |
| 43 | + static css = { |
| 44 | + border: '1px dashed blue', |
| 45 | + }; |
| 46 | + |
| 47 | + render () { |
| 48 | + return <div>Hello there</div>; |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +class Static2 extends Component { |
| 53 | + static css = { |
| 54 | + border: '1px dashed blue', |
| 55 | + }; |
| 56 | + |
| 57 | + css () { |
| 58 | + return { |
| 59 | + color: this.props.color |
| 60 | + }; |
| 61 | + } |
| 62 | + |
| 63 | + render () { |
| 64 | + return <div>Hello there</div>; |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | +storiesOf('Component', module) |
| 69 | + .add('Default', () => |
| 70 | + h(CssTest as any) |
| 71 | + ) |
| 72 | + .add('Dynamic styles', () => |
| 73 | + h(Dynamic as any) |
| 74 | + ) |
| 75 | + .add('Static decorator', () => |
| 76 | + h(Static as any) |
| 77 | + ) |
| 78 | + .add('Static dynamic styles', () => |
| 79 | + h(Static2 as any, {color: 'blue'}) |
| 80 | + ) |
0 commit comments