@gympass/yoga 7.105.0 → 7.106.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,8 @@
1
1
  import { css } from "styled-components";
2
2
  import defaultStyle from "./sharedTextStyle";
3
+ const formatFontFamily = (fontFamily, fontWeight) => {
4
+ return fontWeight === 400 ? fontFamily : `${fontFamily}-${fontWeight}`;
5
+ };
3
6
  const textStyle = (type) => () => css`
4
7
  ${defaultStyle(type)};
5
8
  ${({
@@ -8,26 +11,20 @@ const textStyle = (type) => () => css`
8
11
  theme: {
9
12
  yoga: {
10
13
  baseFont,
11
- fontWeights,
12
- components: {
13
- text: {
14
- [type]: { fontFamily, fontWeight }
15
- }
16
- }
14
+ components: { text }
17
15
  }
18
16
  }
19
17
  }) => {
20
- let finalFontFamily;
21
- if (fontFamily) {
22
- finalFontFamily = `${fontFamily}-${fontWeight}`;
23
- } else {
24
- finalFontFamily = fontWeight === 400 ? baseFont.family : `${baseFont.family}-${fontWeight}`;
18
+ const fontFamily = text[type].fontFamily || baseFont.family;
19
+ let finalFontWeight = text[type].fontWeight;
20
+ if (light && text[`${type}-light`]) {
21
+ finalFontWeight = text[`${type}-light`].fontWeight;
22
+ }
23
+ if (bold && text[`${type}-bold`]) {
24
+ finalFontWeight = text[`${type}-bold`].fontWeight;
25
25
  }
26
26
  return css`
27
- font-family: '${finalFontFamily}';
28
-
29
- ${light ? `font-family: ${baseFont.family}-${fontWeights.light};` : ""}
30
- ${bold ? `font-family: ${baseFont.family}-${fontWeights.bold};` : ""}
27
+ font-family: '${formatFontFamily(fontFamily, finalFontWeight)}';
31
28
  `;
32
29
  }}
33
30
  `;
@@ -8,21 +8,21 @@ const textStyle = (type) => () => css`
8
8
  theme: {
9
9
  yoga: {
10
10
  baseFont,
11
- fontWeights,
12
- components: {
13
- text: {
14
- [type]: { fontFamily, fontWeight }
15
- }
16
- }
11
+ components: { text }
17
12
  }
18
13
  }
19
14
  }) => {
20
- const finalFontFamily = fontFamily || baseFont.family;
15
+ const fontFamily = text[type].fontFamily || baseFont.family;
16
+ let finalFontWeight = text[type].fontWeight;
17
+ if (light && text[`${type}-light`]) {
18
+ finalFontWeight = text[`${type}-light`].fontWeight;
19
+ }
20
+ if (bold && text[`${type}-bold`]) {
21
+ finalFontWeight = text[`${type}-bold`].fontWeight;
22
+ }
21
23
  return css`
22
- font-family: ${finalFontFamily};
23
- ${fontWeight ? `font-weight: ${fontWeight};` : ""}
24
- ${light ? `font-weight: ${fontWeights.light};` : ""}
25
- ${bold ? `font-weight: ${fontWeights.bold};` : ""}
24
+ font-family: ${fontFamily};
25
+ ${finalFontWeight ? `font-weight: ${finalFontWeight};` : ""}
26
26
  `;
27
27
  }}
28
28
  `;
@@ -10,15 +10,18 @@ const textStyle = (type) => () => css`
10
10
  theme: {
11
11
  yoga: {
12
12
  baseFont,
13
- fontWeights,
14
- components: {
15
- text: {
16
- [type]: { fontFamily, fontWeight }
17
- }
18
- }
13
+ components: { text }
19
14
  }
20
15
  }
