1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/* eslint-disable react-native/no-inline-styles */
/* eslint-disable react-native/no-color-literals */
import * as React from "react"
import { View, ViewStyle } from "react-native"
import { storiesOf } from "@storybook/react-native"
import { StoryScreen, Story, UseCase } from "../../../storybook/views"
import { Checkbox } from "./checkbox"
import { Toggle } from "react-powerplug"
declare let module
const arrayStyle: ViewStyle[] = [{ paddingVertical: 40 }, { alignSelf: "flex-end" }]
const arrayOutlineStyle: ViewStyle[] = [{ borderColor: "#b443c9" }, { borderWidth: 25 }]
const arrayFillStyle: ViewStyle[] = [{ backgroundColor: "#55e0ff" }]
storiesOf("Checkbox", module)
.addDecorator((fn) => <StoryScreen>{fn()}</StoryScreen>)
.add("Behaviour", () => (
<Story>
<UseCase text="The Checkbox" usage="Use the checkbox to represent on/off states.">
<Toggle initial={false}>
{({ on, toggle }) => <Checkbox value={on} onToggle={toggle} text="Toggle me" />}
</Toggle>
</UseCase>
<UseCase text="value = true" usage="This is permanently on.">
<Checkbox value={true} text="Always on" />
</UseCase>
<UseCase text="value = false" usage="This is permanantly off.">
<Checkbox value={false} text="Always off" />
</UseCase>
</Story>
))
.add("Styling", () => (
<Story>
<UseCase text="multiline = true" usage="For really really long text">
<Toggle initial={false}>
{({ on, toggle }) => (
<View>
<Checkbox
text="We’re an App Design & Development Team. Experts in mobile & web technologies. We create beautiful, functional mobile apps and websites."
value={on}
multiline
onToggle={toggle}
/>
</View>
)}
</Toggle>
</UseCase>
<UseCase text=".style" usage="Override the container style">
<Toggle initial={false}>
{({ on, toggle }) => (
<View>
<Checkbox
text="Hello there!"
value={on}
style={{
backgroundColor: "purple",
marginLeft: 40,
paddingVertical: 30,
paddingLeft: 60,
}}
onToggle={toggle}
/>
</View>
)}
</Toggle>
</UseCase>
<UseCase text=".outlineStyle" usage="Override the outline style">
<Toggle initial={false}>
{({ on, toggle }) => (
<View>
<Checkbox
text="Outline is the box frame"
value={on}
outlineStyle={{
borderColor: "green",
borderRadius: 10,
borderWidth: 4,
width: 60,
height: 20,
}}
onToggle={toggle}
/>
</View>
)}
</Toggle>
</UseCase>
<UseCase text=".fillStyle" usage="Override the fill style">
<Toggle initial={false}>
{({ on, toggle }) => (
<View>
<Checkbox
text="Fill er up"
value={on}
fillStyle={{ backgroundColor: "red", borderRadius: 8 }}
onToggle={toggle}
/>
</View>
)}
</Toggle>
</UseCase>
<UseCase text="Array style" usage="Use array styles">
<Toggle initial={false}>
{({ on, toggle }) => (
<View>
<Checkbox
text="Check it twice"
value={on}
onToggle={toggle}
style={arrayStyle}
outlineStyle={arrayOutlineStyle}
fillStyle={arrayFillStyle}
/>
</View>
)}
</Toggle>
</UseCase>
</Story>
))
|