ff-ds-ui 0.0.1 → 0.0.3

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 (105) hide show
  1. package/.husky/pre-commit +2 -0
  2. package/.prettierrc +7 -0
  3. package/.storybook/main.ts +14 -0
  4. package/.storybook/preview.ts +21 -0
  5. package/.storybook/vitest.setup.ts +7 -0
  6. package/README.md +1 -73
  7. package/eslint.config.js +19 -13
  8. package/package.json +55 -34
  9. package/src/components/Avatar/Avatar.scss +90 -0
  10. package/src/components/Avatar/Avatar.tsx +40 -0
  11. package/src/components/Avatar/__stories__/Avatar.stories.tsx +21 -0
  12. package/src/components/Avatar/__test__/utils.test.ts +76 -0
  13. package/src/components/Avatar/index.ts +1 -0
  14. package/src/components/Avatar/utils.tsx +26 -0
  15. package/src/components/Breadcrumbs/Breadcrumbs.tsx +40 -0
  16. package/src/components/Breadcrumbs/__stories__/Breadcrumbs.stories.tsx +20 -0
  17. package/src/components/Breadcrumbs/index.ts +1 -0
  18. package/src/components/Button/Button.scss +245 -0
  19. package/src/components/Button/Button.tsx +34 -0
  20. package/src/components/Button/__stories__/Button.stories.tsx +168 -0
  21. package/src/components/Button/const.ts +26 -0
  22. package/src/components/Button/index.ts +1 -0
  23. package/src/components/Card/Card.scss +13 -0
  24. package/src/components/Card/Card.tsx +12 -0
  25. package/src/components/Card/__stories__/Card.stories.tsx +18 -0
  26. package/src/components/Card/index.ts +1 -0
  27. package/src/components/Checkbox/Checkbox.scss +28 -0
  28. package/src/components/Checkbox/Checkbox.tsx +23 -0
  29. package/src/components/Checkbox/__stories__/Checkbox.stories.tsx +21 -0
  30. package/src/components/Checkbox/index.ts +1 -0
  31. package/src/components/Divider/Divider.scss +62 -0
  32. package/src/components/Divider/Divider.tsx +21 -0
  33. package/src/components/Divider/__stories__/Divider.stories.tsx +68 -0
  34. package/src/components/Divider/index.ts +1 -0
  35. package/src/components/Flex/Flex.scss +94 -0
  36. package/src/components/Flex/Flex.tsx +41 -0
  37. package/src/components/Flex/__stories__/Flex.stories.tsx +27 -0
  38. package/src/components/Flex/index.ts +1 -0
  39. package/src/components/Label/Label.scss +53 -0
  40. package/src/components/Label/Label.tsx +27 -0
  41. package/src/components/Label/__stories__/Label.stories.tsx +26 -0
  42. package/src/components/Label/index.ts +1 -0
  43. package/src/components/Link/Link.scss +13 -0
  44. package/src/components/Link/Link.tsx +18 -0
  45. package/src/components/Link/__stories__/Link.stories.tsx +20 -0
  46. package/src/components/Link/index.ts +1 -0
  47. package/src/components/Loader/Loader.scss +56 -0
  48. package/src/components/Loader/Loader.tsx +33 -0
  49. package/src/components/Loader/__stories__/Loader.stories.tsx +18 -0
  50. package/src/components/Loader/const.ts +7 -0
  51. package/src/components/Loader/index.ts +1 -0
  52. package/src/components/Radio/Radio.scss +28 -0
  53. package/src/components/Radio/Radio.tsx +24 -0
  54. package/src/components/Radio/__stories__/Radio.stories.tsx +21 -0
  55. package/src/components/Radio/index.ts +1 -0
  56. package/src/components/Skeleton/Skeleton.scss +73 -0
  57. package/src/components/Skeleton/Skeleton.tsx +16 -0
  58. package/src/components/Skeleton/__stories__/Skeleton.stories.tsx +16 -0
  59. package/src/components/Skeleton/index.ts +1 -0
  60. package/src/components/Tabs/Tabs.scss +25 -0
  61. package/src/components/Tabs/Tabs.tsx +39 -0
  62. package/src/components/Tabs/__stories__/Tabs.stories.tsx +19 -0
  63. package/src/components/Tabs/index.ts +1 -0
  64. package/src/components/Text/Text.scss +30 -0
  65. package/src/components/Text/Text.tsx +68 -0
  66. package/src/components/Text/_stories_/Text.stories.tsx +95 -0
  67. package/src/components/Text/index.ts +1 -0
  68. package/src/components/TextArea/TextArea.scss +45 -0
  69. package/src/components/TextArea/TextArea.tsx +39 -0
  70. package/src/components/TextArea/__stories__/TextArea.stories.tsx +20 -0
  71. package/src/components/TextArea/index.ts +1 -0
  72. package/src/components/TextInput/TextInput.scss +92 -0
  73. package/src/components/TextInput/TextInput.tsx +43 -0
  74. package/src/components/TextInput/__stories__/TextInput.stories.tsx +40 -0
  75. package/src/components/TextInput/index.ts +1 -0
  76. package/src/components/User/User.scss +7 -0
  77. package/src/components/User/User.tsx +23 -0
  78. package/src/components/User/__stories__/User.stories.tsx +23 -0
  79. package/src/components/User/index.ts +1 -0
  80. package/src/components/index.ts +17 -1
  81. package/src/index.ts +1 -1
  82. package/src/stories/modules.mdx +14 -0
  83. package/src/styles/fonts.scss +1 -0
  84. package/src/styles/mixins/_index.scss +18 -0
  85. package/src/styles/mixins/button.scss +29 -0
  86. package/src/styles/mixins/typography.scss +107 -0
  87. package/src/styles/styles.scss +3 -0
  88. package/src/styles/variables/_index.scss +25 -0
  89. package/src/styles/variables/colors.scss +45 -0
  90. package/src/styles/variables/padding.scss +7 -0
  91. package/src/styles/variables/radius.scss +8 -0
  92. package/src/styles/variables/spacing.scss +15 -0
  93. package/src/styles/variables/typography.scss +66 -0
  94. package/src/utils/bem/__tests__/bem.test.ts +25 -0
  95. package/src/utils/bem/bem.ts +24 -0
  96. package/src/utils/index.ts +1 -0
  97. package/tsconfig.app.json +28 -25
  98. package/tsconfig.build.json +20 -0
  99. package/tsconfig.json +2 -5
  100. package/tsconfig.node.json +22 -22
  101. package/vite.config.ts +78 -23
  102. package/vitest.shims.d.ts +1 -0
  103. package/index.html +0 -13
  104. package/public/vite.svg +0 -1
  105. package/src/components/Button/index.tsx +0 -21