21
16
  }) => {
17
+ const themeFontFamily = text[type].fontFamily ? `${text[type].fontFamily}, ` : "";
18
+ let finalFontWeight = text[type].fontWeight;
19
+ if (light && text[`${type}-light`]) {
20
+ finalFontWeight = text[`${type}-light`].fontWeight;
21
+ }
22
+ if (bold && text[`${type}-bold`]) {
23
+ finalFontWeight = text[`${type}-bold`].fontWeight;
24
+ }
22
25
  return css`
23
26
  ${numberOfLines ? `
24
27
  display: -webkit-box;
@@ -27,10 +30,8 @@ const textStyle = (type) => () => css`
27
30
  overflow: hidden;
28
31
  ` : ""}
29
32
 
30
- font-family: ${fontFamily ? `${fontFamily}, ` : ""}${baseFont.family};
31
- ${fontWeight ? `font-weight: ${fontWeight};` : ""}
32
- ${light ? `font-weight: ${fontWeights.light};` : ""}
33
- ${bold ? `font-weight: ${fontWeights.bold};` : ""}
33
+ font-family: ${`${themeFontFamily}${baseFont.family}`};
34
+ ${finalFontWeight ? `font-weight: ${finalFontWeight};` : ""}
34
35
  `;
35
36
  }}
36
37
  `;
@@ -1,8 +1,8 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import React from "react";
3
3
  import { render } from "@testing-library/react";
4
- import { ThemeProvider } from "../..";
5
4
  import { Text } from ".";
