File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ import { ThemeProvider } from 'paramount-ui'
6767 getContainerStyles?: GetContainerStyles;
6868 getRowStyles?: GetRowStyles;
6969 getTextInputStyles?: GetIconTextInputStyles;
70+ getLabelStyles?: GetLabelStyles;
7071 getListItemStyles?: GetListItemStyles;
7172 getOverlayStyles?: GetOverlayStyles;
7273 getPickerButtonStyles?: GetPickerButtonStyles;
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ export const FormField = (props: FormFieldProps) => {
7272
7373 const labelContent = (
7474 < View style = { labelWrapperStyle } >
75- < Label getStyles = { ( ) => ( { textStyle : labelTextStyle } ) } > { label } </ Label >
75+ < Label getStyles = { ( ) => ( { labelStyle : labelTextStyle } ) } > { label } </ Label >
7676 </ View >
7777 ) ;
7878
Original file line number Diff line number Diff line change @@ -28,15 +28,15 @@ Composes `Text`
2828Using ` getStyles ` prop
2929
3030```
31- TextStyles {
32- textStyle: TextStyle ;
31+ LabelStyles {
32+ labelStyle: LabelStyle ;
3333}
3434
35- getStyles={(TextProps , Theme) => TextStyles }
35+ getStyles={(LabelProps , Theme) => LabelStyles }
3636```
3737
3838Markup
3939
4040``` tsx
41- <Text textStyle />
41+ <Text labelStyle />
4242```
Original file line number Diff line number Diff line change 1+ import { TextStyle } from 'react-native' ;
2+
3+ import { Theme } from '../../theme/Theme' ;
4+ import { LabelProps } from './Label' ;
5+ import { getTextStyles } from './Text.styles' ;
6+
7+ export interface LabelStyles {
8+ labelStyle : TextStyle ;
9+ }
10+
11+ export type GetLabelStyles = ( props : LabelProps , theme : Theme ) => LabelStyles ;
12+
13+ export const getLabelStyles : GetLabelStyles = ( props , theme ) => {
14+ const { getStyles, ...rest } = props ;
15+ const { textStyle } = getTextStyles ( rest , theme ) ;
16+
17+ return { labelStyle : textStyle } ;
18+ } ;
Original file line number Diff line number Diff line change 11import * as React from 'react' ;
22import { Platform } from 'react-native' ;
3+ import { DeepPartial } from 'ts-essentials' ;
34
5+ import { useTheme } from '../../theme' ;
6+ import { mergeStyles , ReplaceReturnType } from '../../utils/mergeStyles' ;
7+ import { GetLabelStyles , getLabelStyles , LabelStyles } from './Label.styles' ;
48import { Text , TextProps } from './Text' ;
59
6- export const Label = ( props : TextProps ) => {
7- const { children, ...textProps } = props ;
10+ // tslint:disable-next-line
11+ // @ts -ignore
12+ export interface LabelProps extends TextProps {
13+ /** Callback to get element styles. */
14+ getStyles ?: ReplaceReturnType < GetLabelStyles , DeepPartial < LabelStyles > > ;
15+ }
16+
17+ export const Label = ( props : LabelProps ) => {
18+ const { children, getStyles, ...textProps } = props ;
19+ const theme = useTheme ( ) ;
20+
21+ const { labelStyle } = mergeStyles (
22+ getLabelStyles ,
23+ getStyles ,
24+ theme . components . getLabelStyles ,
25+ ) ( props , theme ) ;
826
927 return (
1028 < Text
1129 // @ts -ignore
1230 accessibilityRole = { Platform . OS === 'web' ? 'label' : 'none' }
31+ getStyles = { ( ) => ( { textStyle : labelStyle } ) }
1332 { ...textProps }
1433 >
1534 { children }
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ import { GetTabStyles } from '../components/Tabs/Tab.styles';
3131import { GetTabsStyles } from '../components/Tabs/Tabs.styles' ;
3232import { GetToastStyles } from '../components/Toast/Toast.styles' ;
3333import { GetHeadingStyles } from '../components/Typography/Heading.styles' ;
34+ import { GetLabelStyles } from '../components/Typography/Label.styles' ;
3435import { GetParagraphStyles } from '../components/Typography/Paragraph.styles' ;
3536import { GetTextStyles } from '../components/Typography/Text.styles' ;
3637import { defaultTheme } from './defaultTheme' ;
@@ -273,6 +274,7 @@ export interface Theme {
273274 getContainerStyles ?: GetContainerStyles ;
274275 getRowStyles ?: GetRowStyles ;
275276 getTextInputStyles ?: GetTextInputStyles ;
277+ getLabelStyles ?: GetLabelStyles ;
276278 getListItemStyles ?: GetListItemStyles ;
277279 getOverlayStyles ?: GetOverlayStyles ;
278280 getPickerButtonStyles ?: GetPickerButtonStyles ;
Original file line number Diff line number Diff line change @@ -16150,11 +16150,11 @@ exports[`Label_2 1`] = `<div />`;
1615016150exports[`Label_3 1`] = `
1615116151<pre>
1615216152 <code>
16153- TextStyles {
16154- textStyle: TextStyle ;
16153+ LabelStyles {
16154+ labelStyle: LabelStyle ;
1615516155}
1615616156
16157- getStyles={(TextProps , Theme) => TextStyles }
16157+ getStyles={(LabelProps , Theme) => LabelStyles }
1615816158
1615916159 </code>
1616016160</pre>
@@ -16165,7 +16165,7 @@ exports[`Label_4 1`] = `
1616516165 <code
1616616166 className="language-tsx"
1616716167 >
16168- <Text textStyle />
16168+ <Text labelStyle />
1616916169
1617016170 </code>
1617116171</pre>
You can’t perform that action at this time.
0 commit comments