@@ -1 +1,17 @@
1
- export * from './Button'
1
+ export * from './Button'
2
+ export * from './Text'
3
+ export * from './Flex'
4
+ export * from './TextInput'
5
+ export * from './Avatar'
6
+ export * from './User'
7
+ export * from './Divider'
8
+ export * from './Skeleton'
9
+ export * from './Loader'
10
+ export * from './Card'
11
+ export * from './Label'
12
+ export * from './Radio'
13
+ export * from './Checkbox'
14
+ export * from './Link'
15
+ export * from './Breadcrumbs'
16
+ export * from './TextArea'
17
+ export * from './Tabs'
package/src/index.ts CHANGED
@@ -1 +1 @@
1
- export * from "./components";
1
+ export * from './components'
@@ -0,0 +1,14 @@
1
+ import { Meta } from '@storybook/addon-docs/blocks'
2
+ import { TextInput, Text, Button, Flex } from '../components'
3
+
4
+ <Meta title="Modules DS" />
5
+
6
+ <Flex direction="col">
7
+ <Text>Module text input + button</Text>
8
+ <Flex direction="row" gap="xs">
9
+ <TextInput size="l"></TextInput>
10
+ <Button variant="primary" size="l">
11
+ Click me
12
+ </Button>
13
+ </Flex>
14
+ </Flex>
@@ -0,0 +1 @@
1
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap');
@@ -0,0 +1,18 @@
1
+ @use './typography.scss';
2
+ @use './button.scss';
3
+
4
+ @mixin mixins-typography-variants {
5
+ @include typography.getTypographyVariants;
6
+ }
7
+
8
+ @mixin mixins-typography-colors {
9
+ @include typography.getTypographyColors;
10
+ }
11
+
12
+ @mixin button-reset-styles {
13
+ @include button.reset-button-styles;
14
+ }
15
+
16
+ @mixin outlined-hover($rgb, $hoverA, $activeA) {
17
+ @include button.outlined-hover($rgb, $hoverA, $activeA);
18
+ }
@@ -0,0 +1,29 @@
1
+ @use '../variables' as Variables;
2
+
3
+ @mixin reset-button-styles {
4
+ @include Variables.variables-typography;
5
+
6
+ outline: none;
7
+ border: none;
8
+ padding: 0;
9
+
10
+ font-family: var(--FF-DS-font-family-sans);
11
+ font-size: 12px;
12
+ font-weight: var(--FF-DS-text-body-font-weigh);
13
+
14
+ color: inherit;
15
+ background: none;
16
+ border: none;
17
+ outline: none;
18
+ cursor: pointer;
19
+ }
20
+
21
+ @mixin outlined-hover($rgb, $hoverA: 0.2, $actriveA: 0.25) {
22
+ &:hover {
23
+ background-color: rgba(var(#{$rgb}), $hoverA);
24
+ }
25
+
26
+ &:active {
27
+ background-color: rgba(var(#{$rgb}), $actriveA);
28
+ }
29
+ }
@@ -0,0 +1,107 @@
1
+ @mixin getTypographyVariants {
2
+ &_variant_body1 {
3
+ font-family: var(----FF-DS-text-body-font-family);
4
+ font-weight: var(--FF-DS-text-body-font-weight);
5
+ font-size: var(--FF-DS-text-body-1-font-size);
6
+ line-height: var(--FF-DS-text-body-1-line-height);
7
+ }
8
+ &_variant_body2 {
9
+ font-family: var(----FF-DS-text-body-font-family);
10
+ font-weight: var(--FF-DS-text-body-font-weight);
11
+ font-size: var(--FF-DS-text-body-2-font-size);
12
+ line-height: var(--FF-DS-text-body-2-line-height);
13
+ }
14
+ &_variant_body3 {
15
+ font-family: var(----FF-DS-text-body-font-family);
16
+ font-weight: var(--FF-DS-text-body-font-weight);
17
+ font-size: var(--FF-DS-text-body-3-font-size);
18
+ line-height: var(--FF-DS-text-body-3-line-height);
19
+ }
20
+ &_variant_caption1 {
21
+ font-family: var(--FF-DS-text-caption-font-family);
22
+ font-weight: var(--FF-DS-text-caption-font-weight);
23
+ font-size: var(--FF-DS-text-caption-1-font-size);
24
+ line-height: var(--FF-DS-text-caption-1-line-height);
25
+ }
26
+ &_variant_caption2 {
27
+ font-family: var(--FF-DS-text-caption-font-family);
28
+ font-weight: var(--FF-DS-text-caption-font-weight);
29
+ font-size: var(--FF-DS-text-caption-2-font-size);
30
+ line-height: var(--FF-DS-text-caption-2-line-height);
31
+ }
32
+ &_variant_header1 {
33
+ font-family: var(--FF-DS-text-header-font-family);
34
+ font-weight: var(--FF-DS-text-header-font-weight);
35
+ font-size: var(--FF-DS-text-header-1-font-size);
36
+ line-height: var(--FF-DS-text-header-1-line-height);
37
+ }
38
+ &_variant_header2 {
39
+ font-family: var(--FF-DS-text-header-font-family);
40
+ font-weight: var(--FF-DS-text-header-font-weight);
41
+ font-size: var(--FF-DS-text-header-2-font-size);
42
+ line-height: var(--FF-DS-text-header-2-line-height);
43
+ }
44
+ &_variant_subheader1 {
45
+ font-family: var(--FF-DS-text-subheader-font-family);
46
+ font-weight: var(--FF-DS-text-subheader-font-weight);
47
+ font-size: var(--FF-DS-text-subheader-1-font-size);
48
+ line-height: var(--FF-DS-text-subheader-1-line-height);
49
+ }
50
+ &_variant_subheader2 {
51
+ font-family: var(--FF-DS-text-subheader-font-family);
52
+ font-weight: var(--FF-DS-text-subheader-font-weight);
53
+ font-size: var(--FF-DS-text-subheader-2-font-size);
54
+ line-height: var(--FF-DS-text-subheader-2-line-height);
55
+ }
56
+ &_variant_subheader3 {
57
+ font-family: var(--FF-DS-text-subheader-font-family);
58
+ font-weight: var(--FF-DS-text-subheader-font-weight);
59
+ font-size: var(--FF-DS-text-subheader-3-font-size);
60
+ line-height: var(--FF-DS-text-subheader-3-line-height);
61
+ }
62
+ &_variant_display1 {
63
+ font-family: var(--FF-DS-text-display-font-family);
64
+ font-weight: var(--FF-DS-text-display-font-weight);
65
+ font-size: var(--FF-DS-text-display-1-font-size);
66
+ line-height: var(--FF-DS-text-display-1-line-height);
67
+ }
68
+ &_variant_display2 {
69
+ font-family: var(--FF-DS-text-display-font-family);
70
+ font-weight: var(--FF-DS-text-display-font-weight);
71
+ font-size: var(--FF-DS-text-display-2-font-size);
72
+ line-height: var(--FF-DS-text-display-2-line-height);
73
+ }
74
+ &_variant_display3 {
75
+ font-family: var(--FF-DS-text-display-font-family);
76
+ font-weight: var(--FF-DS-text-display-font-weight);
77
+ font-size: var(--FF-DS-text-display-3-font-size);
78
+ line-height: var(--FF-DS-text-display-3-line-height);
79
+ }
80
+ &_variant_display4 {
81
+ font-family: var(--FF-DS-text-display-font-family);
82
+ font-weight: var(--FF-DS-text-display-font-weight);
83
+ font-size: var(--FF-DS-text-display-4-font-size);
84
+ line-height: var(--FF-DS-text-display-4-line-height);
85
+ }
86
+ }
87
+
88
+ @mixin getTypographyColors {
89
+ &_color_primary {
90
+ color: rgb(8, 87, 206);
91
+ }
92
+ &_color_warning {
93
+ color: rgb(148, 158, 5);
94
+ }
95
+ &_color_secondary {
96
+ color: rgb(94, 94, 94);
97
+ }
98
+ &_color_danger {
99
+ color: rgb(102, 16, 16);
100
+ }
101
+ &_color_default {
102
+ color: rgb(0, 0, 0);
103
+ }
104
+ &_color_success {
105
+ color: rgb(37, 141, 37);
106
+ }
107
+ }
@@ -0,0 +1,3 @@
1
+ @use './variables';
2
+
3
+ $ns: 'FF-DS-';
@@ -0,0 +1,25 @@
1
+ @use './typography';
2
+ @use './spacing.scss';
3
+ @use './radius.scss';
4
+ @use './padding.scss';
5
+ @use './colors.scss';
6
+
7
+ @mixin variables-colors {
8
+ @include colors.variables;
9
+ }
10
+
11
+ @mixin variables-padding {
12
+ @include padding.variables;
13
+ }
14
+
15
+ @mixin variables-radius {
16
+ @include radius.variables;
17
+ }
18
+
19
+ @mixin variables-spacing {
20
+ @include spacing.variables;
21
+ }
22
+
23
+ @mixin variables-typography {
24
+ @include typography.variables;
25
+ }
@@ -0,0 +1,45 @@
1
+ // Colors = 'brand' | 'primary' | 'success' | 'warning' | 'secondary' | 'error'
2
+
3
+ @mixin variables {
4
+ // Brand
5
+ --FF-DS-color-brand-base: rgb(124, 58, 237);
6
+ --FF-DS-color-brand-base-rgb: 124, 58, 237;
7
+ --FF-DS-color-brand-hover: rgb(109, 40, 217);
8
+ --FF-DS-color-brand-border: rgb(124, 58, 237);
9
+ --FF-DS-color-brand-text: rgb(255, 255, 255);
10
+
11
+ // Primary
12
+ --FF-DS-color-primary-base: rgb(59, 130, 246);
13
+ --FF-DS-color-primary-base-rgb: 59, 130, 246;
14
+ --FF-DS-color-primary-hover: rgb(37, 99, 235);
15
+ --FF-DS-color-primary-border: rgb(59, 130, 246);
16
+ --FF-DS-color-primary-text: rgb(255, 255, 255);
17
+
18
+ // Success
19
+ --FF-DS-color-success-base: rgb(34, 197, 94);
20
+ --FF-DS-color-success-base-rgb: 34, 197, 94;
21
+ --FF-DS-color-success-hover: rgb(22, 163, 74);
22
+ --FF-DS-color-success-border: rgb(34, 197, 94);
23
+ --FF-DS-color-success-text: rgb(255, 255, 255);
24
+
25
+ // Warning
26
+ --FF-DS-color-warning-base: rgb(234, 179, 8);
27
+ --FF-DS-color-warning-base-rgb: 234, 179, 8;
28
+ --FF-DS-color-warning-hover: rgb(202, 138, 4);
29
+ --FF-DS-color-warning-border: rgb(234, 179, 8);
30
+ --FF-DS-color-warning-text: rgb(0, 0, 0);
31
+
32
+ // Secondary
33
+ --FF-DS-color-secondary-base: rgb(229, 231, 235);
34
+ --FF-DS-color-secondary-base-rgb: 229, 231, 235;
35
+ --FF-DS-color-secondary-hover: rgb(209, 213, 219);
36
+ --FF-DS-color-secondary-border: rgb(197, 197, 197);
37
+ --FF-DS-color-secondary-text: rgb(17, 24, 39);
38
+
39
+ // Error
40
+ --FF-DS-color-error-base: rgb(239, 68, 68);
41
+ --FF-DS-color-error-base-rgb: 239, 68, 68;
42
+ --FF-DS-color-error-hover: rgb(220, 38, 38);
43
+ --FF-DS-color-error-border: rgb(239, 68, 68);
44
+ --FF-DS-color-error-text: rgb(255, 255, 255);
45
+ }
@@ -0,0 +1,7 @@
1
+ @mixin variables {
2
+ --FF-DS-padding-xs: 6px;
3
+ --FF-DS-padding-s: 8px;
4
+ --FF-DS-padding-m: 12px;
5
+ --FF-DS-padding-l: 16px;
6
+ --FF-DS-padding-xl: 20px;
7
+ }
@@ -0,0 +1,8 @@
1
+ @mixin variables {
2
+ --FF-DS-border-radius-xs: 3px;
3
+ --FF-DS-border-radius-s: 5px;
4
+ --FF-DS-border-radius-m: 6px;
5
+ --FF-DS-border-radius-l: 8px;
6
+ --FF-DS-border-radius-xl: 10px;
7
+ --FF-DS-border-radius-2xl: 16px;
8
+ }
@@ -0,0 +1,15 @@
1
+ @mixin variables {
2
+ --FF-DS-spacing-base: 4px;
3
+
4
+ --FF-DS-spacing-xs: calc(var(--FF-DS-spacing-base) * 0.5);
5
+ --FF-DS-spacing-xm: var(--FF-DS-spacing-base);
6
+ --FF-DS-spacing-s: calc(var(--FF-DS-spacing-base) * 2);
7
+ --FF-DS-spacing-m: calc(var(--FF-DS-spacing-base) * 3);
8
+ --FF-DS-spacing-l: calc(var(--FF-DS-spacing-base) * 4);
9
+ --FF-DS-spacing-xl: calc(var(--FF-DS-spacing-base) * 5);
10
+ --FF-DS-spacing-2xl: calc(var(--FF-DS-spacing-base) * 6);
11
+ --FF-DS-spacing-3xl: calc(var(--FF-DS-spacing-base) * 7);
12
+ --FF-DS-spacing-4xl: calc(var(--FF-DS-spacing-base) * 8);
13
+ --FF-DS-spacing-5xl: calc(var(--FF-DS-spacing-base) * 9);
14
+ --FF-DS-spacing-6xl: calc(var(--FF-DS-spacing-base) * 10);
15
+ }
@@ -0,0 +1,66 @@
1
+ @mixin variables {
2
+ // BASE FONT FAMILY
3
+ --FF-DS-font-family-sans: 'Inter', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
4
+
5
+ // TYPOGRAPHY FONT FAMILY
6
+ --FF-DS-text-body-font-family: var(--FF-DS-font-family-sans);
7
+ --FF-DS-text-caption-font-family: var(--FF-DS-font-family-sans);
8
+ --FF-DS-text-header-font-family: var(--FF-DS-font-family-sans);
9
+ --FF-DS-text-subheader-font-family: var(--FF-DS-font-family-sans);
10
+ --FF-DS-text-display-font-family: var(--FF-DS-font-family-sans);
11
+
12
+ // TYPOGRAPHY WEIGHT
13
+ --FF-DS-text-body-font-weight: 400;
14
+ --FF-DS-text-caption-font-weight: 400;
15
+ --FF-DS-text-header-font-weight: 600;
16
+ --FF-DS-text-subheader-font-weight: 600;
17
+ --FF-DS-text-display-font-weight: 600;
18
+ --FF-DS-text-accent-font-weight: 600;
19
+
20
+ // BODY FONT SIZE/LINE_HEIGHT
21
+ --FF-DS-text-body-1-font-size: 13px;
22
+ --FF-DS-text-body-1-line-height: 18px;
23
+
24
+ --FF-DS-text-body-2-font-size: 15px;
25
+ --FF-DS-text-body-2-line-height: 20px;
26
+
27
+ --FF-DS-text-body-3-font-size: 17px;
28
+ --FF-DS-text-body-3-line-height: 24px;
29
+
30
+ // CAPTION FONT SIZE/LINE_HEIGHT
31
+ --FF-DS-text-caption-1-font-size: 9px;
32
+ --FF-DS-text-caption-1-line-height: 12px;
33
+
34
+ --FF-DS-text-caption-2-font-size: 11px;
35
+ --FF-DS-text-caption-2-line-height: 16px;
36
+
37
+ // HEADER FONT SIZE/LINE_HEIGHT
38
+ --FF-DS-text-header-1-font-size: 20px;
39
+ --FF-DS-text-header-1-line-height: 24px;
40
+
41
+ --FF-DS-text-header-2-font-size: 24px;
42
+ --FF-DS-text-header-2-line-height: 28px;
43
+
44
+ // SUBHEADER FONT SIZE/LINE_HEIGHT
45
+ --FF-DS-text-subheader-1-font-size: 13px;
46
+ --FF-DS-text-subheader-1-line-height: 18px;
47
+
48
+ --FF-DS-text-subheader-2-font-size: 15px;
49
+ --FF-DS-text-subheader-2-line-height: 20px;
50
+
51
+ --FF-DS-text-subheader-3-font-size: 17px;
52
+ --FF-DS-text-subheader-3-line-height: 24px;
53
+
54
+ // DISPLAY FONT SIZE/LINE_HEIGHT
55
+ --FF-DS-text-display-1-font-size: 28px;
56
+ --FF-DS-text-display-1-line-height: 36px;
57
+
58
+ --FF-DS-text-display-2-font-size: 32px;
59
+ --FF-DS-text-display-2-line-height: 40px;
60
+
61
+ --FF-DS-text-display-3-font-size: 40px;
62
+ --FF-DS-text-display-3-line-height: 48px;
63
+
64
+ --FF-DS-text-display-4-font-size: 48px;
65
+ --FF-DS-text-display-4-line-height: 52px;
66
+ }
@@ -0,0 +1,25 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { bemBlock } from '../bem'
3
+
4
+ describe('src => comp => utils => bem.ts', () => {
5
+ it('bem block function test - button', () => {
6
+ const block = bemBlock('button')
7
+ const buttonClassName = block({ view: 'primary', disabled: true }, 'extraClass')
8
+ expect(buttonClassName).toBe(
9
+ 'FF-DS-button FF-DS-button_view_primary FF-DS-button_disabled extraClass'
10
+ )
11
+ })
12
+
13
+ it('bem block function test - text', () => {
14
+ const block = bemBlock('text')
15
+ const textClassName = block({ size: '2xl', variant: 'caption' }, 'extraClass')
16
+ expect(textClassName).toBe(
17
+ 'FF-DS-text FF-DS-text_size_2xl FF-DS-text_variant_caption extraClass'
18
+ )
19
+ })
20
+
21
+ it('bem block function test - empty block name', () => {
22
+ expect(() => bemBlock('')).toThrow('Empty block name')
23
+ expect(() => bemBlock('')({ as: '' })).toThrow('Empty block name')
24
+ })
25
+ })
@@ -0,0 +1,24 @@
1
+ import classNames from 'classnames'
2
+
3
+ type Mods = Record<string, string | boolean | undefined | null | number>
4
+
5
+ const NS = 'FF-DS-'
6
+
7
+ export const bemBlock = (bemBlockName: string) => {
8
+ if (!bemBlockName) throw new Error('Empty block name')
9
+
10
+ return (mods?: Mods, extra?: string | string[]) => {
11
+ const classNameMods = mods
12
+ ? Object.entries(mods)
13
+ // Cортируем пустые значения
14
+ .filter(([_, value]) => value !== false && value !== undefined && value !== null)
15
+ // Убираем значения true - btn_disabled_true => btn_disabled
16
+ .map(([bemModifier, bemModifierValue]) => {
17
+ return bemModifierValue === true
18
+ ? `${NS}${bemBlockName}_${bemModifier}`
19
+ : `${NS}${bemBlockName}_${bemModifier}_${bemModifierValue}`
20
+ })
21
+ : []
22
+ return classNames(`${NS}${bemBlockName}`, classNameMods, extra)
23
+ }
24
+ }
@@ -0,0 +1 @@
1
+ export * from './bem/bem'
package/tsconfig.app.json CHANGED
@@ -1,28 +1,31 @@
1
1
  {
2
- "compilerOptions": {
3
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4
- "target": "ES2022",
5
- "useDefineForClassFields": true,
6
- "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
- "module": "ESNext",
8
- "types": ["vite/client"],
9
- "skipLibCheck": true,
2
+ "compilerOptions": {
3
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4
+ "target": "ES2022",
5
+ "useDefineForClassFields": true,
6
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
+ "module": "ESNext",
8
+ "types": ["vite/client"],
9
+ "skipLibCheck": true,
10
+ "baseUrl": ".",
11
+ "paths": {
12
+ "@/*": ["src/*"]
13
+ },
14
+ /* Bundler mode */
15
+ "moduleResolution": "bundler",
16
+ "allowImportingTsExtensions": true,
17
+ "verbatimModuleSyntax": true,
18
+ "moduleDetection": "force",
19
+ "noEmit": true,
20
+ "jsx": "react-jsx",
10
21
 
11
- /* Bundler mode */
12
- "moduleResolution": "bundler",
13
- "allowImportingTsExtensions": true,
14
- "verbatimModuleSyntax": true,
15
- "moduleDetection": "force",
16
- "noEmit": true,
17
- "jsx": "react-jsx",
18
-
19
- /* Linting */
20
- "strict": true,
21
- "noUnusedLocals": true,
22
- "noUnusedParameters": true,
23
- "erasableSyntaxOnly": true,
24
- "noFallthroughCasesInSwitch": true,
25
- "noUncheckedSideEffectImports": true
26
- },
27
- "include": ["src"]
22
+ /* Linting */
23
+ "strict": true,
24
+ "noUnusedLocals": true,
25
+ "noUnusedParameters": true,
26
+ "erasableSyntaxOnly": true,
27
+ "noFallthroughCasesInSwitch": true,
28
+ "noUncheckedSideEffectImports": true
29
+ },
30
+ "include": ["src"]
28
31
  }
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "jsx": "react-jsx",
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "emitDeclarationOnly": true,
9
+ "outDir": "dist",
10
+ "strict": true,
11
+ "moduleResolution": "Node",
12
+ "skipLibCheck": true,
13
+ "esModuleInterop": true,
14
+ "baseUrl": ".",
15
+ "paths": {
16
+ "@/*": ["src/*"]
17
+ }
18
+ },
19
+ "include": ["src"]
20
+ }
package/tsconfig.json CHANGED
@@ -1,7 +1,4 @@
1
1
  {
2
- "files": [],
3
- "references": [
4
- { "path": "./tsconfig.app.json" },
5
- { "path": "./tsconfig.node.json" }
6
- ]
2
+ "files": [],
3
+ "references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" }]
7
4
  }
