Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@observation.org/react-native-components",
"version": "1.71.0",
"version": "1.72.0",
"main": "src/index.ts",
"repository": "git@github.com:observation/react-native-components.git",
"author": "Observation.org",
Expand Down Expand Up @@ -65,6 +65,7 @@
"accordion-collapse-react-native": "^1.1.1",
"color": "^5.0.3",
"react-native-logs": "^5.5.0",
"react-native-render-html": "^6.3.4",
"react-native-scalable-image": "^1.1.0"
},
"packageManager": "yarn@3.6.4",
Expand Down
36 changes: 36 additions & 0 deletions src/@types/font.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { TextStyle } from 'react-native'

import { MixedSizeCSSPropertiesKeys } from 'react-native-render-html'

/**
* React Native's TextStyle without the overflow:'scroll' property.
*
* The component @native-html (used by react-native-render-html) is missing the overflow: 'scroll' property.
* In order to use the React Native's TextStyle together with the HtmlContent (RenderHtml) component
* (and type checking) we override the overflow property with our own overflow type.
*/
export type FontStyle = TextStyle & { overflow?: 'visible' | 'hidden' | undefined } & {
[k in MixedSizeCSSPropertiesKeys]?: number | string
}
export type FontName =
| 'extraSmall'
| 'small'
| 'smallBold'
| 'smallLight'
| 'medium'
| 'mediumBold'
| 'large'
| 'largeBold'
| 'extraLarge'
| 'extraLargeBold'
| 'huge'
| 'hugeBold'

export type FontMetrics = {
extraSmall: number
small: number
medium: number
large: number
extraLarge: number
huge: number
}
10 changes: 10 additions & 0 deletions src/@types/layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Insets, ViewStyle } from 'react-native'

export type LayoutStyles = {
absolute: ViewStyle
absoluteLeft: ViewStyle
absoluteRight: ViewStyle
absoluteTop: ViewStyle
absoluteBottom: ViewStyle
hitSlop: Insets
}
10 changes: 10 additions & 0 deletions src/@types/rounded.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export type RoundedStyle = {
borderRadius: number
overflow: 'hidden'
}

export type RoundedStyles = {
normal: RoundedStyle
large: RoundedStyle
huge: RoundedStyle
}
11 changes: 11 additions & 0 deletions src/@types/shadow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ViewStyle } from 'react-native'

export type ShadowStyle = {
android: ViewStyle
ios: ViewStyle
}

export type ShadowStyles = {
normal: ShadowStyle
small: ShadowStyle
}
81 changes: 81 additions & 0 deletions src/@types/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
export interface ThemeAnimation {
duration: {
medium: number
}
}

export interface ThemeColor {
white: string
black: string
grey800: string
grey500: string
grey300: string
grey50: string
grey100: string
primary500: string
primary300: string
primary50: string
success500: string
success200: string
success700: string
success600: string
success400: string
success50: string
warning500: string
warning700: string
warning200: string
error500: string
error200: string
error700: string
accentLime400: string
accentLime50: string
accentSky400: string
accentSky50: string
}

export interface ThemeOverlay {
white00: string
white05: string
white10: string
white70: string
white80: string
black50: string
grey60: string
}

export interface ThemeGradient {
bottom: string[]
top: string[]
}

export interface ThemeIcon {
size: {
xxs: number
xs: number
s: number
m: number
l: number
xl: number
xxl: number
xxxl: number
}
}

export interface ThemeMargin {
eighth: number
quarter: number
half: number
common: number
large: number
double: number
huge: number
}

export interface Theme {
animation: ThemeAnimation
icon: ThemeIcon
color: ThemeColor
overlay: ThemeOverlay
gradient: ThemeGradient
margin: ThemeMargin
}
4 changes: 2 additions & 2 deletions src/components/BackButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
import { NavigationProp, ParamListBase } from '@react-navigation/native'

import IconButton from '../components/IconButton'
import theme from '../styles/theme'
import { theme } from '../styles'

