summaryrefslogtreecommitdiff
path: root/app/components/checkbox
diff options
context:
space:
mode:
authorKirill Rogovoy <[email protected]>2021-07-19 20:06:08 +0300
committerKirill Rogovoy <[email protected]>2021-07-19 20:06:08 +0300
commitf0bf4e7afdcd8b02a62be45ab3e7d047ed865a79 (patch)
tree575c0ff2cbb846252bd2e494c81c396846aab2f6 /app/components/checkbox
parent67ad38d0a7cd319623e9f41c0c381ed5c5f6f973 (diff)
Apply Prettier
Diffstat (limited to 'app/components/checkbox')
-rw-r--r--app/components/checkbox/checkbox.props.ts4
-rw-r--r--app/components/checkbox/checkbox.story.tsx45
-rw-r--r--app/components/checkbox/checkbox.tsx33
3 files changed, 51 insertions, 31 deletions
diff --git a/app/components/checkbox/checkbox.props.ts b/app/components/checkbox/checkbox.props.ts
index 01a13d0..4a212e3 100644
--- a/app/components/checkbox/checkbox.props.ts
+++ b/app/components/checkbox/checkbox.props.ts
@@ -1,5 +1,5 @@
-import { StyleProp, ViewStyle } from "react-native"
-import { TxKeyPath } from "../../i18n"
+import { StyleProp, ViewStyle } from 'react-native'
+import { TxKeyPath } from '../../i18n'
export interface CheckboxProps {
/**
diff --git a/app/components/checkbox/checkbox.story.tsx b/app/components/checkbox/checkbox.story.tsx
index f8d80d8..9d1429a 100644
--- a/app/components/checkbox/checkbox.story.tsx
+++ b/app/components/checkbox/checkbox.story.tsx
@@ -1,26 +1,37 @@
/* 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"
+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" }]
+const arrayStyle: ViewStyle[] = [
+ { paddingVertical: 40 },
+ { alignSelf: 'flex-end' },
+]
+const arrayOutlineStyle: ViewStyle[] = [
+ { borderColor: '#b443c9' },
+ { borderWidth: 25 },
+]
+const arrayFillStyle: ViewStyle[] = [{ backgroundColor: '#55e0ff' }]
-storiesOf("Checkbox", module)
+storiesOf('Checkbox', module)
.addDecorator((fn) => <StoryScreen>{fn()}</StoryScreen>)
- .add("Behaviour", () => (
+ .add('Behaviour', () => (
<Story>
- <UseCase text="The Checkbox" usage="Use the checkbox to represent on/off states.">
+ <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" />}
+ {({ on, toggle }) => (
+ <Checkbox value={on} onToggle={toggle} text="Toggle me" />
+ )}
</Toggle>
</UseCase>
<UseCase text="value = true" usage="This is permanently on.">
@@ -31,7 +42,7 @@ storiesOf("Checkbox", module)
</UseCase>
</Story>
))
- .add("Styling", () => (
+ .add('Styling', () => (
<Story>
<UseCase text="multiline = true" usage="For really really long text">
<Toggle initial={false}>
@@ -55,7 +66,7 @@ storiesOf("Checkbox", module)
text="Hello there!"
value={on}
style={{
- backgroundColor: "purple",
+ backgroundColor: 'purple',
marginLeft: 40,
paddingVertical: 30,
paddingLeft: 60,
@@ -74,7 +85,7 @@ storiesOf("Checkbox", module)
text="Outline is the box frame"
value={on}
outlineStyle={{
- borderColor: "green",
+ borderColor: 'green',
borderRadius: 10,
borderWidth: 4,
width: 60,
@@ -93,7 +104,7 @@ storiesOf("Checkbox", module)
<Checkbox
text="Fill er up"
value={on}
- fillStyle={{ backgroundColor: "red", borderRadius: 8 }}
+ fillStyle={{ backgroundColor: 'red', borderRadius: 8 }}
onToggle={toggle}
/>
</View>
diff --git a/app/components/checkbox/checkbox.tsx b/app/components/checkbox/checkbox.tsx
index fc3992a..d788114 100644
--- a/app/components/checkbox/checkbox.tsx
+++ b/app/components/checkbox/checkbox.tsx
@@ -1,13 +1,13 @@
-import * as React from "react"
-import { TextStyle, TouchableOpacity, View, ViewStyle } from "react-native"
-import { Text } from "../text/text"
-import { color, spacing } from "../../theme"
-import { CheckboxProps } from "./checkbox.props"
+import * as React from 'react'
+import { TextStyle, TouchableOpacity, View, ViewStyle } from 'react-native'
+import { Text } from '../text/text'
+import { color, spacing } from '../../theme'
+import { CheckboxProps } from './checkbox.props'
const ROOT: ViewStyle = {
- flexDirection: "row",
+ flexDirection: 'row',
paddingVertical: spacing[1],
- alignSelf: "flex-start",
+ alignSelf: 'flex-start',
}
const DIMENSIONS = { width: 16, height: 16 }
@@ -15,8 +15,8 @@ const DIMENSIONS = { width: 16, height: 16 }
const OUTLINE: ViewStyle = {
...DIMENSIONS,
marginTop: 2, // finicky and will depend on font/line-height/baseline/weather
- justifyContent: "center",
- alignItems: "center",
+ justifyContent: 'center',
+ alignItems: 'center',
borderWidth: 1,
borderColor: color.primaryDarker,
borderRadius: 1,
@@ -37,7 +37,9 @@ export function Checkbox(props: CheckboxProps) {
const outlineStyle = [OUTLINE, props.outlineStyle]
const fillStyle = [FILL, props.fillStyle]
- const onPress = props.onToggle ? () => props.onToggle && props.onToggle(!props.value) : null
+ const onPress = props.onToggle
+ ? () => props.onToggle && props.onToggle(!props.value)
+ : null
return (
<TouchableOpacity
@@ -46,8 +48,15 @@ export function Checkbox(props: CheckboxProps) {
onPress={onPress}
style={rootStyle}
>
- <View style={outlineStyle}>{props.value && <View style={fillStyle} />}</View>
- <Text text={props.text} tx={props.tx} numberOfLines={numberOfLines} style={LABEL} />
+ <View style={outlineStyle}>
+ {props.value && <View style={fillStyle} />}
+ </View>
+ <Text
+ text={props.text}
+ tx={props.tx}
+ numberOfLines={numberOfLines}
+ style={LABEL}
+ />
</TouchableOpacity>
)
}