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

Commit

Permalink
Text style arrays story
Browse files Browse the repository at this point in the history
  • Loading branch information
Morgan Laco committed Sep 26, 2018
1 parent 9f6632e commit 18cfcd7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion boilerplate/src/views/shared/text/text.story.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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 { color } from "../../../theme/color"
Expand All @@ -9,6 +9,10 @@ const VIEWSTYLE = {
flex: 1,
backgroundColor: color.storybookDarkBg,
}
const viewStyleArray: ViewStyle[] = [
VIEWSTYLE,
{backgroundColor: "#7fff00"},
]

storiesOf("Text", module)
.addDecorator(fn => <StoryScreen>{fn()}</StoryScreen>)
Expand Down Expand Up @@ -72,3 +76,18 @@ storiesOf("Text", module)
</UseCase>
</Story>
))
.add("Styling", () => (
<Story>
<UseCase
text="Style array"
usage="Text with style array"
>
<View style={viewStyleArray}>
<Text>
{" "}
Hello <Text preset="bold">bolded</Text> World.
</Text>
</View>
</UseCase>
</Story>
))
2 changes: 1 addition & 1 deletion boilerplate/src/views/shared/text/text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function Text(props: TextProps) {
let style
if (Array.isArray(styleOverride)) {
style = reduce((acc,term) => {
return { ...acc, ...term, }
return { ...acc, ...term }
}, presetToUse, styleOverride)
} else {
style = { ...presetToUse, ...styleOverride }
Expand Down

0 comments on commit 18cfcd7

Please sign in to comment.