type Props = {
navigation: NavigationProp<ParamListBase>
Expand All @@ -13,7 +13,7 @@ const BackButton = ({ navigation }: Props) => (
<IconButton
containerStyle={{ padding: theme.margin.common }}
onPress={() => navigation.goBack()}
icon={{ name: 'chevron-left', size: theme.icon.size.extraExtraLarge, color: theme.color.primary500 }}
icon={{ name: 'chevron-left', size: theme.icon.size.xxl, color: theme.color.primary500 }}
/>
)

Expand Down
6 changes: 3 additions & 3 deletions src/components/BottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { StyleProp, StyleSheet, Text, View, ViewStyle } from 'react-native'
import { useTheme } from '@react-navigation/native'

import LargeButton, { LargeButtonProps } from './LargeButton'
import { shadow, theme } from '../styles'
import textStyle from '../styles/text'
import theme from '../styles/theme'

type Props = {
title?: string
Expand Down Expand Up @@ -61,12 +61,12 @@ export default BottomSheet

const styles = StyleSheet.create({
container: {
...theme.shadow.ios,
...shadow.normal.ios,
borderTopWidth: 1 / 3,
borderTopColor: theme.color.grey300,
},
bottomSheetContainer: {
...theme.shadow.android,
...shadow.normal.android,
},
bottomSheet: {
flexDirection: 'column',
Expand Down
4 changes: 2 additions & 2 deletions src/components/BrandIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome'

import BrandIcons, { BrandIconName } from '../lib/BrandIcons'
import theme from '../styles/theme'
import { theme } from '../styles'

type Props = {
name: BrandIconName
Expand All @@ -14,7 +14,7 @@ type Props = {
export const BrandIcon = ({ name, color, size }: Props) => {
const icon = BrandIcons[name]
const iconColor = color ?? theme.color.primary500
const iconSize = size ?? theme.icon.size.large
const iconSize = size ?? theme.icon.size.l
const FontAwesomeIconTypeErased = FontAwesomeIcon as unknown as any

return <FontAwesomeIconTypeErased icon={icon} color={iconColor} size={iconSize} />
Expand Down
2 changes: 1 addition & 1 deletion src/components/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { StyleProp, StyleSheet, TouchableOpacity, View, ViewStyle } from 'react-

import { Icon } from './Icon'
import Log from '../lib/Log'
import theme from '../styles/theme'
import { theme } from '../styles'

type Props = {
enabled: boolean
Expand Down
4 changes: 2 additions & 2 deletions src/components/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
ViewStyle,
} from 'react-native'

import { fontSize, theme } from '../styles'
import appTextStyle from '../styles/text'
import theme from '../styles/theme'

type Props = {
text?: string
Expand Down Expand Up @@ -46,7 +46,7 @@ const styles = StyleSheet.create({
...appTextStyle.body,
color: theme.color.white,
lineHeight: theme.margin.common,
fontSize: theme.font.size.medium,
fontSize: fontSize.medium,
},
chipContainer: {
backgroundColor: theme.color.accentLime400,
Expand Down
11 changes: 5 additions & 6 deletions src/components/ContentImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { Dimensions, Image, StyleSheet, Text, TouchableOpacity, View } from 'rea
import ScalableImage from 'react-native-scalable-image'

import Lightbox from './Lightbox'
import font from '../styles/font'
import theme from '../styles/theme'
import { font, rounded, shadow, theme } from '../styles'

type Props = {
src: string
Expand Down Expand Up @@ -58,21 +57,21 @@ const styles = StyleSheet.create({
outerContainer: {
margin: -theme.margin.common,
marginBottom: -theme.margin.half,
...theme.shadow.ios,
...shadow.normal.ios,
},
innerContainer: {
flexDirection: 'row',
margin: theme.margin.common,
backgroundColor: theme.color.white,
...theme.shadow.android,
...theme.roundedLarge,
...shadow.normal.android,
...rounded.large,
borderWidth: 1,
borderColor: theme.color.grey50,
},
imageContainer: {
margin: theme.margin.common,
marginRight: theme.margin.half,
...theme.roundedLarge,
...rounded.large,
},
image: {
height: 80,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Date.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Props = {

const Date = ({ date, containerStyle }: Props) => (
<IconText
icon={<Icon name="calendar-day" style={'solid'} color={theme.color.grey300} size={theme.icon.size.medium} />}
icon={<Icon name="calendar-day" style={'solid'} color={theme.color.grey300} size={theme.icon.size.m} />}
text={date}
style={{
containerStyle,
Expand Down
4 changes: 2 additions & 2 deletions src/components/Disclose.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { StyleProp, StyleSheet, Text, TextStyle, TouchableOpacity, View, ViewSty

import { Icon } from './Icon'
import Log from '../lib/Log'
import { theme } from '../styles'
import appTextStyle from '../styles/text'
import theme from '../styles/theme'

type Props = {
text: string
Expand All @@ -19,7 +19,7 @@ const Disclose = ({ text, onPress, textStyle, containerStyle }: Props) => {
<TouchableOpacity activeOpacity={0.5} onPress={onPress}>
<View style={[styles.containerStyle, containerStyle]}>
<Text style={[appTextStyle.link, textStyle]}>{text}</Text>
<Icon name="chevron-right" size={theme.icon.size.extraLarge} />
<Icon name="chevron-right" size={theme.icon.size.xl} />
</View>
</TouchableOpacity>
)
Expand Down
4 changes: 2 additions & 2 deletions src/components/DocumentLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { StyleProp, ViewStyle } from 'react-native'

import { Icon } from './Icon'
import IconText from './IconText'
import { theme } from '../styles'
import textStyle from '../styles/text'
import theme from '../styles/theme'

type Props = {
onPress?: () => void
Expand All @@ -15,7 +15,7 @@ type Props = {

const DocumentLink = ({ onPress, containerStyle, label }: Props) => (
<IconText
icon={<Icon name="file-lines" size={theme.icon.size.medium} style="solid" />}
icon={<Icon name="file-lines" size={theme.icon.size.m} style="solid" />}
text={label}
style={{
containerStyle,
Expand Down
4 changes: 2 additions & 2 deletions src/components/FilterButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { StyleProp, StyleSheet, TouchableOpacity, ViewStyle } from 'react-native'

import theme from '../styles/theme'
import { rounded, theme } from '../styles'

type Props = {
content: (_: { color: string }) => React.ReactElement
Expand Down Expand Up @@ -29,7 +29,7 @@ export default FilterButton

const styles = StyleSheet.create({
container: {
...theme.rounded,
...rounded.normal,
justifyContent: 'center',
},
button: {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome'

import Icons, { IconName } from '../lib/Icons'
import theme from '../styles/theme'
import { theme } from '../styles'

export type IconStyleProp = 'light' | 'solid'

Expand All @@ -23,7 +23,7 @@ export const Icon = ({ name, color, size, testID, style, rotation }: IconProps):
const iconStyle = style ?? 'light'
const icon = iconStyle === 'light' ? Icons[name].light : Icons[name].solid
const iconColor = color ?? theme.color.primary500
const iconSize = size ?? theme.icon.size.large
const iconSize = size ?? theme.icon.size.l
const transform = rotation ? { rotate: rotation } : undefined

return <FontAwesomeIcon icon={icon} color={iconColor} size={iconSize} testID={testID} transform={transform} />
Expand Down
4 changes: 2 additions & 2 deletions src/components/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import { StyleProp, TouchableOpacity, ViewStyle } from 'react-native'

import { Icon, IconProps } from './Icon'
import theme from '../styles/theme'
import { theme } from '../styles'

type Props = {
containerStyle?: StyleProp<ViewStyle>
Expand All @@ -22,7 +22,7 @@ const IconButton = ({ containerStyle, disabled, onPress, icon, accessibilityLabe
onPress={disabled ? undefined : onPress}
activeOpacity={0.5}
>
<Icon size={theme.icon.size.large} {...icon} />
<Icon size={theme.icon.size.l} {...icon} />
</TouchableOpacity>
)

Expand Down
Loading