diff --git a/src/components/Accordion/Accordion.tsx b/src/components/Accordion/Accordion.tsx index 7c0bfcc1..9667e95c 100644 --- a/src/components/Accordion/Accordion.tsx +++ b/src/components/Accordion/Accordion.tsx @@ -1,7 +1,8 @@ import React, {useCallback, useMemo, useState} from 'react' -import {FlatList, StyleProp, Text, TextStyle, ViewStyle} from 'react-native' +import {FlatList, StyleSheet, StyleProp, Text, TextStyle, ViewStyle} from 'react-native' import {AccordionItem} from './AccordionItem' import type {AnimationType} from './ToggleAnimation' +import {useTheme} from '../../hooks' type ViewStyleProp = StyleProp | Array> type TextTitleStyleProp = StyleProp | Array> @@ -103,6 +104,7 @@ export interface AccordionProps extends CommonAccordionProps { const AccordionComponent = React.forwardRef( ({sections, expandMultiple = false, keyExtractor, wrapperStyle, ...rest}, ref) => { + const AccordionTheme = useTheme().components.Accordion const [array, setArray] = useState([]) const _keyExtractor = useMemo( @@ -149,7 +151,7 @@ const AccordionComponent = React.forwardRef( return ( = ({ outlineWidth={outlineWidth} borderRadius={borderRadius ?? ButtonTheme.borderRadius} disabled={disabled} - style={[{height: ButtonTheme.height}, StyleSheet.flatten(style)]} + style={[{height: ButtonTheme.height}, ButtonTheme.style, StyleSheet.flatten(style)]} {...props}> {!!leftIcon && leftIcon} {typeof children === 'string' ? ( diff --git a/src/components/Card/Card.tsx b/src/components/Card/Card.tsx index 09672943..ba0d626b 100644 --- a/src/components/Card/Card.tsx +++ b/src/components/Card/Card.tsx @@ -1,4 +1,5 @@ import React, {PropsWithChildren} from 'react' +import {StyleSheet} from 'react-native' import type {StyleProp, ViewStyle} from 'react-native' import styled from 'styled-components/native' import {activeOpacity} from '../../helpers' @@ -45,7 +46,7 @@ export const Card: React.FC = ({ ( return ( ( } return ( - + {labelComponent ? ( {labelComponent} diff --git a/src/components/CountDown/CountDown.tsx b/src/components/CountDown/CountDown.tsx index b85a6d44..68c94e3a 100644 --- a/src/components/CountDown/CountDown.tsx +++ b/src/components/CountDown/CountDown.tsx @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-shadow */ import React, {forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState} from 'react' -import {type ViewProps, type TextStyle, type StyleProp} from 'react-native' +import {type ViewProps, type TextStyle, type StyleProp, StyleSheet} from 'react-native' import styled from 'styled-components/native' import dayjs from 'dayjs' import {Text} from '../Text/Text' @@ -281,7 +281,7 @@ export const CountDown = forwardRef( fontSize={fontSize || CountDownTheme.fontSize} color={textColor || CountDownTheme.textColor} fontFamily={fontFamily || CountDownTheme.fontFamily} - style={textStyle || CountDownTheme.textStyle}> + style={[CountDownTheme.textStyle, StyleSheet.flatten(textStyle)]}> {value} {showLabels && ( @@ -289,7 +289,7 @@ export const CountDown = forwardRef( fontSize={CountDownTheme.labelFontSize} color={textColor || CountDownTheme.labelColor} fontFamily={fontFamily || CountDownTheme.fontFamily} - style={unitTextStyle || CountDownTheme.unitTextStyle}> + style={[CountDownTheme.unitTextStyle, StyleSheet.flatten(unitTextStyle)]}> {timeLabels[unit.toLowerCase() as keyof typeof timeLabels]} )} @@ -298,7 +298,7 @@ export const CountDown = forwardRef( fontSize={fontSize || CountDownTheme.fontSize} color={textColor || CountDownTheme.textColor} fontFamily={fontFamily || CountDownTheme.fontFamily} - style={textStyle || CountDownTheme.textStyle}> + style={[CountDownTheme.textStyle, StyleSheet.flatten(textStyle)]}> {separator} )} @@ -319,7 +319,7 @@ export const CountDown = forwardRef( return ( ( fontSize={fontSize || CountDownTheme.fontSize} color={textColor || CountDownTheme.textColor} fontFamily={fontFamily || CountDownTheme.fontFamily} - style={textStyle || CountDownTheme.textStyle}> + style={[CountDownTheme.textStyle, StyleSheet.flatten(textStyle)]}> - )} @@ -358,7 +358,7 @@ export const CountDown = forwardRef( : `Countdown: ${countDownTime} seconds` return ( ( color={textColor || CountDownTheme.textColor} fontSize={fontSize || CountDownTheme.fontSize} fontFamily={fontFamily || CountDownTheme.fontFamily} - style={textStyle || CountDownTheme.textStyle}> + style={[CountDownTheme.textStyle, StyleSheet.flatten(textStyle)]}> {countDownTime}s diff --git a/src/components/Icon/Icon.tsx b/src/components/Icon/Icon.tsx index ae1917bc..b01a01ba 100644 --- a/src/components/Icon/Icon.tsx +++ b/src/components/Icon/Icon.tsx @@ -46,7 +46,7 @@ export const Icon: React.FunctionComponent = ({ disabled={(!onPress && !onLongPress) || (disabled ?? IconTheme.disabled)} onPress={onPress} onLongPress={onLongPress} - style={buttonStyle ?? IconTheme.buttonStyle} + style={[IconTheme.buttonStyle, StyleSheet.flatten(buttonStyle)]} hitSlop={hitSlop}> = ({ height: size ?? IconTheme.size, tintColor: color ?? IconTheme.color, }, - StyleSheet.flatten(style ?? IconTheme.style), + IconTheme.style, + StyleSheet.flatten(style), ]} resizeMode={resizeMode ?? IconTheme.resizeMode} /> diff --git a/src/components/RadioButton/RadioButton.tsx b/src/components/RadioButton/RadioButton.tsx index 6a434e8e..4ed0e0fa 100644 --- a/src/components/RadioButton/RadioButton.tsx +++ b/src/components/RadioButton/RadioButton.tsx @@ -158,8 +158,8 @@ export const RadioButton = forwardRef( - {label} + style={[RadioButtonTheme.textContainerStyle, StyleSheet.flatten(textContainerStyle)]}> + {label} ) : null) @@ -170,7 +170,9 @@ export const RadioButton = forwardRef( } return ( - + ( disabled ?? RadioButtonTheme.disabled ? disableOpacity ?? RadioButtonTheme.disableOpacity : 1, borderWidth: RadioButtonTheme.borderWidth, }, - style ?? RadioButtonTheme.style, + RadioButtonTheme.style, + style, ])} onPress={handlePress} {...rest}> @@ -197,7 +200,7 @@ export const RadioButton = forwardRef( inner={inner} isActive={!!(value ?? isActive)} innerBackgroundColor={innerBackgroundColor ?? RadioButtonTheme.innerBackgroundColor ?? '#007AFF'} - style={innerContainerStyle ?? RadioButtonTheme.innerContainerStyle} + style={[RadioButtonTheme.innerContainerStyle, StyleSheet.flatten(innerContainerStyle)]} testID="circle" /> diff --git a/src/components/Slider/Slider.tsx b/src/components/Slider/Slider.tsx index 5256e396..b8714d2c 100644 --- a/src/components/Slider/Slider.tsx +++ b/src/components/Slider/Slider.tsx @@ -306,15 +306,16 @@ export const Slider: SliderComponentProps = ({ return ( - - + + {!!actualShowTrackPoint && ( actualTapToSeek && onPressPoint(point)} /> )} @@ -329,12 +330,16 @@ export const Slider: SliderComponentProps = ({ = ({ return ( ) diff --git a/src/theme/components/Accordion.ts b/src/theme/components/Accordion.ts index 594886b8..57bc479c 100644 --- a/src/theme/components/Accordion.ts +++ b/src/theme/components/Accordion.ts @@ -1,8 +1,12 @@ +import type {StyleProp, ViewStyle} from 'react-native' import base from '../base' -import type {ViewStyle} from 'react-native' import type {IFontWeight} from '../base/typography' export interface AccordionThemeProps { + /** + * Style for the wrapper container + */ + wrapperStyle?: StyleProp // Container styles container: { paddingBottom: number @@ -42,6 +46,7 @@ export interface AccordionThemeProps { } export const AccordionTheme: AccordionThemeProps = { + wrapperStyle: undefined, container: { paddingBottom: base.spacing.petite, overflow: 'hidden', diff --git a/src/theme/components/Button/Button.ts b/src/theme/components/Button/Button.ts index 4b615423..976fda17 100644 --- a/src/theme/components/Button/Button.ts +++ b/src/theme/components/Button/Button.ts @@ -1,9 +1,11 @@ +import type {StyleProp, ViewStyle} from 'react-native' import base from '../../base' import {metrics} from '../../../helpers' import type {ButtonProps} from '../../../components/Button/Button' export type ButtonThemeProps = { height?: number + style?: StyleProp } & Pick< ButtonProps, 'backgroundColor' | 'disabledColor' | 'borderRadius' | 'textColor' | 'outlineWidth' | 'outlineColor' @@ -15,4 +17,7 @@ export const ButtonTheme: ButtonThemeProps = { disabledColor: base.colors.muted, borderRadius: metrics.borderRadius, textColor: base.colors.white, + style: { + height: metrics.xxl, + }, } diff --git a/src/theme/components/Checkbox.ts b/src/theme/components/Checkbox.ts index d1e4d135..35c7b92f 100644 --- a/src/theme/components/Checkbox.ts +++ b/src/theme/components/Checkbox.ts @@ -1,8 +1,11 @@ +import type {StyleProp, ViewStyle} from 'react-native' import base from '../base' import {metrics} from '../../helpers' import type {ICheckboxProps} from '../../components/Checkbox/Checkbox' -export type CheckboxThemeProps = Pick< +export type CheckboxThemeProps = { + style?: StyleProp +} & Pick< ICheckboxProps, 'size' | 'borderRadius' | 'fillColor' | 'unfillColor' | 'checkMarkColor' | 'borderWidth' > @@ -14,4 +17,5 @@ export const CheckboxTheme: CheckboxThemeProps = { unfillColor: base.colors.transparent, checkMarkColor: base.colors.white, borderWidth: base.borderWidths.tiny, + style: undefined, } diff --git a/src/theme/components/CountDown.ts b/src/theme/components/CountDown.ts index 6238813f..66321724 100644 --- a/src/theme/components/CountDown.ts +++ b/src/theme/components/CountDown.ts @@ -1,33 +1,32 @@ -import {StyleProp, TextStyle} from 'react-native' +import type {StyleProp, ViewStyle, TextStyle} from 'react-native' import type {CountDownProps} from '../../components' import {metrics} from '../../helpers' import base from '../base' -export type CountDownThemeProps = Pick< - CountDownProps, - 'fontSize' | 'textColor' | 'fontFamily' | 'textStyle' -> & { - /** - * Font size for time unit labels (d, h, m, s) - */ - labelFontSize: number - /** - * Color for time unit labels - */ - labelColor: string - /** - * Font family for time unit labels - */ - fontFamily: string - /** - * Custom text style for countdown text - */ - textStyle?: StyleProp - /** - * Custom text style for time unit labels - */ - unitTextStyle?: StyleProp -} +export type CountDownThemeProps = { + style?: StyleProp +} & Pick & { + /** + * Font size for time unit labels (d, h, m, s) + */ + labelFontSize: number + /** + * Color for time unit labels + */ + labelColor: string + /** + * Font family for time unit labels + */ + fontFamily: string + /** + * Custom text style for countdown text + */ + textStyle?: StyleProp + /** + * Custom text style for time unit labels + */ + unitTextStyle?: StyleProp + } export const CountDownTheme: CountDownThemeProps = { fontSize: metrics.large, @@ -37,4 +36,5 @@ export const CountDownTheme: CountDownThemeProps = { fontFamily: base.fonts.regular as string, textStyle: undefined, // Optional custom text style unitTextStyle: undefined, // Optional custom unit text style + style: undefined, } diff --git a/src/theme/components/Typography.ts b/src/theme/components/Typography.ts index ad54f5d0..c1df0b32 100644 --- a/src/theme/components/Typography.ts +++ b/src/theme/components/Typography.ts @@ -1,4 +1,4 @@ -import type {TextStyle} from 'react-native' +import type {StyleProp, TextStyle} from 'react-native' import base from '../base' // Define types locally since TypographyProps is not exported export type TypographyVariant = 'h1' | 'h2' | 'regular' | 'bold' @@ -12,6 +12,10 @@ export type TypographyThemeProps = Pick & * Default typography variant styles */ variantStyles: Record + /** + * Default style for typography component + */ + style?: StyleProp } export const TypographyTheme: TypographyThemeProps = { @@ -39,4 +43,5 @@ export const TypographyTheme: TypographyThemeProps = { lineHeight: 24, }, }, + style: undefined, }