5
+ import { ThemeProvider, v3theme } from "../..";
6
6
  describe("<Text />", () => {
7
7
  describe("Snapshots", () => {
8
8
  it("should match snapshot with Text", () => {
@@ -35,6 +35,36 @@ describe("<Text />", () => {
35
35
  );
36
36
  expect(container).toMatchSnapshot();
37
37
  });
38
+ it("should match snapshot with Text when v3theme is settled", () => {
39
+ const { container } = render(
40
+ /* @__PURE__ */ jsxs(ThemeProvider, { theme: v3theme, children: [
41
+ /* @__PURE__ */ jsx(Text.Display1, { children: "Text Display1" }),
42
+ /* @__PURE__ */ jsx(Text.Display2, { children: "Text Display2" }),
43
+ /* @__PURE__ */ jsx(Text.Display3, { children: "Text Display3" }),
44
+ /* @__PURE__ */ jsx(Text.Display4, { children: "Text Display4" }),
45
+ /* @__PURE__ */ jsx(Text.DisplayNumber, { children: "Text DisplayNumber" }),
46
+ /* @__PURE__ */ jsx(Text.H1, { children: "Text H1" }),
47
+ /* @__PURE__ */ jsx(Text.H2, { children: "Text H2" }),
48
+ /* @__PURE__ */ jsx(Text.H3, { children: "Text H3" }),
49
+ /* @__PURE__ */ jsx(Text.H4, { children: "Text H4" }),
50
+ /* @__PURE__ */ jsx(Text.H5, { children: "Text H5" }),
51
+ /* @__PURE__ */ jsx(Text.Body1, { children: "Text Body1" }),
52
+ /* @__PURE__ */ jsx(Text.Body2, { children: "Text Body2" }),
53
+ /* @__PURE__ */ jsx(Text.Caption, { children: "Text Caption" }),
54
+ /* @__PURE__ */ jsx(Text.Overline, { children: "Text Overline" }),
55
+ /* @__PURE__ */ jsx(Text.SectionTitle, { children: "Text SectionTitle" }),
56
+ /* @__PURE__ */ jsx(Text.SmallestException, { children: "Text SmallestException" }),
57
+ /* @__PURE__ */ jsx(Text, { children: "Text" }),
58
+ /* @__PURE__ */ jsx(Text.Small, { children: "Text Small" }),
59
+ /* @__PURE__ */ jsx(Text.Tiny, { children: "Text Tiny" }),
60
+ /* @__PURE__ */ jsx(Text.Regular, { children: "Text Regular" }),
61
+ /* @__PURE__ */ jsx(Text.Medium, { children: "Text Medium" }),
62
+ /* @__PURE__ */ jsx(Text.Bold, { children: "Text Bold" }),
63
+ /* @__PURE__ */ jsx(Text.Black, { children: "Text Black" })
64
+ ] })
65
+ );
66
+ expect(container).toMatchSnapshot();
67
+ });
38
68
  it("should match snapshot with Text variant", () => {
39
69
  const { container } = render(
40
70
  /* @__PURE__ */ jsxs(ThemeProvider, { children: [
@@ -49,7 +49,164 @@ const v3theme = createTheme((tokens) => ({
49
49
  backgroundAndDisabled: tokens.colors.clearNew
50
50
  }
51
51
  },
52
- baseFont: tokens.fonts.inter
52
+ baseFont: tokens.fonts.inter,
53
+ components: {
54
+ text: {
55
+ display1: {
56
+ fontFamily: "NaN Holo Condensed",
57
+ fontsize: tokens.fontSizes.xhuge,
58
+ fontWeight: tokens.fontWeights.bold,
59
+ lineHeight: tokens.lineHeights.xhuge
60
+ },
61
+ display2: {
62
+ fontFamily: "NaN Holo Condensed",
63
+ fontsize: tokens.fontSizes.xxxlarge,
64
+ fontWeight: tokens.fontWeights.bold,
65
+ lineHeight: tokens.lineHeights.xxlarge
66
+ },
67
+ display3: {
68
+ fontFamily: "NaN Holo Condensed",
69
+ fontsize: tokens.fontSizes.xxlarge,
70
+ fontWeight: tokens.fontWeights.bold,
71
+ lineHeight: tokens.lineHeights.xlarge
72
+ },
73
+ display4: {
74
+ fontFamily: "NaN Holo Condensed",
75
+ fontsize: tokens.fontSizes.xlarge,
76
+ fontWeight: tokens.fontWeights.bold,
77
+ lineHeight: tokens.lineHeights.medium
78
+ },
79
+ displayNumber: {
80
+ fontFamily: "NaN Holo Condensed",
81
+ fontsize: tokens.fontSizes.xxxlarge,
82
+ fontWeight: tokens.fontWeights.bold,
83
+ lineHeight: tokens.lineHeights.xxlarge
84
+ },
85
+ h1: {
86
+ fontsize: tokens.fontSizes.huge,
87
+ fontWeight: tokens.fontWeights.medium,
88
+ lineHeight: tokens.lineHeights.huge
89
+ },
90
+ "h1-light": null,
91
+ "h1-bold": {
92
+ fontWeight: tokens.fontWeights.bold
93
+ },
94
+ h2: {
95
+ fontsize: tokens.fontSizes.xxxlarge,
96
+ fontWeight: tokens.fontWeights.medium,
97
+ lineHeight: tokens.lineHeights.xxxlarge
98
+ },
99
+ "h2-light": null,
100
+ "h2-bold": {
101
+ fontWeight: tokens.fontWeights.bold
102
+ },
103
+ h3: {
104
+ fontsize: tokens.fontSizes.xxlarge,
105
+ lineHeight: tokens.lineHeights.xxlarge,
106
+ fontWeight: tokens.fontWeights.medium
107
+ },
108
+ "h3-light": null,
109
+ "h3-bold": {
110
+ fontWeight: tokens.fontWeights.bold
111
+ },
112
+ h4: {
113
+ fontsize: tokens.fontSizes.xlarge,
114
+ fontWeight: tokens.fontWeights.medium,
115
+ lineHeight: tokens.lineHeights.xlarge
116
+ },
117
+ "h4-light": null,
118
+ "h4-bold": {
119
+ fontWeight: tokens.fontWeights.bold
120
+ },
121
+ h5: {
122
+ fontsize: tokens.fontSizes.large,
123
+ fontWeight: tokens.fontWeights.medium,
124
+ lineHeight: tokens.lineHeights.large
125
+ },
126
+ "h5-light": null,
127
+ "h5-bold": {
128
+ fontWeight: tokens.fontWeights.bold
129
+ },
130
+ body1: {
131
+ fontsize: tokens.fontSizes.medium,
132
+ fontWeight: tokens.fontWeights.medium,
133
+ lineHeight: tokens.lineHeights.medium
134
+ },
135
+ "body1-bold": {
136
+ fontWeight: tokens.fontWeights.bold
137
+ },
138
+ body2: {
139
+ fontsize: tokens.fontSizes.small,
140
+ fontWeight: tokens.fontWeights.medium,
141
+ lineHeight: tokens.lineHeights.small
142
+ },
143
+ "body2-bold": {
144
+ fontWeight: tokens.fontWeights.bold
145
+ },
146
+ caption: {
147
+ fontsize: tokens.fontSizes.xsmall,
148
+ fontWeight: tokens.fontWeights.regular,
149
+ lineHeight: tokens.lineHeights.xsmall
150
+ },
151
+ overline: {
152
+ fontsize: tokens.fontSizes.xsmall,
153
+ fontWeight: tokens.fontWeights.bold,
154
+ lineHeight: tokens.lineHeights.xsmall
155
+ },
156
+ sectionTitle: {
157
+ fontsize: tokens.fontSizes.xsmall,
158
+ fontWeight: tokens.fontWeights.medium,
159
+ lineHeight: tokens.lineHeights.xsmall,
160
+ letterSpacing: 1,
161
+ textTransform: "uppercase"
162
+ },
163
+ smallestException: {
164
+ fontsize: tokens.fontSizes.xxsmall,
165
+ fontWeight: tokens.fontWeights.regular,
166
+ lineHeight: tokens.lineHeights.xxsmall
167
+ },
168
+ // deprecated, please don't use
169
+ p: {
170
+ fontsize: tokens.fontSizes.medium,
171
+ fontWeight: tokens.fontWeights.medium,
172
+ lineHeight: tokens.lineHeights.medium
173
+ },
174
+ "p-light": null,
175
+ "p-bold": {
176
+ fontWeight: tokens.fontWeights.bold
177
+ },
178
+ small: {
179
+ fontsize: tokens.fontSizes.small,
180
+ fontWeight: tokens.fontWeights.medium,
181
+ lineHeight: tokens.lineHeights.small
182
+ },
183
+ "small-light": null,
184
+ "small-bold": {
185
+ fontWeight: tokens.fontWeights.bold
186
+ },
187
+ tiny: {
188
+ fontsize: tokens.fontSizes.xsmall,
189
+ fontWeight: tokens.fontWeights.regular,
190
+ lineHeight: tokens.lineHeights.xsmall
191
+ },
192
+ "tiny-light": null,
193
+ light: {
194
+ fontWeight: tokens.fontWeights.light
195
+ },
196
+ regular: {
197
+ fontWeight: tokens.fontWeights.regular
198
+ },
199
+ medium: {
200
+ fontWeight: tokens.fontWeights.medium
201
+ },
202
+ bold: {
203
+ fontWeight: tokens.fontWeights.bold
204
+ },
205
+ black: {
206
+ fontWeight: tokens.fontWeights.black
207
+ }
208
+ }
209
+ }
53
210
  }));
54
211
  export {
55
212
  v3theme
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gympass/yoga",
3
- "version": "7.105.0",
3
+ "version": "7.106.0",
4
4
  "description": "Gympass component library",
5
5
  "main": "./cjs",
6
6
  "types": "./typings/index.d.ts",
@@ -57,7 +57,7 @@
57
57
  "react-native": "0.72.3",
58
58
  "styled-components": "^4.4.0"
59
59
  },
60
- "gitHead": "6190e4f67b4d9ac5a78d43e3fecd6c6d09ddc649",
60
+ "gitHead": "22aaf247b6ebdfa5b26898a21afbfddb3e604445",
61
61
  "module": "./esm",
62
62
  "private": false,
63
63
  "react-native": "./cjs/index.native.js"