ff-ds-ui 0.0.2 → 0.0.4

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 (106) 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/LICENSE +21 -21
  7. package/README.md +13 -73
  8. package/eslint.config.js +29 -23
  9. package/package.json +57 -36
  10. package/src/components/Avatar/Avatar.scss +90 -0
  11. package/src/components/Avatar/Avatar.tsx +40 -0
  12. package/src/components/Avatar/__stories__/Avatar.stories.tsx +21 -0
  13. package/src/components/Avatar/__test__/utils.test.ts +76 -0
  14. package/src/components/Avatar/index.ts +1 -0
  15. package/src/components/Avatar/utils.tsx +26 -0
  16. package/src/components/Breadcrumbs/Breadcrumbs.tsx +40 -0
  17. package/src/components/Breadcrumbs/__stories__/Breadcrumbs.stories.tsx +20 -0
  18. package/src/components/Breadcrumbs/index.ts +1 -0
  19. package/src/components/Button/Button.scss +245 -0
  20. package/src/components/Button/Button.tsx +34 -0
  21. package/src/components/Button/__stories__/Button.stories.tsx +168 -0
  22. package/src/components/Button/const.ts +26 -0
  23. package/src/components/Button/index.ts +1 -0
  24. package/src/components/Card/Card.scss +13 -0
  25. package/src/components/Card/Card.tsx +12 -0
  26. package/src/components/Card/__stories__/Card.stories.tsx +18 -0
  27. package/src/components/Card/index.ts +1 -0
  28. package/src/components/Checkbox/Checkbox.scss +28 -0
  29. package/src/components/Checkbox/Checkbox.tsx +23 -0
  30. package/src/components/Checkbox/__stories__/Checkbox.stories.tsx +21 -0
  31. package/src/components/Checkbox/index.ts +1 -0
  32. package/src/components/Divider/Divider.scss +62 -0
  33. package/src/components/Divider/Divider.tsx +21 -0
  34. package/src/components/Divider/__stories__/Divider.stories.tsx +68 -0
  35. package/src/components/Divider/index.ts +1 -0
  36. package/src/components/Flex/Flex.scss +94 -0
  37. package/src/components/Flex/Flex.tsx +41 -0
  38. package/src/components/Flex/__stories__/Flex.stories.tsx +27 -0
  39. package/src/components/Flex/index.ts +1 -0
  40. package/src/components/Label/Label.scss +53 -0
  41. package/src/components/Label/Label.tsx +27 -0
  42. package/src/components/Label/__stories__/Label.stories.tsx +26 -0
  43. package/src/components/Label/index.ts +1 -0
  44. package/src/components/Link/Link.scss +13 -0
  45. package/src/components/Link/Link.tsx +18 -0
  46. package/src/components/Link/__stories__/Link.stories.tsx +20 -0
  47. package/src/components/Link/index.ts +1 -0
  48. package/src/components/Loader/Loader.scss +56 -0
  49. package/src/components/Loader/Loader.tsx +33 -0
  50. package/src/components/Loader/__stories__/Loader.stories.tsx +18 -0
  51. package/src/components/Loader/const.ts +7 -0
  52. package/src/components/Loader/index.ts +1 -0
  53. package/src/components/Radio/Radio.scss +28 -0
  54. package/src/components/Radio/Radio.tsx +24 -0
  55. package/src/components/Radio/__stories__/Radio.stories.tsx +21 -0
  56. package/src/components/Radio/index.ts +1 -0
  57. package/src/components/Skeleton/Skeleton.scss +73 -0
  58. package/src/components/Skeleton/Skeleton.tsx +16 -0
  59. package/src/components/Skeleton/__stories__/Skeleton.stories.tsx +16 -0
  60. package/src/components/Skeleton/index.ts +1 -0
  61. package/src/components/Tabs/Tabs.scss +25 -0
  62. package/src/components/Tabs/Tabs.tsx +39 -0
  63. package/src/components/Tabs/__stories__/Tabs.stories.tsx +19 -0
  64. package/src/components/Tabs/index.ts +1 -0
  65. package/src/components/Text/Text.scss +30 -0
  66. package/src/components/Text/Text.tsx +68 -0
  67. package/src/components/Text/_stories_/Text.stories.tsx +95 -0
  68. package/src/components/Text/index.ts +1 -0
  69. package/src/components/TextArea/TextArea.scss +45 -0
  70. package/src/components/TextArea/TextArea.tsx +38 -0
  71. package/src/components/TextArea/__stories__/TextArea.stories.tsx +20 -0
  72. package/src/components/TextArea/index.ts +1 -0
  73. package/src/components/TextInput/TextInput.scss +92 -0
  74. package/src/components/TextInput/TextInput.tsx +43 -0
  75. package/src/components/TextInput/__stories__/TextInput.stories.tsx +40 -0
  76. package/src/components/TextInput/index.ts +1 -0
  77. package/src/components/User/User.scss +7 -0
  78. package/src/components/User/User.tsx +23 -0
  79. package/src/components/User/__stories__/User.stories.tsx +23 -0
  80. package/src/components/User/index.ts +1 -0
  81. package/src/components/index.ts +17 -0
  82. package/src/index.ts +1 -1
  83. package/src/stories/modules.mdx +14 -0
  84. package/src/styles/fonts.scss +1 -0
  85. package/src/styles/mixins/_index.scss +18 -0
  86. package/src/styles/mixins/button.scss +29 -0
  87. package/src/styles/mixins/typography.scss +107 -0
  88. package/src/styles/styles.scss +3 -0
  89. package/src/styles/variables/_index.scss +25 -0
  90. package/src/styles/variables/colors.scss +45 -0
  91. package/src/styles/variables/padding.scss +7 -0
  92. package/src/styles/variables/radius.scss +8 -0
  93. package/src/styles/variables/spacing.scss +15 -0
  94. package/src/styles/variables/typography.scss +66 -0
  95. package/src/utils/bem/__tests__/bem.test.ts +25 -0
  96. package/src/utils/bem/bem.ts +24 -0
  97. package/src/utils/index.ts +1 -0
  98. package/tsconfig.app.json +28 -28
  99. package/tsconfig.build.json +16 -0
  100. package/tsconfig.json +4 -7
  101. package/tsconfig.node.json +26 -26
  102. package/vite.config.ts +78 -32
  103. package/vitest.shims.d.ts +1 -0
  104. package/index.html +0 -13
  105. package/public/vite.svg +0 -1
  106. package/src/components/Button.tsx +0 -9
