From e5021187e96b78b53203bd95d08d6818aea47d17 Mon Sep 17 00:00:00 2001 From: "Thomas F. K. Jorna" Date: Wed, 14 Jul 2021 15:10:31 +0200 Subject: New Ignite 7.0.6 app --- app/components/form-row/form-row.presets.ts | 71 ++++++++++++++++++ app/components/form-row/form-row.props.tsx | 23 ++++++ app/components/form-row/form-row.story.tsx | 107 ++++++++++++++++++++++++++++ app/components/form-row/form-row.tsx | 13 ++++ 4 files changed, 214 insertions(+) create mode 100644 app/components/form-row/form-row.presets.ts create mode 100644 app/components/form-row/form-row.props.tsx create mode 100644 app/components/form-row/form-row.story.tsx create mode 100644 app/components/form-row/form-row.tsx (limited to 'app/components/form-row') diff --git a/app/components/form-row/form-row.presets.ts b/app/components/form-row/form-row.presets.ts new file mode 100644 index 0000000..7c10294 --- /dev/null +++ b/app/components/form-row/form-row.presets.ts @@ -0,0 +1,71 @@ +import { ViewStyle } from "react-native" +import { color, spacing } from "../../theme" + +/** + * The size of the border radius. + */ +const RADIUS = 8 + +/** + * The default style of the container. + */ +const ROOT: ViewStyle = { + borderWidth: 1, + borderColor: color.line, + padding: spacing[2], +} + +/** + * What each of the presets look like. + */ +export const PRESETS = { + /** + * Rounded borders on the the top only. + */ + top: { + ...ROOT, + borderTopLeftRadius: RADIUS, + borderTopRightRadius: RADIUS, + borderBottomWidth: 0, + }, + /** + * No rounded borders. + */ + middle: { + ...ROOT, + borderBottomWidth: 0, + }, + /** + * Rounded borders on the bottom. + */ + bottom: { + ...ROOT, + borderBottomLeftRadius: RADIUS, + borderBottomRightRadius: RADIUS, + }, + /** + * Rounded borders everywhere. + */ + soloRound: { + ...ROOT, + borderRadius: RADIUS, + }, + /** + * Straight borders everywhere. + */ + soloStraight: { + ...ROOT, + }, + /** + * Transparent borders useful to keep things lined up. + */ + clear: { + ...ROOT, + borderColor: color.transparent, + }, +} + +/** + * The names of the presets supported by FormRow. + */ +export type FormRowPresets = keyof typeof PRESETS diff --git a/app/components/form-row/form-row.props.tsx b/app/components/form-row/form-row.props.tsx new file mode 100644 index 0000000..f010206 --- /dev/null +++ b/app/components/form-row/form-row.props.tsx @@ -0,0 +1,23 @@ +import * as React from "react" +import { StyleProp, ViewStyle } from "react-native" +import { FormRowPresets } from "./form-row.presets" + +/** + * The properties you can pass to FormRow. + */ +export interface FormRowProps { + /** + * Children components. + */ + children?: React.ReactNode + + /** + * Override the container style... useful for margins and padding. + */ + style?: StyleProp + + /** + * The type of border. + */ + preset: FormRowPresets +} diff --git a/app/components/form-row/form-row.story.tsx b/app/components/form-row/form-row.story.tsx new file mode 100644 index 0000000..509afbb --- /dev/null +++ b/app/components/form-row/form-row.story.tsx @@ -0,0 +1,107 @@ +/* eslint-disable react-native/no-inline-styles */ +/* eslint-disable react-native/no-color-literals */ + +import * as React from "react" +import { storiesOf } from "@storybook/react-native" +import { StoryScreen, Story, UseCase } from "../../../storybook/views" +import { Text, FormRow } from "../" +import { color } from "../../theme/color" +import { ViewStyle } from "react-native" + +declare let module + +const TEXT_STYLE_OVERRIDE = { + color: color.storybookTextColor, +} +const arrayStyle: ViewStyle[] = [{ borderWidth: 5 }, { borderColor: "#32cd32" }] + +storiesOf("FormRow", module) + .addDecorator((fn) => {fn()}) + .add("Assembled", () => ( + + + + + Hello! I am at the top + + + + + Lorem ipsum dolor sit amet, consectetur adipisicing elit. Commodi officia quo rerum + impedit asperiores hic ex quae, quam dolores vel odit doloribus, tempore atque deserunt + possimus incidunt, obcaecati numquam officiis. + + + + + ...one more thing + + + + 🎉 Footers! + + + + + + My borders are still there, but they are clear. This causes the text to still align + properly due to the box model of flexbox. + + + + I'm round + + + I'm square and have a custom style. + + + + )) + .add("Presets", () => ( + + + + Curved borders at the top. + Nothing below + + + + + No curves and empty at the bottom. + + + + + Curved at the bottom + Line at the top. + + + + + Curves all around. + + + + + Curves nowhere. + + + + + Curves nowhere. + + + + )) + .add("Styling", () => ( + + + + Array style. + + + + )) diff --git a/app/components/form-row/form-row.tsx b/app/components/form-row/form-row.tsx new file mode 100644 index 0000000..2045336 --- /dev/null +++ b/app/components/form-row/form-row.tsx @@ -0,0 +1,13 @@ +import * as React from "react" +import { View } from "react-native" +import { PRESETS } from "./form-row.presets" +import { FormRowProps } from "./form-row.props" + +/** + * A horizontal container component used to hold a row of a form. + */ +export function FormRow(props: FormRowProps) { + const viewStyle = [PRESETS[props.preset], props.style] + + return {props.children} +} -- cgit v1.2.3