@alfalab/core-components-typography 3.2.2 → 4.0.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.
Files changed (82) hide show
  1. package/colors.css +20 -20
  2. package/colors.module-1c06b16d.js +6 -0
  3. package/common.module-00fb3f71.js +6 -0
  4. package/component.js +2 -2
  5. package/cssm/title-responsive/index.module.css +14 -64
  6. package/esm/colors.css +20 -20
  7. package/esm/colors.module-d9f55bc3.js +4 -0
  8. package/esm/common.module-39c4c6a5.js +4 -0
  9. package/esm/component.js +2 -2
  10. package/esm/index.js +2 -2
  11. package/esm/text/component.js +2 -2
  12. package/esm/text/index.css +18 -19
  13. package/esm/text/index.js +1 -1
  14. package/esm/title/common.css +5 -5
  15. package/esm/title/component.js +1 -1
  16. package/esm/title/index.css +19 -19
  17. package/esm/title/index.js +3 -3
  18. package/esm/title-mobile/component.js +3 -3
  19. package/esm/title-mobile/index.css +11 -11
  20. package/esm/title-mobile/index.js +2 -2
  21. package/esm/title-responsive/component.js +3 -3
  22. package/esm/title-responsive/index.css +44 -94
  23. package/esm/title-responsive/index.js +2 -2
  24. package/index.js +2 -2
  25. package/modern/colors.css +20 -20
  26. package/modern/colors.module-d0f9b310.js +4 -0
  27. package/modern/common.module-47d6bc91.js +4 -0
  28. package/modern/component.js +2 -2
  29. package/modern/index.js +2 -2
  30. package/modern/text/component.js +2 -2
  31. package/modern/text/index.css +18 -19
  32. package/modern/text/index.js +1 -1
  33. package/modern/title/common.css +5 -5
  34. package/modern/title/component.js +1 -1
  35. package/modern/title/index.css +19 -19
  36. package/modern/title/index.js +3 -3
  37. package/modern/title-mobile/component.js +3 -3
  38. package/modern/title-mobile/index.css +11 -11
  39. package/modern/title-mobile/index.js +2 -2
  40. package/modern/title-responsive/component.js +3 -3
  41. package/modern/title-responsive/index.css +44 -94
  42. package/modern/title-responsive/index.js +2 -2
  43. package/package.json +1 -1
  44. package/src/colors.module.css +79 -0
  45. package/src/colors.ts +23 -0
  46. package/src/component.tsx +19 -0
  47. package/src/index.ts +5 -0
  48. package/src/margins.module.css +11 -0
  49. package/src/presets.ts +17 -0
  50. package/src/text/component.tsx +116 -0
  51. package/src/text/index.module.css +76 -0
  52. package/src/text/index.ts +1 -0
  53. package/src/title/common.module.css +16 -0
  54. package/src/title/component.tsx +105 -0
  55. package/src/title/index.module.css +75 -0
  56. package/src/title/index.tsx +17 -0
  57. package/src/title-mobile/component.tsx +16 -0
  58. package/src/title-mobile/index.module.css +42 -0
  59. package/src/title-mobile/index.tsx +1 -0
  60. package/src/title-responsive/component.tsx +14 -0
  61. package/src/title-responsive/index.module.css +126 -0
  62. package/src/title-responsive/index.tsx +1 -0
  63. package/src/types.ts +1 -0
  64. package/text/component.js +2 -2
  65. package/text/index.css +18 -19
  66. package/text/index.js +1 -1
  67. package/title/common.css +5 -5
  68. package/title/component.js +1 -1
  69. package/title/index.css +19 -19
  70. package/title/index.js +3 -3
  71. package/title-mobile/component.js +3 -3
  72. package/title-mobile/index.css +11 -11
  73. package/title-mobile/index.js +2 -2
  74. package/title-responsive/component.js +3 -3
  75. package/title-responsive/index.css +44 -94
  76. package/title-responsive/index.js +2 -2
  77. package/colors.module-a848b027.js +0 -6
  78. package/common.module-7493433e.js +0 -6
  79. package/esm/colors.module-996156cd.js +0 -4
  80. package/esm/common.module-bbfef03a.js +0 -4
  81. package/modern/colors.module-f2c54769.js +0 -4
  82. package/modern/common.module-888addc3.js +0 -4