@@ -0,0 +1,2 @@
1
+ npm test
2
+ npm run lint
package/.prettierrc ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "singleQuote": true,
3
+ "semi": false,
4
+ "trailingComma": "es5",
5
+ "tabWidth": 4,
6
+ "printWidth": 100
7
+ }
@@ -0,0 +1,14 @@
1
+ import type { StorybookConfig } from '@storybook/react-vite'
2
+
3
+ const config: StorybookConfig = {
4
+ stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
5
+ addons: [
6
+ '@chromatic-com/storybook',
7
+ '@storybook/addon-vitest',
8
+ '@storybook/addon-a11y',
9
+ '@storybook/addon-docs',
10
+ '@storybook/addon-onboarding',
11
+ ],
12
+ framework: '@storybook/react-vite',
13
+ }
14
+ export default config
@@ -0,0 +1,21 @@
1
+ import type { Preview } from '@storybook/react-vite'
2
+
3
+ const preview: Preview = {
4
+ parameters: {
5
+ controls: {
6
+ matchers: {
7
+ color: /(background|color)$/i,
8
+ date: /Date$/i,
9
+ },
10
+ },
11
+
12
+ a11y: {
13
+ // 'todo' - show a11y violations in the test UI only
14
+ // 'error' - fail CI on a11y violations
15
+ // 'off' - skip a11y checks entirely
16
+ test: 'todo',
17
+ },
18
+ },
19
+ }
20
+
21
+ export default preview
@@ -0,0 +1,7 @@
1
+ import * as a11yAddonAnnotations from '@storybook/addon-a11y/preview'
2
+ import { setProjectAnnotations } from '@storybook/react-vite'
3
+ import * as projectAnnotations from './preview'
4
+
5
+ // This is an important step to apply the right configuration when testing your stories.
6
+ // More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
7
+ setProjectAnnotations([a11yAddonAnnotations, projectAnnotations])
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 FF_Team
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 FF_Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,73 +1,13 @@
1
- # React + TypeScript + Vite
2
-
3
- This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
-
5
- Currently, two official plugins are available:
6
-
7
- - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
8
- - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9
-
10
- ## React Compiler
11
-
12
- The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
13
-
14
- ## Expanding the ESLint configuration
15
-
16
- If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
17
-
18
- ```js
19
- export default defineConfig([
20
- globalIgnores(['dist']),
21
- {
22
- files: ['**/*.{ts,tsx}'],
23
- extends: [
24
- // Other configs...
25
-
26
- // Remove tseslint.configs.recommended and replace with this
27
- tseslint.configs.recommendedTypeChecked,
28
- // Alternatively, use this for stricter rules
29
- tseslint.configs.strictTypeChecked,
30
- // Optionally, add this for stylistic rules
31
- tseslint.configs.stylisticTypeChecked,
32
-
33
- // Other configs...
34
- ],
35
- languageOptions: {
36
- parserOptions: {
37
- project: ['./tsconfig.node.json', './tsconfig.app.json'],
38
- tsconfigRootDir: import.meta.dirname,
39
- },
40
- // other options...
41
- },
42
- },
43
- ])
44
- ```
45
-
46
- You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
47
-
48
- ```js
49
- // eslint.config.js
50
- import reactX from 'eslint-plugin-react-x'
51
- import reactDom from 'eslint-plugin-react-dom'
52
-
53
- export default defineConfig([
54
- globalIgnores(['dist']),
55
- {
56
- files: ['**/*.{ts,tsx}'],
57
- extends: [
58
- // Other configs...
59
- // Enable lint rules for React
60
- reactX.configs['recommended-typescript'],
61
- // Enable lint rules for React DOM
62
- reactDom.configs.recommended,
63
- ],
64
- languageOptions: {
65
- parserOptions: {
66
- project: ['./tsconfig.node.json', './tsconfig.app.json'],
67
- tsconfigRootDir: import.meta.dirname,
68
- },
69
- // other options...
70
- },
71
- },
72
- ])
73
- ```
1
+ # FF-DS-UI lib
2
+
3
+ ## Publish to Npm
4
+
5
+ ### 1 - version up => package.json, json-lock versions
6
+
7
+ ### 2 - tag => git tag v.0.0.0
8
+
9
+ ### 3 - push tag => git push origin --tags
10
+
11
+ ### 4 - run build => npm run build
12
+
13
+ ### 5 - push packets => npm publish
package/eslint.config.js CHANGED
@@ -1,23 +1,29 @@
1
- import js from '@eslint/js'
2
- import globals from 'globals'
3
- import reactHooks from 'eslint-plugin-react-hooks'
4
- import reactRefresh from 'eslint-plugin-react-refresh'
5
- import tseslint from 'typescript-eslint'
6
- import { defineConfig, globalIgnores } from 'eslint/config'
7
-
8
- export default defineConfig([
9
- globalIgnores(['dist']),
10
- {
11
- files: ['**/*.{ts,tsx}'],
12
- extends: [
13
- js.configs.recommended,
14
- tseslint.configs.recommended,
15
- reactHooks.configs.flat.recommended,
16
- reactRefresh.configs.vite,
17
- ],
18
- languageOptions: {
19
- ecmaVersion: 2020,
20
- globals: globals.browser,
21
- },
22
- },
23
- ])
1
+ // For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format
2
+ import storybook from 'eslint-plugin-storybook'
3
+
4
+ import js from '@eslint/js'
5
+ import globals from 'globals'
6
+ import reactHooks from 'eslint-plugin-react-hooks'
7
+ import reactRefresh from 'eslint-plugin-react-refresh'
8
+ import tseslint from 'typescript-eslint'
9
+ import { defineConfig, globalIgnores } from 'eslint/config'
10
+
11
+ export default defineConfig([
12
+ globalIgnores(['dist']),
13
+ {
14
+ files: ['**/*.{ts,tsx}'],
15
+ extends: [
16
+ js.configs.recommended,
17
+ tseslint.configs.recommended,
18
+ reactHooks.configs.flat.recommended,
19
+ reactRefresh.configs.vite,
20
+ ],
21
+ languageOptions: {
22
+ ecmaVersion: 2020,
23
+ globals: globals.browser,
24
+ },
25
+ rules: {
26
+ '@typescript-eslint/no-unused-vars': 'warn',
27
+ },
28
+ },
29
+ ])
package/package.json CHANGED
@@ -1,36 +1,57 @@
1
- {
2
- "name": "ff-ds-ui",
3
- "private": false,
4
- "version": "0.0.2",
5
- "type": "module",
6
- "main": "./dist/my-ui-lib.umd.js",
7
- "module": "./dist/my-ui-lib.es.js",
8
- "types": "./dist/index.d.ts",
9
- "scripts": {
10
- "dev": "vite",
11
- "build": "tsc -b && vite build",
12
- "lint": "eslint .",
13
- "preview": "vite preview"
14
- },
15
- "peerDependencies": {
16
- "react": "^19.2.0",
17
- "react-dom": "^19.2.0"
18
- },
19
- "devDependencies": {
20
- "react": "^19.2.0",
21
- "react-dom": "^19.2.0",
22
- "@eslint/js": "^9.39.1",
23
- "@types/node": "^24.10.1",
24
- "@types/react": "^19.2.5",
25
- "@types/react-dom": "^19.2.3",
26
- "@vitejs/plugin-react": "^5.1.1",
27
- "eslint": "^9.39.1",
28
- "eslint-plugin-react-hooks": "^7.0.1",
29
- "eslint-plugin-react-refresh": "^0.4.24",
30
- "globals": "^16.5.0",
31
- "typescript": "~5.9.3",
32
- "typescript-eslint": "^8.46.4",
33
- "vite": "^7.2.4",
34
- "vite-plugin-dts": "^4.5.4"
35
- }
36
- }
1
+ {
2
+ "name": "ff-ds-ui",
3
+ "private": false,
4
+ "version": "0.0.4",
5
+ "type": "module",
6
+ "main": "./dist/my-ui-lib.umd.js",
7
+ "module": "./dist/my-ui-lib.es.js",
8
+ "types": "./dist/index.d.ts",
9
+ "scripts": {
10
+ "dev": "vite",
11
+ "build": "tsc -b && vite build",
12
+ "preview": "vite preview",
13
+ "storybook": "storybook dev -p 6006",
14
+ "build-storybook": "storybook build",
15
+ "test": "vitest",
16
+ "lint": "eslint .",
17
+ "format": "npx prettier --write .",
18
+ "prepare": "husky"
19
+ },
20
+ "peerDependencies": {
21
+ "react": "^19.2.0",
22
+ "react-dom": "^19.2.0"
23
+ },
24
+ "devDependencies": {
25
+ "@chromatic-com/storybook": "^4.1.3",
26
+ "@eslint/js": "^9.39.1",
27
+ "@storybook/addon-a11y": "^10.1.8",
28
+ "@storybook/addon-docs": "^10.1.5",
29
+ "@storybook/addon-onboarding": "^10.1.8",
30
+ "@storybook/addon-vitest": "^10.1.8",
31
+ "@storybook/react-vite": "^10.1.5",
32
+ "@storybook/react": "^10.1.10",
33
+ "@types/node": "^24.10.1",
34
+ "@types/react": "^19.2.5",
35
+ "@types/react-dom": "^19.2.3",
36
+ "@vitejs/plugin-react": "^5.1.1",
37
+ "@vitest/browser-playwright": "^4.0.15",
38
+ "@vitest/coverage-v8": "^4.0.15",
39
+ "classnames": "^2.5.1",
40
+ "eslint": "^9.39.1",
41
+ "eslint-plugin-react-hooks": "^7.0.1",
42
+ "eslint-plugin-react-refresh": "^0.4.24",
43
+ "eslint-plugin-storybook": "^10.1.8",
44
+ "globals": "^16.5.0",
45
+ "husky": "^9.1.7",
46
+ "playwright": "^1.57.0",
47
+ "react": "^19.2.0",
48
+ "react-dom": "^19.2.0",
49
+ "sass": "^1.96.0",
50
+ "storybook": "^10.1.8",
51
+ "typescript": "~5.9.3",
52
+ "typescript-eslint": "^8.46.4",
53
+ "vite": "^7.2.4",
54
+ "vite-plugin-dts": "^4.5.4",
55
+ "vitest": "^4.0.15"
56
+ }
57
+ }
@@ -0,0 +1,90 @@
1
+ @use '../../styles/styles.scss' as MainStyles;
2
+ @use '../../styles/variables/colors.scss' as Colors;
3
+
4
+ $block: '.#{MainStyles.$ns}avatar';
5
+
6
+ #{$block} {
7
+ @include Colors.variables;
8
+
9
+ box-sizing: border-box;
10
+ display: flex;
11
+ justify-content: center;
12
+ align-items: center;
13
+
14
+ & > img {
15
+ width: inherit;
16
+ height: inherit;
17
+ border-radius: 100%;
18
+ -webkit-border-radius: 100%;
19
+ -moz-border-radius: 100%;
20
+ -ms-border-radius: 100%;
21
+ -o-border-radius: 100%;
22
+ }
23
+
24
+ &_size {
25
+ &_xs {
26
+ height: 20px;
27
+ width: 20px;
28
+ min-width: 20px;
29
+ }
30
+ &_s {
31
+ height: 24px;
32
+ width: 24px;
33
+ min-width: 24px;
34
+ }
35
+ &_m {
36
+ height: 28px;
37
+ width: 28px;
38
+ min-width: 28px;
39
+ }
40
+ &_l {
41
+ height: 36px;
42
+ width: 36px;
43
+ min-width: 36px;
44
+ }
45
+ &_xl {
46
+ height: 44px;
47
+ width: 44px;
48
+ min-width: 44px;
49
+ }
50
+ }
51
+
52
+ &_variant {
53
+ &_normal {
54
+ background: var(--FF-DS-color-secondary-base);
55
+ border: 1px solid var(--FF-DS-color-secondary-border);
56
+ & > span {
57
+ color: var(--FF-DS-color-secondary-text);
58
+ }
59
+ }
60
+
61
+ &_branded {
62
+ background: var(--FF-DS-color-brand-base);
63
+ border: 1px solid var(--FF-DS-color-brand-border);
64
+ & > span {
65
+ color: var(--FF-DS-color-brand-text);
66
+ }
67
+ }
68
+ }
69
+
70
+ &_outline {
71
+ background: transparent;
72
+ }
73
+
74
+ &_form {
75
+ &_circle {
76
+ border-radius: 100%;
77
+ -webkit-border-radius: 100%;
78
+ -moz-border-radius: 100%;
79
+ -ms-border-radius: 100%;
80
+ -o-border-radius: 100%;
81
+ }
82
+ &_square {
83
+ border-radius: 8px;
84
+ -webkit-border-radius: 8px;
85
+ -moz-border-radius: 8px;
86
+ -ms-border-radius: 8px;
87
+ -o-border-radius: 8px;
88
+ }
89
+ }
90
+ }
@@ -0,0 +1,40 @@
1
+ import React, { useState } from 'react'
2
+ import './Avatar.scss'
3
+ import { bemBlock } from '../../utils'
4
+ import { Text } from '../../components/Text'
5
+ import { getAvatarCamelCaseText } from './utils'
6
+
7
+ export interface AvatarProps {
8
+ size?: 's' | 'm' | 'l' | 'xl'
9
+ variant?: 'normal' | 'branded'
10
+ outline?: boolean
11
+ text?: string
12
+ alt?: string
13
+ imgUrl?: string
14
+ form?: 'circle' | 'square'
15
+ }
16
+
17
+ export const Avatar: React.FC<AvatarProps> = ({
18
+ variant = 'normal',
19
+ outline,
20
+ size = 'xl',
21
+ text,
22
+ alt,
23
+ imgUrl,
24
+ form = 'circle',
25
+ }) => {
26
+ const [hasError, setHasError] = useState<boolean>(false)
27
+
28
+ const b = bemBlock('avatar')
29
+
30
+ return (
31
+ <div className={b({ form, variant, outline, size })}>
32
+ {((hasError === true && imgUrl) || !imgUrl) && text && (
33
+ <Text variant="caption2">{getAvatarCamelCaseText(text)}</Text>
34
+ )}
35
+ {imgUrl && !hasError && (
36
+ <img src={imgUrl} alt={alt} onError={() => setHasError(true)} />
37
+ )}
38
+ </div>
39
+ )
40
+ }
@@ -0,0 +1,21 @@
1
+ import type { Meta, StoryObj } from '@storybook/react'
2
+ import { Avatar } from '../Avatar'
3
+
4
+ const meta = {
5
+ title: 'Components/Avatar',
6
+ component: Avatar,
7
+ tags: ['autodocs'],
8
+ } satisfies Meta<typeof Avatar>
9
+
10
+ export default meta
11
+
12
+ type Story = StoryObj<typeof meta>
13
+
14
+ export const Avatar_default: Story = {
15
+ args: {
16
+ size: 's',
17
+ text: 'Author Comp',
18
+ alt: 'img desc',
19
+ imgUrl: 'https://inbusiness.kz/uploads/2025-8/o0INDAPX.jpg',
20
+ },
21
+ }
@@ -0,0 +1,76 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { getAvatarCamelCaseText } from '../utils'
3
+
4
+ describe('src => comp => Avatar => utils.ts', () => {
5
+ it('test getAvatarCamelCaseText function = 1 word', () => {
6
+ const testString: string = 'TEXT'
7
+ const resString = getAvatarCamelCaseText(testString)
8
+ expect(resString).toBe('TE')
9
+ })
10
+
11
+ it('test getAvatarCamelCaseText function = 1 lowercase word', () => {
12
+ const testString: string = 'text'
13
+ const resString = getAvatarCamelCaseText(testString)
14
+ expect(resString).toBe('TE')
15
+ })
16
+
17
+ it('test getAvatarCamelCaseText function - 2 word', () => {
18
+ const testString: string = 'ANY TEXT'
19
+ const resString = getAvatarCamelCaseText(testString)
20
+ expect(resString).toBe('AT')
21
+ })
22
+
23
+ it('test getAvatarCamelCaseText function = 2 lowercase word', () => {
24
+ const testString: string = 'any text'
25
+ const resString = getAvatarCamelCaseText(testString)
26
+ expect(resString).toBe('AT')
27
+ })
28
+
29
+ it('test getAvatarCamelCaseText function = empty', () => {
30
+ const testString: string = ' '
31
+ const resString = getAvatarCamelCaseText(testString)
32
+ expect(resString).toBe('')
33
+ })
34
+
35
+ it('test getAvatarCamelCaseText function = 1 word 1 char', () => {
36
+ const testString: string = 'a'
37
+ const resString = getAvatarCamelCaseText(testString)
38
+ expect(resString).toBe('A')
39
+ })
40
+
41
+ it('test getAvatarCamelCaseText function = 2 word 1 char', () => {
42
+ const testString: string = 'a a'
43
+ const resString = getAvatarCamelCaseText(testString)
44
+ expect(resString).toBe('AA')
45
+ })
46
+
47
+ it('test getAvatarCamelCaseText function = 3 word', () => {
48
+ const testString: string = 'any text asd'
49
+ const resString = getAvatarCamelCaseText(testString)
50
+ expect(resString).toBe('AT')
51
+ })
52
+
53
+ it('test getAvatarCamelCaseText function = 3 word 1 char', () => {
54
+ const testString: string = 'a f a'
55
+ const resString = getAvatarCamelCaseText(testString)
56
+ expect(resString).toBe('AF')
57
+ })
58
+
59
+ it('test getAvatarCamelCaseText function = 1 word space', () => {
60
+ const testString: string = 'any '
61
+ const resString = getAvatarCamelCaseText(testString)
62
+ expect(resString).toBe('AN')
63
+ })
64
+
65
+ it('test getAvatarCamelCaseText function = 1 word space', () => {
66
+ const testString: string = ' any '
67
+ const resString = getAvatarCamelCaseText(testString)
68
+ expect(resString).toBe('AN')
69
+ })
70
+
71
+ it('test getAvatarCamelCaseText function = 2 word space', () => {
72
+ const testString: string = ' aaaa ffff '
73
+ const resString = getAvatarCamelCaseText(testString)
74
+ expect(resString).toBe('AF')
75
+ })
76
+ })
@@ -0,0 +1 @@
1
+ export * from './Avatar'
@@ -0,0 +1,26 @@
1
+ /**
2
+ * getAvatarCamelCaseText - transform string to first letter of words
3
+ * @param {string} str
4
+ * @returns {string | ''} string | ''
5
+ */
6
+ export const getAvatarCamelCaseText = (str?: string): string => {
7
+ if (!str) return ''
8
+
9
+ const wordArr: string[] = str
10
+ .trim()
11
+ .split(' ')
12
+ .filter((el) => Boolean(el))
13
+
14
+ if (wordArr.length === 0) {
15
+ return ''
16
+ }
17
+
18
+ const wordArrLen: number = wordArr.length
19
+ const resStr = wordArr.join('')
20
+
21
+ if (wordArrLen > 1) {
22
+ return wordArr[0][0].toUpperCase() + wordArr[1][0].toUpperCase()
23
+ } else {
24
+ return `${resStr[0].toUpperCase()}${resStr[1]?.toUpperCase() || ''}`
25
+ }
26
+ }
@@ -0,0 +1,40 @@
1
+ import React from 'react'
2
+ import { Flex } from '../Flex'
3
+ import { Text } from '../Text'
4
+
5
+ interface BreadcrumbsProps {
6
+ separator?: string
7
+ onItemClick?: (value: string) => void
8
+ items: string[]
9
+ }
10
+
11
+ export const Breadcrumbs: React.FC<BreadcrumbsProps> = ({
12
+ separator = '/',
13
+ items,
14
+ onItemClick,
15
+ }) => {
16
+ //TODO: сделать cursor pointer если = clickable: Boolean(onItemClick)
17
+ return (
18
+ <Flex gap="s">
19
+ {items.map((item, i) => {
20
+ const isLastElement = items.length - 1 === i
21
+ return (
22
+ <>
23
+ <Text
24
+ onClick={() => onItemClick && onItemClick(item)}
25
+ color="secondary"
26
+ variant="body1"
27
+ >
28
+ {item}
29
+ </Text>
30
+ {!isLastElement && (
31
+ <Text variant="body1" color="secondary">
32
+ {separator}
33
+ </Text>
34
+ )}
35
+ </>
36
+ )
37
+ })}
38
+ </Flex>
39
+ )
40
+ }
@@ -0,0 +1,20 @@
1
+ import type { Meta, StoryObj } from '@storybook/react'
2
+ import { Breadcrumbs } from '../Breadcrumbs'
3
+
4
+ const meta = {
5
+ title: 'Components/Breadcrumbs',
6
+ component: Breadcrumbs,
7
+ tags: ['autodocs'],
8
+ } satisfies Meta<typeof Breadcrumbs>
9
+
10
+ export default meta
11
+
12
+ type Story = StoryObj<typeof meta>
13
+
14
+ export const Breadcrumbs_default: Story = {
15
+ args: {
16
+ items: ['main page', 'projects', 'proj1'],
17
+ onItemClick: (value) => console.log(value),
18
+ separator: '/',
19
+ },
20
+ }
@@ -0,0 +1 @@
1
+ export * from './Breadcrumbs'