@guardian/stand 0.0.6 → 0.0.7

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.
package/README.md CHANGED
@@ -116,15 +116,21 @@ import { css } from '@emotion/react';
116
116
  import { semanticColors } from '@guardian/stand'; // JS/TS usage
117
117
  import '@guardian/stand/semantic/colors.css'; // CSS usage
118
118
 
119
- const style = css`
119
+ const stringStyle = css`
120
120
  color: ${semanticColors.text.primary}; /* JS/TS usage */
121
121
  background-color: var(
122
122
  --semantic-colors-bg-default-on-light
123
123
  ); /* CSS usage */
124
124
  `;
125
+
126
+ const objectStyle = {
127
+ color: semanticColors.text.primary /* JS/TS usage */,
128
+ backgroundColor:
129
+ 'var(--semantic-colors-bg-default-on-light)' /* CSS usage */,
130
+ };
125
131
  ```
126
132
 
127
- For a list of available semantic color styles see the [Storybook Semantic Colors](https://68c12e3ed577cb56abfd31bf-ktzjjbdtby.chromatic.com/?path=/docs/stand-editorial-design-system-semantic-color-palette--docs) section.
133
+ For a list of available semantic color styles see the [Storybook Semantic Colors](https://68c12e3ed577cb56abfd31bf-kggeezequd.chromatic.com/?path=/docs/stand-editorial-design-system-semantic-color-palette--docs) section.
128
134
 
129
135
  For a full list of CSS Semantic Color tokens see [`semantic/colors.css`](./src/styleD/build/css/semantic/colors.css).
130
136
 
@@ -133,26 +139,48 @@ For a full list of CSS Semantic Color tokens see [`semantic/colors.css`](./src/s
133
139
  ```ts
134
140
  import { css } from '@emotion/react';
135
141
  import {
142
+ semanticColors,
136
143
  semanticTypography,
137
- convertTypographyToEmotion, // helper function to convert from typography token object to emotion CSS
144
+ convertTypographyToEmotionObjectStyle, // helper function to convert from typography token object to emotion CSS object style
145
+ convertTypographyToEmotionStringStyle, // helper function to convert from typography token object to emotion CSS string style
138
146
  } from '@guardian/stand'; // JS/TS usage
139
147
  import '@guardian/stand/semantic/typography.css'; // CSS usage
140
148
 
141
- const styleJS = css`
142
- /* JS/TS usage */
143
- ${convertTypographyToEmotion(semanticTypography['body-compact-md'])}
149
+ /* JS/TS usage */
150
+ const stringStyleJS = css`
151
+ ${convertTypographyToEmotionStringStyle(
152
+ semanticTypography['body-compact-md'],
153
+ )}
144
154
  `;
155
+ const objectStyleJS = {
156
+ // other styles e.g.
157
+ color: semanticColors.text.primary,
158
+
159
+ // typography styles
160
+ ...convertTypographyToEmotionObjectStyle(
161
+ semanticTypography['body-compact-sm'],
162
+ ),
163
+ };
145
164
 
146
- const styleCSS = css`
165
+ /* CSS usage */
166
+ const stringStyleCSS = css`
147
167
  /* CSS usage */
148
168
  font: var(--semantic-typography-body-compact-sm-font);
149
169
  letter-spacing: var(--semantic-typography-body-compact-sm-letter-spacing);
150
170
  font-variation-settings: 'wdth'
151
171
  var(--semantic-typography-body-compact-sm-font-width);
152
172
  `;
173
+ const objectStyleCSS = {
174
+ fontFamily: 'var(--semantic-typography-body-compact-sm-font-family)',
175
+ fontWeight: 'var(--semantic-typography-body-compact-sm-font-weight)',
176
+ fontSize: 'var(--semantic-typography-body-compact-sm-font-size)',
177
+ lineHeight: 'var(--semantic-typography-body-compact-sm-line-height)',
178
+ letterSpacing: 'var(--semantic-typography-body-compact-sm-letter-spacing)',
179
+ fontVariationSettings: `'wdth' var(--semantic-typography-body-compact-sm-font-variation-settings)`,
180
+ };
153
181
  ```
154
182
 
155
- For a list of available typography styles see the [Storybook Semantic Typography](https://68c12e3ed577cb56abfd31bf-ktzjjbdtby.chromatic.com/?path=/docs/stand-editorial-design-system-semantic-typography--docs) section.
183
+ For a list of available typography styles see the [Storybook Semantic Typography](https://68c12e3ed577cb56abfd31bf-kggeezequd.chromatic.com/?path=/docs/stand-editorial-design-system-semantic-typography--docs) section.
156
184
 
157
185
  For a full list of CSS Semantic Typography tokens see [`semantic/typography.css`](./src/styleD/build/css/semantic/typography.css).
158
186
 
@@ -165,13 +193,18 @@ import { css } from '@emotion/react';
165
193
  import { baseColors } from '@guardian/stand'; // JS/TS usage
166
194
  import '@guardian/stand/base/colors.css'; // CSS usage
167
195
 
168
- const style = css`
196
+ const stringStyle = css`
169
197
  color: ${baseColors.neutral['900']}; /* JS/TS usage */
170
198
  background-color: var(--base-colors-blue-500); /* CSS usage */
171
199
  `;
200
+
201
+ const objectStyle = {
202
+ color: baseColors.neutral['900'] /* JS/TS usage */,
203
+ backgroundColor: 'var(--base-colors-blue-500)' /* CSS usage */,
204
+ };
172
205
  ```
173
206
 
174
- For a list of the available base/primitives color styles see the [Storybook Base Colors](https://68c12e3ed577cb56abfd31bf-ktzjjbdtby.chromatic.com/?path=/docs/stand-editorial-design-system-base-color-palette--docs) section.
207
+ For a list of the available base/primitives color styles see the [Storybook Base Colors](https://68c12e3ed577cb56abfd31bf-kggeezequd.chromatic.com/?path=/docs/stand-editorial-design-system-base-color-palette--docs) section.
175
208
 
176
209
  For a full list of CSS Base/Primitives Color tokens see [`base/colors.css`](./src/styleD/build/css/base/colors.css).
177
210
 
@@ -182,19 +215,28 @@ import { css } from '@emotion/react';
182
215
  import { baseTypography } from '@guardian/stand'; // JS/TS usage
183
216
  import '@guardian/stand/base/typography.css'; // CSS usage
184
217
 
185
- const styleJs = css`
186
- /* JS/TS usage */
218
+ /* JS/TS usage */
219
+ const stringStyleJS = css`
187
220
  font-family: ${baseTypography.family['Open Sans']};
188
221
  font-size: ${baseTypography.size['14-px']};
189
222
  font-weight: ${baseTypography.weight['Open Sans'].normal};
190
223
  font-variation-settings: 'wdth' ${baseTypography.width['Open Sans']};
191
- font-style: ${baseTypography.style.normal};
224
+ style: ${baseTypography.style.normal};
192
225
  line-height: ${baseTypography.lineHeight.normal};
193
226
  letter-spacing: ${baseTypography.letterSpacing['default-px']};
194
227
  `;
228
+ const objectStyleJS = {
229
+ fontFamily: baseTypography.family['Open Sans'],
230
+ fontSize: baseTypography.size['14-px'],
231
+ fontWeight: baseTypography.weight['Open Sans'].normal,
232
+ fontVariationSettings: `'wdth' ${baseTypography.width['Open Sans']}`,
233
+ fontStyle: baseTypography.style.normal,
234
+ lineHeight: baseTypography.lineHeight.normal,
235
+ letterSpacing: baseTypography.letterSpacing['default-px'],
236
+ };
195
237
 
196
- const styleCss = css`
197
- /* CSS usage */
238
+ /* CSS usage */
239
+ const stringStyleCSS = css`
198
240
  font-family: var(--base-typography-family-open-sans);
199
241
  font-size: var(--base-typography-size-14-px);
200
242
  font-weight: var(--base-typography-weight-open-sans-normal);
@@ -203,9 +245,18 @@ const styleCss = css`
203
245
  line-height: var(--base-typography-line-height-normal);
204
246
  letter-spacing: var(--base-typography-letter-spacing-default-px);
205
247
  `;
248
+ const objectStyleCSS = {
249
+ fontFamily: 'var(--base-typography-family-open-sans)',
250
+ fontSize: 'var(--base-typography-size-14-px)',
251
+ fontWeight: 'var(--base-typography-weight-open-sans-normal)',
252
+ fontVariationSettings: `'wdth' var(--base-typography-width-open-sans)`,
253
+ fontStyle: 'var(--base-typography-style-normal)',
254
+ lineHeight: 'var(--base-typography-line-height-normal)',
255
+ letterSpacing: 'var(--base-typography-letter-spacing-default-px)',
256
+ };
206
257
  ```
207
258
 
208
- For a list of the available base/primitives typography tokens see the [Storybook Base Typography](https://68c12e3ed577cb56abfd31bf-ktzjjbdtby.chromatic.com/?path=/docs/stand-editorial-design-system-base-typography--docs) section.
259
+ For a list of the available base/primitives typography tokens see the [Storybook Base Typography](https://68c12e3ed577cb56abfd31bf-kggeezequd.chromatic.com/?path=/docs/stand-editorial-design-system-base-typography--docs) section.
209
260
 
210
261
  For a full list of CSS Base/Primitives Typography tokens see [`base/typography.css`](./src/styleD/build/css/base/typography.css).
211
262
 
package/dist/index.cjs CHANGED
@@ -18,4 +18,5 @@ exports.baseColors = colors.baseColors;
18
18
  exports.baseTypography = typography.baseTypography;
19
19
  exports.semanticColors = colors$1.semanticColors;
20
20
  exports.semanticTypography = typography$1.semanticTypography;
21
- exports.convertTypographyToEmotion = typography$2.convertTypographyToEmotion;
21
+ exports.convertTypographyToEmotionObjectStyle = typography$2.convertTypographyToEmotionObjectStyle;
22
+ exports.convertTypographyToEmotionStringStyle = typography$2.convertTypographyToEmotionStringStyle;
package/dist/index.js CHANGED
@@ -5,4 +5,4 @@ export { baseColors } from './styleD/build/typescript/base/colors.js';
5
5
  export { baseTypography } from './styleD/build/typescript/base/typography.js';
6
6
  export { semanticColors } from './styleD/build/typescript/semantic/colors.js';
7
7
  export { semanticTypography } from './styleD/build/typescript/semantic/typography.js';
8
- export { convertTypographyToEmotion } from './styleD/utils/semantic/typography.js';
8
+ export { convertTypographyToEmotionObjectStyle, convertTypographyToEmotionStringStyle } from './styleD/utils/semantic/typography.js';
@@ -2,7 +2,7 @@
2
2
 
3
3
  var react = require('@emotion/react');
4
4
 
5
- const convertTypographyToEmotion = (typography) => {
5
+ const convertTypographyToEmotionStringStyle = (typography) => {
6
6
  return react.css`
7
7
  font-family: ${typography.font.fontFamily};
8
8
  font-weight: ${typography.font.fontWeight};
@@ -13,5 +13,17 @@ const convertTypographyToEmotion = (typography) => {
13
13
  font-variation-settings: \"wdth\" ${typography.fontWidth};
14
14
  `;
15
15
  };
16
+ const convertTypographyToEmotionObjectStyle = (typography) => {
17
+ return {
18
+ fontFamily: typography.font.fontFamily,
19
+ fontWeight: typography.font.fontWeight,
20
+ fontSize: typography.font.fontSize,
21
+ fontStyle: typography.font.fontStyle,
22
+ lineHeight: typography.font.lineHeight,
23
+ letterSpacing: typography.letterSpacing,
24
+ fontVariationSettings: `"wdth" ${typography.fontWidth}`
25
+ };
26
+ };
16
27
 
17
- exports.convertTypographyToEmotion = convertTypographyToEmotion;
28
+ exports.convertTypographyToEmotionObjectStyle = convertTypographyToEmotionObjectStyle;
29
+ exports.convertTypographyToEmotionStringStyle = convertTypographyToEmotionStringStyle;
@@ -1,6 +1,6 @@
1
1
  import { css } from '@emotion/react';
2
2
 
3
- const convertTypographyToEmotion = (typography) => {
3
+ const convertTypographyToEmotionStringStyle = (typography) => {
4
4
  return css`
5
5
  font-family: ${typography.font.fontFamily};
6
6
  font-weight: ${typography.font.fontWeight};
@@ -11,5 +11,16 @@ const convertTypographyToEmotion = (typography) => {
11
11
  font-variation-settings: \"wdth\" ${typography.fontWidth};
12
12
  `;
13
13
  };
14
+ const convertTypographyToEmotionObjectStyle = (typography) => {
15
+ return {
16
+ fontFamily: typography.font.fontFamily,
17
+ fontWeight: typography.font.fontWeight,
18
+ fontSize: typography.font.fontSize,
19
+ fontStyle: typography.font.fontStyle,
20
+ lineHeight: typography.font.lineHeight,
21
+ letterSpacing: typography.letterSpacing,
22
+ fontVariationSettings: `"wdth" ${typography.fontWidth}`
23
+ };
24
+ };
14
25
 
15
- export { convertTypographyToEmotion };
26
+ export { convertTypographyToEmotionObjectStyle, convertTypographyToEmotionStringStyle };
@@ -23,4 +23,4 @@ export type { SemanticTypography } from './styleD/build/typescript/semantic/typo
23
23
  /**
24
24
  * utils exports
25
25
  */
26
- export { convertTypographyToEmotion } from './styleD/utils/semantic/typography';
26
+ export { convertTypographyToEmotionObjectStyle, convertTypographyToEmotionStringStyle, } from './styleD/utils/semantic/typography';
@@ -1,4 +1,4 @@
1
- import type { SerializedStyles } from '@emotion/react';
1
+ import type { CSSObject, SerializedStyles } from '@emotion/react';
2
2
  type SemanticTypography = {
3
3
  font: {
4
4
  fontFamily: string;
@@ -11,5 +11,6 @@ type SemanticTypography = {
11
11
  letterSpacing: string;
12
12
  fontWidth: number;
13
13
  };
14
- export declare const convertTypographyToEmotion: (typography: SemanticTypography) => SerializedStyles;
14
+ export declare const convertTypographyToEmotionStringStyle: (typography: SemanticTypography) => SerializedStyles;
15
+ export declare const convertTypographyToEmotionObjectStyle: (typography: SemanticTypography) => CSSObject;
15
16
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guardian/stand",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -41,6 +41,7 @@
41
41
  "@storybook/addon-themes": "^10.1.11",
42
42
  "@storybook/react-vite": "^10.1.11",
43
43
  "@terrazzo/cli": "^0.10.5",
44
+ "@testing-library/jest-dom": "^6.9.1",
44
45
  "@types/jest": "30.0.0",
45
46
  "@types/node": "^24.10.1",
46
47
  "@types/react": "17.0.76",