package/src/presets.ts ADDED
@@ -0,0 +1,17 @@
1
+ export const typographyPresets = {
2
+ mobile: {
3
+ list: {
4
+ text: {
5
+ primary: {
6
+ tag: 'div',
7
+ view: 'primary-medium',
8
+ },
9
+ secondary: {
10
+ tag: 'div',
11
+ color: 'secondary',
12
+ view: 'primary-small',
13
+ },
14
+ },
15
+ },
16
+ },
17
+ };
@@ -0,0 +1,116 @@
1
+ import React, { forwardRef, HTMLAttributes } from 'react';
2
+ import cn from 'classnames';
3
+
4
+ import { Color } from '../colors';
5
+ import { TextElementType } from '../types';
6
+
7
+ import colors from '../colors.module.css';
8
+ import styles from './index.module.css';
9
+
10
+ type NativeProps = HTMLAttributes<HTMLSpanElement>;
11
+
12
+ type TextBaseProps = {
13
+ /**
14
+ * [Вариант начертания](https://core-ds.github.io/core-components/master/?path=/docs/tokens-assets-типографика--docs)
15
+ */
16
+ view?:
17
+ | 'primary-large'
18
+ | 'primary-medium'
19
+ | 'primary-small'
20
+ | 'secondary-large'
21
+ | 'secondary-medium'
22
+ | 'secondary-small'
23
+ | 'component'
24
+ | 'caps';
25
+
26
+ /**
27
+ * Цвет текста
28
+ */
29
+ color?: Color;
30
+
31
+ /**
32
+ * Толщина шрифта
33
+ */
34
+ weight?: 'regular' | 'medium' | 'bold';
35
+
36
+ /**
37
+ * Делает цифры моноширинными
38
+ */
39
+ monospaceNumbers?: boolean;
40
+
41
+ /**
42
+ * HTML тег
43
+ */
44
+ tag?: 'span' | 'div';
45
+
46
+ /**
47
+ * Css-класс для стилизации (native prop)
48
+ */
49
+ className?: string;
50
+
51
+ /**
52
+ * Id компонента для тестов
53
+ */
54
+ dataTestId?: string;
55
+
56
+ /**
57
+ * Контент (native prop)
58
+ */
59
+ children?: React.ReactNode;
60
+
61
+ /**
62
+ * Добавляет отступы к тэгу 'p'
63
+ */
64
+ defaultMargins?: never;
65
+
66
+ /**
67
+ * Количество строк (не поддерживает IE)
68
+ */
69
+ rowLimit?: 1 | 2 | 3;
70
+ };
71
+
72
+ type TextPTagProps = Omit<TextBaseProps, 'tag' | 'defaultMargins'> & {
73
+ tag?: 'p';
74
+ defaultMargins?: boolean;
75
+ };
76
+
77
+ export type TextProps = Omit<NativeProps, 'color'> & (TextBaseProps | TextPTagProps);
78
+
79
+ export const Text = forwardRef<TextElementType, TextProps>(
80
+ (
81
+ {
82
+ view = 'primary-medium',
83
+ tag: Component = 'span',
84
+ weight,
85
+ monospaceNumbers = false,
86
+ defaultMargins = true,
87
+ color,
88
+ className,
89
+ dataTestId,
90
+ children,
91
+ rowLimit,
92
+ ...restProps
93
+ },
94
+ ref,
95
+ ) => (
96
+ <Component
97
+ className={cn(
98
+ {
99
+ [styles.paragraph]: Component === 'p' && !defaultMargins,
100
+ [styles.paragraphWithMargins]: Component === 'p' && defaultMargins,
101
+ [styles.monospace]: monospaceNumbers,
102
+ [styles[`rowLimit${rowLimit}`]]: rowLimit,
103
+ },
104
+ className,
105
+ color && colors[color],
106
+ styles[view],
107
+ weight && styles[weight],
108
+ )}
109
+ data-test-id={dataTestId}
110
+ ref={ref as never}
111
+ {...restProps}
112
+ >
113
+ {children}
114
+ </Component>
115
+ ),
116
+ );
@@ -0,0 +1,76 @@
1
+ @import '@alfalab/core-components-themes/src/default.css';
2
+
3
+ :root {
4
+ --text-paragraph-margin-bottom: 0 0 var(--gap-s);
5
+ }
6
+
7
+ .paragraph {
8
+ margin: 0;
9
+ padding: 0;
10
+ }
11
+
12
+ .paragraphWithMargins {
13
+ padding: 0;
14
+ margin: var(--text-paragraph-margin-bottom);
15
+ }
16
+
17
+ .primary-large {
18
+ @mixin paragraph_primary_large;
19
+ }
20
+
21
+ .primary-medium {
22
+ @mixin paragraph_primary_medium;
23
+ }
24
+
25
+ .primary-small {
26
+ @mixin paragraph_primary_small;
27
+ }
28
+
29
+ .secondary-large {
30
+ @mixin paragraph_secondary_large;
31
+ }
32
+
33
+ .secondary-medium {
34
+ @mixin paragraph_secondary_medium;
35
+ }
36
+
37
+ .secondary-small {
38
+ @mixin paragraph_secondary_small;
39
+ }
40
+
41
+ .component {
42
+ @mixin paragraph_component;
43
+ }
44
+
45
+ .caps {
46
+ @mixin paragraph_caps;
47
+ }
48
+
49
+ .bold {
50
+ font-weight: bold;
51
+ }
52
+
53
+ .medium {
54
+ font-weight: 500;
55
+ }
56
+
57
+ .regular {
58
+ font-weight: normal;
59
+ }
60
+
61
+ .monospace {
62
+ font-variant-numeric: tabular-nums;
63
+ }
64
+
65
+ .rowLimit1 {
66
+ @mixin row_limit 1;
67
+ word-break: break-all;
68
+ }
69
+
70
+ .rowLimit2 {
71
+ @mixin row_limit 2;
72
+ }
73
+
74
+ .rowLimit3 {
75
+ @mixin row_limit 3;
76
+ }
@@ -0,0 +1 @@
1
+ export * from './component';
@@ -0,0 +1,16 @@
1
+ .component {
2
+ margin: 0;
3
+ padding: 0;
4
+
5
+ &.bold {
6
+ font-weight: bold;
7
+ }
8
+
9
+ &.medium {
10
+ font-weight: 500;
11
+ }
12
+
13
+ &.regular {
14
+ font-weight: normal;
15
+ }
16
+ }
@@ -0,0 +1,105 @@
1
+ import React, { forwardRef, HTMLAttributes } from 'react';
2
+ import cn from 'classnames';
3
+
4
+ import { Color } from '../colors';
5
+
6
+ import colors from '../colors.module.css';
7
+
8
+ type NativeProps = HTMLAttributes<HTMLHeadingElement>;
9
+
10
+ export type TitleProps = Omit<NativeProps, 'color'> & {
11
+ /**
12
+ * HTML тег
13
+ */
14
+ tag: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'div';
15
+
16
+ /**
17
+ * [Вариант начертания](https://core-ds.github.io/core-components/master/?path=/docs/guidelines-typography--page)
18
+ */
19
+ view?: 'xlarge' | 'large' | 'medium' | 'small' | 'xsmall';
20
+
21
+ /**
22
+ * Цвет текста
23
+ */
24
+ color?: Color;
25
+
26
+ /**
27
+ * Толщина шрифта
28
+ */
29
+ weight?: 'regular' | 'medium' | 'bold';
30
+
31
+ /**
32
+ * Шрифт текста
33
+ */
34
+ font?: 'styrene' | 'system';
35
+
36
+ /**
37
+ * Добавляет отступы
38
+ */
39
+ defaultMargins?: boolean;
40
+
41
+ /**
42
+ * Css-класс для стилизации (native prop)
43
+ */
44
+ className?: string;
45
+
46
+ /**
47
+ * Id компонента для тестов
48
+ */
49
+ dataTestId?: string;
50
+
51
+ /**
52
+ * Контент (native prop)
53
+ */
54
+ children?: React.ReactNode;
55
+
56
+ /**
57
+ * Количество строк (не поддерживает IE)
58
+ */
59
+ rowLimit?: 1 | 2 | 3;
60
+ };
61
+
62
+ type Styles = {
63
+ styles: {
64
+ [key: string]: string;
65
+ };
66
+ };
67
+
68
+ type TitleElementType = HTMLHeadingElement | HTMLDivElement;
69
+
70
+ export const Title = forwardRef<TitleElementType, TitleProps & Styles>(
71
+ (
72
+ {
73
+ tag: Component = 'div',
74
+ view = 'medium',
75
+ font = 'styrene',
76
+ weight = font === 'styrene' ? 'medium' : 'bold',
77
+ defaultMargins = false,
78
+ color,
79
+ className,
80
+ dataTestId,
81
+ children,
82
+ rowLimit,
83
+ styles,
84
+ ...restProps
85
+ },
86
+ ref,
87
+ ) => (
88
+ <Component
89
+ className={cn(
90
+ styles.component,
91
+ className,
92
+ styles[`${font}-${view}`],
93
+ defaultMargins && styles[`margins-${view}`],
94
+ styles[weight],
95
+ color && colors[color],
96
+ { [styles[`rowLimit${rowLimit}`]]: rowLimit },
97
+ )}
98
+ data-test-id={dataTestId}
99
+ ref={ref}
100
+ {...restProps}
101
+ >
102
+ {children}
103
+ </Component>
104
+ ),
105
+ );
@@ -0,0 +1,75 @@
1
+ @import '@alfalab/core-components-themes/src/default.css';
2
+ @import '../margins.module.css';
3
+
4
+ .styrene-xlarge {
5
+ @mixin headline_xlarge;
6
+ }
7
+
8
+ .styrene-large {
9
+ @mixin headline_large;
10
+ }
11
+
12
+ .styrene-medium {
13
+ @mixin headline_medium;
14
+ }
15
+
16
+ .styrene-small {
17
+ @mixin headline_small;
18
+ }
19
+
20
+ .styrene-xsmall {
21
+ @mixin headline_xsmall;
22
+ }
23
+
24
+ .system-xlarge {
25
+ @mixin headline-system_xlarge;
26
+ }
27
+
28
+ .system-large {
29
+ @mixin headline-system_large;
30
+ }
31
+
32
+ .system-medium {
33
+ @mixin headline-system_medium;
34
+ }
35
+
36
+ .system-small {
37
+ @mixin headline-system_small;
38
+ }
39
+
40
+ .system-xsmall {
41
+ @mixin headline-system_xsmall;
42
+ }
43
+
44
+ .margins-xlarge {
45
+ @mixin margin-large;
46
+ }
47
+
48
+ .margins-large {
49
+ @mixin margin-medium;
50
+ }
51
+
52
+ .margins-medium {
53
+ @mixin margin-medium;
54
+ }
55
+
56
+ .margins-small {
57
+ @mixin margin-small;
58
+ }
59
+
60
+ .margins-xsmall {
61
+ @mixin margin-small;
62
+ }
63
+
64
+ .rowLimit1 {
65
+ @mixin row_limit 1;
66
+ word-break: break-all;
67
+ }
68
+
69
+ .rowLimit2 {
70
+ @mixin row_limit 2;
71
+ }
72
+
73
+ .rowLimit3 {
74
+ @mixin row_limit 3;
75
+ }
@@ -0,0 +1,17 @@
1
+ import React, { FC } from 'react';
2
+
3
+ import { Title as TitleBase, TitleProps } from './component';
4
+
5
+ import commonStyles from './common.module.css';
6
+ import styles from './index.module.css';
7
+
8
+ const Title: FC<TitleProps> = (props) => (
9
+ /**
10
+ * Если поменять Object.assign на деструктуризацию, то упадут тесты.
11
+ * Видимо, это особенность работы jest и css-modules.
12
+ */
13
+ <TitleBase {...props} styles={Object.assign(commonStyles, styles)} />
14
+ );
15
+
16
+ export { Title };
17
+ export type { TitleProps };
@@ -0,0 +1,16 @@
1
+ import React, { FC } from 'react';
2
+
3
+ import { Title, TitleProps } from '../title/component';
4
+
5
+ import commonStyles from '../title/common.module.css';
6
+ import styles from './index.module.css';
7
+
8
+ export type TitleMobileProps = Omit<TitleProps, 'defaultMargins'>;
9
+
10
+ export const TitleMobile: FC<TitleMobileProps> = (props) => (
11
+ /**
12
+ * Если поменять Object.assign на деструктуризацию, то упадут тесты.
13
+ * Видимо, это особенность работы jest и css-modules.
14
+ */
15
+ <Title {...props} styles={Object.assign(commonStyles, styles)} />
16
+ );
@@ -0,0 +1,42 @@
1
+ @import '@alfalab/core-components-themes/src/default.css';
2
+ @import '../margins.module.css';
3
+
4
+ .styrene-xlarge {
5
+ @mixin headline-mobile_xlarge;
6
+ }
7
+
8
+ .styrene-large {
9
+ @mixin headline-mobile_large;
10
+ }
11
+
12
+ .styrene-medium {
13
+ @mixin headline-mobile_medium;
14
+ }
15
+
16
+ .styrene-small {
17
+ @mixin headline-mobile_small;
18
+ }
19
+
20
+ .styrene-xsmall {
21
+ @mixin headline-mobile_xsmall;
22
+ }
23
+
24
+ .system-xlarge {
25
+ @mixin headline-system-mobile_xlarge;
26
+ }
27
+
28
+ .system-large {
29
+ @mixin headline-system-mobile_large;
30
+ }
31
+
32
+ .system-medium {
33
+ @mixin headline-system-mobile_medium;
34
+ }
35
+
36
+ .system-small {
37
+ @mixin headline-system-mobile_small;
38
+ }
39
+
40
+ .system-xsmall {
41
+ @mixin headline-system-mobile_xsmall;
42
+ }
@@ -0,0 +1 @@
1
+ export * from './component';
@@ -0,0 +1,14 @@
1
+ import React, { FC } from 'react';
2
+
3
+ import { Title, TitleProps } from '../title/component';
4
+
5
+ import commonStyles from '../title/common.module.css';
6
+ import styles from './index.module.css';
7
+
8
+ export const TitleResponsive: FC<TitleProps> = (props) => (
9
+ /**
10
+ * Если поменять Object.assign на деструктуризацию, то упадут тесты.
11
+ * Видимо, это особенность работы jest и css-modules.
12
+ */
13
+ <Title {...props} styles={Object.assign(commonStyles, styles)} />
14
+ );
@@ -0,0 +1,126 @@
1
+ @import '@alfalab/core-components-themes/src/default.css';
2
+ @import '../margins.module.css';
3
+
4
+ /* TODO: поменять медиа-запросы на миксины */
5
+
6
+ .styrene-xlarge {
7
+ @mixin headline-mobile_xlarge;
8
+ }
9
+
10
+ .styrene-large {
11
+ @mixin headline-mobile_large;
12
+ }
13
+
14
+ .styrene-medium {
15
+ @mixin headline-mobile_medium;
16
+ }
17
+
18
+ .styrene-small {
19
+ @mixin headline-mobile_small;
20
+ }
21
+
22
+ .styrene-xsmall {
23
+ @mixin headline-mobile_xsmall;
24
+ }
25
+
26
+ .system-xlarge {
27
+ @mixin headline-system-mobile_xlarge;
28
+ }
29
+
30
+ .system-large {
31
+ @mixin headline-system-mobile_large;
32
+ }
33
+
34
+ .system-medium {
35
+ @mixin headline-system-mobile_medium;
36
+ }
37
+
38
+ .system-small {
39
+ @mixin headline-system-mobile_small;
40
+ }
41
+
42
+ .system-xsmall {
43
+ @mixin headline-system-mobile_xsmall;
44
+ }
45
+
46
+ .margins-xlarge {
47
+ @mixin margin-large;
48
+ }
49
+
50
+ .margins-large {
51
+ @mixin margin-small;
52
+ }
53
+
54
+ .margins-medium {
55
+ @mixin margin-small;
56
+ }
57
+
58
+ .margins-small {
59
+ @mixin margin-small;
60
+ }
61
+
62
+ .margins-xsmall {
63
+ @mixin margin-small;
64
+ }
65
+
66
+ @media screen and (min-width: 1024px) {
67
+ .styrene-xlarge {
68
+ @mixin headline_xlarge;
69
+ }
70
+
71
+ .styrene-large {
72
+ @mixin headline_large;
73
+ }
74
+
75
+ .styrene-medium {
76
+ @mixin headline_medium;
77
+ }
78
+
79
+ .styrene-small {
80
+ @mixin headline_small;
81
+ }
82
+
83
+ .styrene-xsmall {
84
+ @mixin headline_xsmall;
85
+ }
86
+
87
+ .system-xlarge {
88
+ @mixin headline-system_xlarge;
89
+ }
90
+
91
+ .system-large {
92
+ @mixin headline-system_large;
93
+ }
94
+
95
+ .system-medium {
96
+ @mixin headline-system_medium;
97
+ }
98
+
99
+ .system-small {
100
+ @mixin headline-system_small;
101
+ }
102
+
103
+ .system-xsmall {
104
+ @mixin headline-system_xsmall;
105
+ }
106
+
107
+ .margins-xlarge {
108
+ @mixin margin-large;
109
+ }
110
+
111
+ .margins-large {
112
+ @mixin margin-medium;
113
+ }
114
+
115
+ .margins-medium {
116
+ @mixin margin-medium;
117
+ }
118
+
119
+ .margins-small {
120
+ @mixin margin-small;
121
+ }
122
+
123
+ .margins-xsmall {
124
+ @mixin margin-small;
125
+ }
126
+ }
@@ -0,0 +1 @@
1
+ export * from './component';
package/src/types.ts ADDED
@@ -0,0 +1 @@
1
+ export type TextElementType = HTMLParagraphElement | HTMLSpanElement | HTMLDivElement;
package/text/component.js CHANGED
@@ -5,14 +5,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var tslib = require('tslib');
6
6
  var React = require('react');
