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

Commit

Permalink
Allow style arrays in FormRow HOC
Browse files Browse the repository at this point in the history
  • Loading branch information
Morgan Laco committed Sep 7, 2018
1 parent f35ee00 commit 3624927
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion boilerplate/src/views/shared/form-row/form-row.props.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface FormRowProps {
/**
* Override the container style... useful for margins and padding.
*/
style?: ViewStyle
style?: ViewStyle | ViewStyle[]

/**
* The type of border.
Expand Down
15 changes: 11 additions & 4 deletions boilerplate/src/views/shared/form-row/form-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@ import * as React from "react"
import { View } from "react-native"
import { PRESETS } from "./form-row.presets"
import { FormRowProps } from "./form-row.props"
import { concat, mergeWith } from "ramda"

/**
* A horizontal container component used to hold a row of a form.
*/
export function FormRow(props: FormRowProps) {
let viewStyle
if (Array.isArray(props.style)) {
viewStyle = mergeWith(concat, PRESETS[props.preset], props.style)
} else {
viewStyle = {
...PRESETS[props.preset],
...props.style,
}
}
return (
<View
style={{
...PRESETS[props.preset],
...props.style,
}}
style={viewStyle}
>
{props.children}
</View>
Expand Down

0 comments on commit 3624927

Please sign in to comment.