Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Commit

Permalink
Checkbox array style story
Browse files Browse the repository at this point in the history
  • Loading branch information
Morgan Laco committed Sep 26, 2018
1 parent c2ac84d commit 783d93f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
32 changes: 31 additions & 1 deletion boilerplate/src/views/shared/checkbox/checkbox.story.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
import * as React from "react"
import { View } from "react-native"
import { View, ViewStyle } from "react-native"
import { storiesOf } from "@storybook/react-native"
import { StoryScreen, Story, UseCase } from "../../../../storybook/views"
import { Checkbox } from "./"
import { Toggle } from "react-powerplug"

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", () => (
Expand Down Expand Up @@ -91,5 +104,22 @@ storiesOf("Checkbox", module)
)}
</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>
))
8 changes: 4 additions & 4 deletions boilerplate/src/views/shared/checkbox/checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function Checkbox(props: CheckboxProps) {
let rootStyle
if (Array.isArray(props.style)) {
rootStyle = reduce((acc,term) => {
return { ...acc, ...term, }
return { ...acc, ...term }
}, ROOT, props.style)
} else {
rootStyle = { ...ROOT, ...props.style } as ViewStyle
Expand All @@ -46,16 +46,16 @@ export function Checkbox(props: CheckboxProps) {
let outlineStyle
if (Array.isArray(props.outlineStyle)) {
outlineStyle = reduce((acc,term) => {
return { ...acc, ...term, }
return { ...acc, ...term }
}, OUTLINE, props.outlineStyle)
} else {
outlineStyle = { ...OUTLINE, ...props.outlineStyle } as ViewStyle
}

let fillStyle
if (Array.isArray(props.fillStyle)) {
rootStyle = reduce((acc,term) => {
return { ...acc, ...term, }
fillStyle = reduce((acc,term) => {
return { ...acc, ...term }
}, FILL, props.fillStyle)
} else {
fillStyle = { ...FILL, ...props.fillStyle } as ViewStyle
Expand Down

0 comments on commit 783d93f

Please sign in to comment.