7
7
  var cn = require('classnames');
8
- var colors_module = require('../colors.module-a848b027.js');
8
+ var colors_module = require('../colors.module-1c06b16d.js');
9
9
 
10
10
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
11
11
 
12
12
  var React__default = /*#__PURE__*/_interopDefaultCompat(React);
13
13
  var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
14
14
 
15
- var styles = {"paragraph":"typography__paragraph_1w6ie","paragraphWithMargins":"typography__paragraphWithMargins_1w6ie","primary-large":"typography__primary-large_1w6ie","primary-medium":"typography__primary-medium_1w6ie","primary-small":"typography__primary-small_1w6ie","secondary-large":"typography__secondary-large_1w6ie","secondary-medium":"typography__secondary-medium_1w6ie","secondary-small":"typography__secondary-small_1w6ie","component":"typography__component_1w6ie","caps":"typography__caps_1w6ie","bold":"typography__bold_1w6ie","medium":"typography__medium_1w6ie","regular":"typography__regular_1w6ie","monospace":"typography__monospace_1w6ie","rowLimit1":"typography__rowLimit1_1w6ie","rowLimit2":"typography__rowLimit2_1w6ie","rowLimit3":"typography__rowLimit3_1w6ie"};
15
+ var styles = {"paragraph":"typography__paragraph_pm003","paragraphWithMargins":"typography__paragraphWithMargins_pm003","primary-large":"typography__primary-large_pm003","primary-medium":"typography__primary-medium_pm003","primary-small":"typography__primary-small_pm003","secondary-large":"typography__secondary-large_pm003","secondary-medium":"typography__secondary-medium_pm003","secondary-small":"typography__secondary-small_pm003","component":"typography__component_pm003","caps":"typography__caps_pm003","bold":"typography__bold_pm003","medium":"typography__medium_pm003","regular":"typography__regular_pm003","monospace":"typography__monospace_pm003","rowLimit1":"typography__rowLimit1_pm003","rowLimit2":"typography__rowLimit2_pm003","rowLimit3":"typography__rowLimit3_pm003"};
16
16
  require('./index.css')
17
17
 
18
18
  var Text = React.forwardRef(function (_a, ref) {