@@ -1,26 +1,26 @@
1
1
  {
2
- "compilerOptions": {
3
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
4
- "target": "ES2023",
5
- "lib": ["ES2023"],
6
- "module": "ESNext",
7
- "types": ["node"],
8
- "skipLibCheck": true,
2
+ "compilerOptions": {
3
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
4
+ "target": "ES2023",
5
+ "lib": ["ES2023"],
6
+ "module": "ESNext",
7
+ "types": ["node"],
8
+ "skipLibCheck": true,
9
9
 
10
- /* Bundler mode */
11
- "moduleResolution": "bundler",
12
- "allowImportingTsExtensions": true,
13
- "verbatimModuleSyntax": true,
14
- "moduleDetection": "force",
15
- "noEmit": true,
10
+ /* Bundler mode */
11
+ "moduleResolution": "bundler",
12
+ "allowImportingTsExtensions": true,
13
+ "verbatimModuleSyntax": true,
14
+ "moduleDetection": "force",
15
+ "noEmit": true,
16
16
 
17
- /* Linting */
18
- "strict": true,
19
- "noUnusedLocals": true,
20
- "noUnusedParameters": true,
21
- "erasableSyntaxOnly": true,
22
- "noFallthroughCasesInSwitch": true,
23
- "noUncheckedSideEffectImports": true
24
- },
25
- "include": ["vite.config.ts"]
17
+ /* Linting */
18
+ "strict": true,
19
+ "noUnusedLocals": true,
20
+ "noUnusedParameters": true,
21
+ "erasableSyntaxOnly": true,
22
+ "noFallthroughCasesInSwitch": true,
23
+ "noUncheckedSideEffectImports": true
24
+ },
25
+ "include": ["vite.config.ts"]
26
26
  }