Skip to content

Commit 4e7e78a

Browse files
committed
fix(typography): fix overriding issues
1 parent cb84ca1 commit 4e7e78a

13 files changed

Lines changed: 117 additions & 209 deletions

File tree

README.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,13 @@ More:
1515
- Built on TypeScript (typings!)
1616
- Tree-shaking friendly (ESM)
1717
- Server-side rendering friendly
18-
- Accessibility available (You can pass accessibility props on all touchable components)
1918
- [Styles in JavaScript](https://twitter.com/necolas/status/1058949412284592128)
2019

2120
# Documentation
2221

23-
[Getting started](https://wetrustplatform.github.io/paramount/docs-getting-started)
24-
[Customize theme](https://wetrustplatform.github.io/paramount/docs-customize-theme)
22+
[Getting started](https://github.com/WeTrustPlatform/paramount/blob/master/docs/GettingStarted.mdx)
23+
[Customize theme](https://github.com/WeTrustPlatform/paramount/blob/master/docs/CustomizeTheme.mdx)
2524

2625
# Contributing
2726

2827
Follow [Contributing guide](CONTRIBUTING.md)
29-
30-
## Sponsors
31-
32-
Special thanks to sponsors that help build paramount.
33-
34-
[![Browserstack](https://i1.wp.com/www.diogonunes.com/blog/wp-content/uploads/2016/07/browserstack-logo.png?w=512&ssl=1)](http://www.browserstack.com/)
35-
36-
Browserstack provides cross-browser testing tools. Used to test paramount components against different browsers including IE10

docs/Introduction.mdx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,3 @@ More:
1717
- Built on TypeScript (typings!)
1818
- Tree-shaking friendly (ESM)
1919
- [Styles in JavaScript](https://twitter.com/necolas/status/1058949412284592128)
20-
21-
### Sponsors
22-
23-
Special thanks to sponsors that help build paramount.
24-
25-
[![Browserstack](https://i1.wp.com/www.diogonunes.com/blog/wp-content/uploads/2016/07/browserstack-logo.png?w=512&ssl=1)](http://www.browserstack.com/)
26-
27-
Browserstack provides cross-browser testing tools. Used to test paramount components against different browsers including IE10

src/components/Counter/Counter.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ menu: Components
55

66
import { Counter as CounterContainer } from 'react-powerplug';
77
import { Playground, Props } from 'docz';
8-
import { Counter } from './Counter';
8+
import { Counter } from '.';
99
import { Spacing } from '../Layout';
1010

1111
# Counter

src/components/Typography/Heading.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Composes React Native's `Text` component (i.e. you can pass its props)
2222
align="center"
2323
size="xxlarge" // small - xxxlarge or number
2424
color="primary" // or custom
25+
weight="600"
2526
getStyles={(props, theme) => ({
2627
headingStyle: {},
2728
})}
@@ -41,3 +42,7 @@ Composes React Native's `Text` component (i.e. you can pass its props)
4142
<Heading size="small">small</Heading>
4243
</Box>
4344
</Playground>
45+
46+
### Props
47+
48+
<Props of={Heading} />

src/components/Typography/Heading.styles.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { TextStyle } from 'react-native';
22

33
import {
4+
FontWeight,
45
HeadingSize,
56
HeadingSizes,
67
TextColor,
78
Theme,
89
} from '../../theme/ThemeInterface';
9-
import { getTextColor } from './Text.styles';
10+
import { getFontWeight, getTextColor } from './Text.styles';
1011
import { TextAlign } from './types';
1112

1213
export interface HeadingVariables {
@@ -21,6 +22,7 @@ export interface HeadingStylesProps {
2122
size: HeadingSize;
2223
align: TextAlign;
2324
color: TextColor;
25+
weight?: FontWeight;
2426
}
2527

2628
export type GetHeadingStyles = (
@@ -38,15 +40,18 @@ export const getHeadingSize = (headingSizes: HeadingSizes) => (
3840
};
3941

4042
export const getHeadingStyles: GetHeadingStyles = (
41-
{ size, align, color },
43+
{ size, align, color, weight },
4244
theme,
4345
) => {
46+
const sizeStyle = getHeadingSize(theme.headingSizes)(size);
47+
4448
return {
4549
headingStyle: {
46-
...getHeadingSize(theme.headingSizes)(size),
50+
...sizeStyle,
4751
color: getTextColor(theme.colors.text)(color),
4852
fontFamily: theme.fontFamilies.heading,
49-
fontWeight: '600',
53+
fontWeight:
54+
getFontWeight(theme.fontWeights)(weight) || sizeStyle.fontWeight,
5055
textAlign: align,
5156
},
5257
};

src/components/Typography/Heading.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Platform, Text, TextProps } from 'react-native';
33
import { DeepPartial } from 'ts-essentials';
44

55
import { useTheme } from '../../theme';
6-
import { HeadingSize, TextColor } from '../../theme/ThemeInterface';
6+
import { FontWeight, HeadingSize, TextColor } from '../../theme/ThemeInterface';
77
import { mergeStyles, ReplaceReturnType } from '../../utils/mergeStyles';
88
import {
99
GetHeadingStyles,
@@ -17,6 +17,7 @@ export interface HeadingProps extends TextProps {
1717
size?: HeadingSize;
1818
align?: TextAlign;
1919
color?: TextColor;
20+
weight?: FontWeight;
2021
accessibilityLevel?: 1 | 2 | 3 | 4 | 5 | 6;
2122

2223
getStyles?: ReplaceReturnType<GetHeadingStyles, DeepPartial<HeadingStyles>>;
@@ -28,13 +29,14 @@ export const Heading = (props: HeadingProps) => {
2829
size = 'medium',
2930
align = 'left',
3031
color = 'default',
32+
weight,
3133
getStyles,
3234
...textProps
3335
} = props;
3436
const theme = useTheme();
3537

3638
const { headingStyle } = mergeStyles(getHeadingStyles, getStyles)(
37-
{ size, align, color },
39+
{ size, align, color, weight },
3840
theme,
3941
);
4042

src/components/Typography/Paragraph.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@ Composes React Native's `Text` component (i.e. you can pass its props)
4141
<Paragraph size="large">Lorem ipsum dolar set amet</Paragraph>
4242
</Box>
4343
</Playground>
44+
45+
### Props
46+
47+
<Props of={Paragraph} />

src/components/Typography/Paragraph.styles.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface ParagraphStylesProps {
2424
size: ParagraphSize;
2525
color: TextColor;
2626
fontFamily: FontFamily;
27-
weight: FontWeight;
27+
weight?: FontWeight;
2828
}
2929

3030
export interface ParagraphStyles {
@@ -49,12 +49,15 @@ export const getParagraphStyles: GetParagraphStyles = (
4949
{ size, color, fontFamily, align, weight },
5050
theme,
5151
) => {
52+
const sizeStyle = getParagraphSize(theme.paragraphSizes)(size);
53+
5254
return {
5355
paragraphStyle: {
54-
...getParagraphSize(theme.paragraphSizes)(size),
56+
...sizeStyle,
5557
color: getTextColor(theme.colors.text)(color),
5658
fontFamily: getFontFamily(theme.fontFamilies)(fontFamily),
57-
fontWeight: getFontWeight(theme.fontWeights)(weight),
59+
fontWeight:
60+
getFontWeight(theme.fontWeights)(weight) || sizeStyle.fontWeight,
5861
marginBottom: '1em',
5962
marginTop: '1em',
6063
textAlign: align,

src/components/Typography/Paragraph.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const Paragraph = (props: ParagraphProps) => {
3939
fontFamily = 'text',
4040
size = 'medium',
4141
align = 'left',
42-
weight = 'normal',
42+
weight,
4343
getStyles,
4444
...textProps
4545
} = props;

src/components/Typography/Text.mdx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,15 @@ Composes React Native's `Text` component (i.e. you can pass its props)
5151
<Playground>
5252
<Box flexDirection="column">
5353
<Text color="#16a054">#16a054</Text>
54-
<Text color="dark">dark</Text>
5554
<Text color="default">default</Text>
5655
<Text color="muted">muted</Text>
56+
<Text color="link">link</Text>
57+
<Text color="white">white</Text>
5758
<Text color="selected">selected</Text>
59+
<Text color="primary">primary</Text>
60+
<Text color="secondary">secondary</Text>
5861
<Text color="danger">danger</Text>
5962
<Text color="info">info</Text>
60-
<Text color="none">none</Text>
6163
<Text color="success">success</Text>
6264
<Text color="warning">warning</Text>
6365
</Box>
@@ -102,3 +104,7 @@ Composes React Native's `Text` component (i.e. you can pass its props)
102104
<Text transform="capitalize">Lorem ipsum dolar set amet</Text>
103105
</Box>
104106
</Playground>
107+
108+
### Props
109+
110+
<Props of={Text} />

0 commit comments

Comments
 (0)