Skip to content

Commit ac3d0f0

Browse files
committed
Support for font family definitions
Testing initial PR from Shopify#233
1 parent 1795ad2 commit ac3d0f0

File tree

7 files changed

+28
-9
lines changed

7 files changed

+28
-9
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"**/*.js": true
2222
},
2323
"editor.codeActionsOnSave": {
24-
"source.fixAll.eslint": true
24+
"source.fixAll.eslint": "explicit"
2525
},
2626
"editor.formatOnSave": true,
2727
"[typescriptreact]": {

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

88
## Next
99

10+
## 2.5.0
11+
- Add support for defining fonts in the theme. [#232](https://github.com/Shopify/restyle/pull/232) by [ergenekonyigit](https://github.com/ergenekonyigit) & [gokselpirnal](https://github.com/gokselpirnal)
12+
1013
## 2.4.3 - 2023-04-18
1114

1215
- Fixed: clean up the project configuration for RN0.71, aligning some packages to the right version [#271](https://github.com/Shopify/restyle/pull/271) by [kelset](https://github.com/kelset) & [tido64](https://github.com/tido64)

documentation/docs/fundamentals/restyle-functions.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ The Restyle library comes with a number of predefined Restyle functions for your
2626
| shadow | shadowColor | colors |
2727
| textShadow | textShadowOffset, textShadowRadius | _none_ |
2828
| textShadow | textShadowColor | colors |
29-
| typography | fontFamily, fontSize, fontStyle, fontWeight, includeFontPadding, fontVariant, letterSpacing, lineHeight, textAlign, textAlignVertical, textDecorationColor, textDecorationLine, textDecorationStyle, textTransform, verticalAlign, writingDirection | _none_ |
29+
| typography | fontSize, fontStyle, fontWeight, includeFontPadding, fontVariant, letterSpacing, lineHeight, textAlign, textAlignVertical, textDecorationColor, textDecorationLine, textDecorationStyle, textTransform, verticalAlign, writingDirection | _none_ |
30+
| typography | fontFamily | fonts |
3031

3132
## Custom Restyle functions
3233

documentation/docs/guides/dark-mode.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ const theme = createTheme({
3838
secondaryCardText: palette.black,
3939
},
4040
textVariants: {
41+
breakpoints: {},
42+
fonts: {},
4143
defaults: {},
4244
body: {
4345
fontSize: 16,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@shopify/restyle",
3-
"version": "2.4.3",
3+
"version": "2.5.0",
44
"license": "MIT",
55
"description": "A system for building constraint-based UI components",
66
"main": "dist/index.js",

src/restyleFunctions.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ const spacingPropertiesShorthand = {
5353
};
5454

5555
const typographyProperties = {
56-
fontFamily: true,
5756
fontSize: true,
5857
fontStyle: true,
5958
fontWeight: true,
@@ -199,11 +198,17 @@ export const spacingShorthand = getKeys(spacingPropertiesShorthand).map(
199198
},
200199
);
201200

202-
export const typography = getKeys(typographyProperties).map(property => {
203-
return createRestyleFunction({
204-
property,
205-
});
206-
});
201+
export const typography = [
202+
...getKeys(typographyProperties).map(property => {
203+
return createRestyleFunction({
204+
property,
205+
});
206+
}),
207+
createRestyleFunction({
208+
property: 'fontFamily',
209+
themeKey: 'fonts',
210+
}),
211+
];
207212

208213
export const layout = getKeys(layoutProperties).map(property => {
209214
return createRestyleFunction({
@@ -327,6 +332,11 @@ export type TypographyProps<Theme extends BaseTheme> = {
327332
TextStyle[Key],
328333
Theme['breakpoints']
329334
>;
335+
} & {
336+
fontFamily?: ResponsiveValue<
337+
Theme['fonts'] extends object ? keyof Theme['fonts'] : string,
338+
Theme['breakpoints']
339+
>;
330340
};
331341

332342
export type LayoutProps<Theme extends BaseTheme> = {

src/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ export interface KnownBaseTheme {
4444
zIndices?: {
4545
[key: string]: number;
4646
};
47+
fonts?: {
48+
[key: string]: string;
49+
};
4750
borderRadii?: {
4851
[key: string]: number;
4952
};

0 commit comments

Comments
 (0)