@mmb-digital/design-system-web 0.1.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 (127) hide show
  1. package/.babelrc.json +16 -0
  2. package/.eslintrc.js +165 -0
  3. package/.prettierrc.js +15 -0
  4. package/.storybook/main.ts +23 -0
  5. package/.storybook/preview.tsx +27 -0
  6. package/dist/cjs/index.js +131 -0
  7. package/dist/cjs/index.js.map +1 -0
  8. package/dist/cjs/types/jest.config.d.ts +7 -0
  9. package/dist/cjs/types/src/components/button/button.d.ts +4 -0
  10. package/dist/cjs/types/src/components/button/button.styles.d.ts +4 -0
  11. package/dist/cjs/types/src/components/button/button.test.d.ts +1 -0
  12. package/dist/cjs/types/src/components/button/button.types.d.ts +29 -0
  13. package/dist/cjs/types/src/components/form/hint/formHint.d.ts +4 -0
  14. package/dist/cjs/types/src/components/form/hint/formHint.style.d.ts +1 -0
  15. package/dist/cjs/types/src/components/form/hint/formHint.types.d.ts +4 -0
  16. package/dist/cjs/types/src/components/slider/slider/slider.d.ts +5 -0
  17. package/dist/cjs/types/src/components/slider/slider/slider.style.d.ts +5 -0
  18. package/dist/cjs/types/src/components/slider/slider/slider.types.d.ts +47 -0
  19. package/dist/cjs/types/src/components/slider/slider/sliderFunction/default/sliderFunctionDefault.d.ts +2 -0
  20. package/dist/cjs/types/src/components/slider/slider/sliderFunction/default/sliderStep.d.ts +7 -0
  21. package/dist/cjs/types/src/components/slider/slider/sliderFunction/default/sliderStep.test.d.ts +1 -0
  22. package/dist/cjs/types/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderFunctionLinearVisualSteps.d.ts +2 -0
  23. package/dist/cjs/types/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderMax.d.ts +8 -0
  24. package/dist/cjs/types/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderMax.test.d.ts +1 -0
  25. package/dist/cjs/types/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderValueByValue.d.ts +9 -0
  26. package/dist/cjs/types/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderValueByValue.test.d.ts +1 -0
  27. package/dist/cjs/types/src/components/slider/slider/sliderFunction/linearVisualSteps/valueBySliderValue.d.ts +2 -0
  28. package/dist/cjs/types/src/components/slider/slider/sliderFunction/linearVisualSteps/valueBySliderValue.test.d.ts +1 -0
  29. package/dist/cjs/types/src/components/slider/slider/sliderHandleSvgHandler.d.ts +2 -0
  30. package/dist/cjs/types/src/components/storeButton/assets/androidSvg.d.ts +8 -0
  31. package/dist/cjs/types/src/components/storeButton/assets/appleSvg.d.ts +8 -0
  32. package/dist/cjs/types/src/components/storeButton/storeButton.d.ts +4 -0
  33. package/dist/cjs/types/src/components/storeButton/storeButton.styles.d.ts +3 -0
  34. package/dist/cjs/types/src/components/storeButton/storeButton.test.d.ts +1 -0
  35. package/dist/cjs/types/src/components/storeButton/storeButton.types.d.ts +13 -0
  36. package/dist/cjs/types/src/icons/systemIcon.d.ts +8 -0
  37. package/dist/cjs/types/src/index.d.ts +1 -0
  38. package/dist/cjs/types/src/provider/storybook/storybookProvider.d.ts +4 -0
  39. package/dist/cjs/types/src/provider/storybook/storybookProvider.types.d.ts +4 -0
  40. package/dist/cjs/types/src/provider/styledComponents/theme/styledComponentsThemeProvider.d.ts +4 -0
  41. package/dist/cjs/types/src/provider/styledComponents/theme/styledComponentsThemeProvider.types..d.ts +4 -0
  42. package/dist/cjs/types/src/style/styledComponents/theme.d.ts +441 -0
  43. package/dist/esm/index.js +131 -0
  44. package/dist/esm/index.js.map +1 -0
  45. package/dist/esm/types/jest.config.d.ts +7 -0
  46. package/dist/esm/types/src/components/button/button.d.ts +4 -0
  47. package/dist/esm/types/src/components/button/button.styles.d.ts +4 -0
  48. package/dist/esm/types/src/components/button/button.test.d.ts +1 -0
  49. package/dist/esm/types/src/components/button/button.types.d.ts +29 -0
  50. package/dist/esm/types/src/components/form/hint/formHint.d.ts +4 -0
  51. package/dist/esm/types/src/components/form/hint/formHint.style.d.ts +1 -0
  52. package/dist/esm/types/src/components/form/hint/formHint.types.d.ts +4 -0
  53. package/dist/esm/types/src/components/slider/slider/slider.d.ts +5 -0
  54. package/dist/esm/types/src/components/slider/slider/slider.style.d.ts +5 -0
  55. package/dist/esm/types/src/components/slider/slider/slider.types.d.ts +47 -0
  56. package/dist/esm/types/src/components/slider/slider/sliderFunction/default/sliderFunctionDefault.d.ts +2 -0
  57. package/dist/esm/types/src/components/slider/slider/sliderFunction/default/sliderStep.d.ts +7 -0
  58. package/dist/esm/types/src/components/slider/slider/sliderFunction/default/sliderStep.test.d.ts +1 -0
  59. package/dist/esm/types/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderFunctionLinearVisualSteps.d.ts +2 -0
  60. package/dist/esm/types/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderMax.d.ts +8 -0
  61. package/dist/esm/types/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderMax.test.d.ts +1 -0
  62. package/dist/esm/types/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderValueByValue.d.ts +9 -0
  63. package/dist/esm/types/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderValueByValue.test.d.ts +1 -0
  64. package/dist/esm/types/src/components/slider/slider/sliderFunction/linearVisualSteps/valueBySliderValue.d.ts +2 -0
  65. package/dist/esm/types/src/components/slider/slider/sliderFunction/linearVisualSteps/valueBySliderValue.test.d.ts +1 -0
  66. package/dist/esm/types/src/components/slider/slider/sliderHandleSvgHandler.d.ts +2 -0
  67. package/dist/esm/types/src/components/storeButton/assets/androidSvg.d.ts +8 -0
  68. package/dist/esm/types/src/components/storeButton/assets/appleSvg.d.ts +8 -0
  69. package/dist/esm/types/src/components/storeButton/storeButton.d.ts +4 -0
  70. package/dist/esm/types/src/components/storeButton/storeButton.styles.d.ts +3 -0
  71. package/dist/esm/types/src/components/storeButton/storeButton.test.d.ts +1 -0
  72. package/dist/esm/types/src/components/storeButton/storeButton.types.d.ts +13 -0
  73. package/dist/esm/types/src/icons/systemIcon.d.ts +8 -0
  74. package/dist/esm/types/src/index.d.ts +1 -0
  75. package/dist/esm/types/src/provider/storybook/storybookProvider.d.ts +4 -0
  76. package/dist/esm/types/src/provider/storybook/storybookProvider.types.d.ts +4 -0
  77. package/dist/esm/types/src/provider/styledComponents/theme/styledComponentsThemeProvider.d.ts +4 -0
  78. package/dist/esm/types/src/provider/styledComponents/theme/styledComponentsThemeProvider.types..d.ts +4 -0
  79. package/dist/esm/types/src/style/styledComponents/theme.d.ts +441 -0
  80. package/jest.config.ts +197 -0
  81. package/package.json +97 -0
  82. package/readme.md +39 -0
  83. package/rollup.config.js +33 -0
  84. package/src/@types/json.d.ts +5 -0
  85. package/src/@types/styledComponentCssProps.d.ts +11 -0
  86. package/src/@types/styledComponentTheme.d.ts +9 -0
  87. package/src/components/button/button.stories.tsx +97 -0
  88. package/src/components/button/button.styles.ts +162 -0
  89. package/src/components/button/button.test.tsx +25 -0
  90. package/src/components/button/button.tsx +31 -0
  91. package/src/components/button/button.types.ts +33 -0
  92. package/src/components/form/hint/formHint.style.ts +10 -0
  93. package/src/components/form/hint/formHint.tsx +13 -0
  94. package/src/components/form/hint/formHint.types.ts +5 -0
  95. package/src/components/slider/slider/slider.stories.tsx +176 -0
  96. package/src/components/slider/slider/slider.style.ts +29 -0
  97. package/src/components/slider/slider/slider.tsx +136 -0
  98. package/src/components/slider/slider/slider.types.ts +58 -0
  99. package/src/components/slider/slider/sliderFunction/default/sliderFunctionDefault.ts +21 -0
  100. package/src/components/slider/slider/sliderFunction/default/sliderStep.test.ts +90 -0
  101. package/src/components/slider/slider/sliderFunction/default/sliderStep.ts +18 -0
  102. package/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderFunctionLinearVisualSteps.ts +28 -0
  103. package/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderMax.test.ts +83 -0
  104. package/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderMax.ts +34 -0
  105. package/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderValueByValue.test.ts +249 -0
  106. package/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderValueByValue.ts +41 -0
  107. package/src/components/slider/slider/sliderFunction/linearVisualSteps/valueBySliderValue.test.ts +204 -0
  108. package/src/components/slider/slider/sliderFunction/linearVisualSteps/valueBySliderValue.ts +35 -0
  109. package/src/components/slider/slider/sliderHandleSvgHandler.ts +26 -0
  110. package/src/components/storeButton/assets/androidSvg.tsx +159 -0
  111. package/src/components/storeButton/assets/appleSvg.tsx +31 -0
  112. package/src/components/storeButton/storeButton.stories.tsx +67 -0
  113. package/src/components/storeButton/storeButton.styles.ts +36 -0
  114. package/src/components/storeButton/storeButton.test.tsx +22 -0
  115. package/src/components/storeButton/storeButton.tsx +30 -0
  116. package/src/components/storeButton/storeButton.types.tsx +15 -0
  117. package/src/icons/systemIcon.tsx +26 -0
  118. package/src/index.ts +1 -0
  119. package/src/provider/storybook/storybookProvider.tsx +11 -0
  120. package/src/provider/storybook/storybookProvider.types.ts +5 -0
  121. package/src/provider/styledComponents/theme/styledComponentsThemeProvider.tsx +14 -0
  122. package/src/provider/styledComponents/theme/styledComponentsThemeProvider.types..ts +5 -0
  123. package/src/style/styledComponents/mmb_variables-5224.json +958 -0
  124. package/src/style/styledComponents/theme.ts +450 -0
  125. package/stylelint.config.js +15 -0
  126. package/tsconfig.json +29 -0
  127. package/tsconfig.tsbuildinfo +1 -0
package/jest.config.ts ADDED
@@ -0,0 +1,197 @@
1
+ /**
2
+ * For a detailed explanation regarding each configuration property, visit:
3
+ * https://jestjs.io/docs/configuration
4
+ */
5
+
6
+ import type { Config } from 'jest';
7
+
8
+ const config: Config = {
9
+ // All imported modules in your tests should be mocked automatically
10
+ // automock: false,
11
+
12
+ // Stop running tests after `n` failures
13
+ // bail: 0,
14
+
15
+ // The directory where Jest should store its cached dependency information
16
+ // cacheDirectory: "C:\\Users\\543832212\\AppData\\Local\\Temp\\jest",
17
+
18
+ // Automatically clear mock calls, instances, contexts and results before every test
19
+ // clearMocks: false,
20
+
21
+ // Indicates whether the coverage information should be collected while executing the test
22
+ // collectCoverage: false,
23
+
24
+ // An array of glob patterns indicating a set of files for which coverage information should be collected
25
+ // collectCoverageFrom: undefined,
26
+
27
+ // The directory where Jest should output its coverage files
28
+ // coverageDirectory: undefined,
29
+
30
+ // An array of regexp pattern strings used to skip coverage collection
31
+ // coveragePathIgnorePatterns: [
32
+ // "\\\\node_modules\\\\"
33
+ // ],
34
+
35
+ // Indicates which provider should be used to instrument code for coverage
36
+ // coverageProvider: "babel",
37
+
38
+ // A list of reporter names that Jest uses when writing coverage reports
39
+ // coverageReporters: [
40
+ // "json",
41
+ // "text",
42
+ // "lcov",
43
+ // "clover"
44
+ // ],
45
+
46
+ // An object that configures minimum threshold enforcement for coverage results
47
+ // coverageThreshold: undefined,
48
+
49
+ // A path to a custom dependency extractor
50
+ // dependencyExtractor: undefined,
51
+
52
+ // Make calling deprecated APIs throw helpful error messages
53
+ // errorOnDeprecated: false,
54
+
55
+ // The default configuration for fake timers
56
+ // fakeTimers: {
57
+ // "enableGlobally": false
58
+ // },
59
+
60
+ // Force coverage collection from ignored files using an array of glob patterns
61
+ // forceCoverageMatch: [],
62
+
63
+ // A path to a module which exports an async function that is triggered once before all test suites
64
+ // globalSetup: undefined,
65
+
66
+ // A path to a module which exports an async function that is triggered once after all test suites
67
+ // globalTeardown: undefined,
68
+
69
+ // A set of global variables that need to be available in all test environments
70
+ // globals: {},
71
+
72
+ // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
73
+ // maxWorkers: "50%",
74
+
75
+ // An array of directory names to be searched recursively up from the requiring module's location
76
+ moduleDirectories: ['node_modules', '<rootDir>/src'],
77
+
78
+ // An array of file extensions your modules use
79
+ // moduleFileExtensions: [
80
+ // "js",
81
+ // "mjs",
82
+ // "cjs",
83
+ // "jsx",
84
+ // "ts",
85
+ // "tsx",
86
+ // "json",
87
+ // "node"
88
+ // ],
89
+
90
+ // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
91
+ moduleNameMapper: {
92
+ '^@/(.*)$': '<rootDir>/src/$1',
93
+ },
94
+
95
+ // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
96
+ // modulePathIgnorePatterns: [],
97
+
98
+ // Activates notifications for test results
99
+ // notify: false,
100
+
101
+ // An enum that specifies notification mode. Requires { notify: true }
102
+ // notifyMode: "failure-change",
103
+
104
+ // A preset that is used as a base for Jest's configuration
105
+ // preset: undefined,
106
+
107
+ // Run tests from one or more projects
108
+ // projects: undefined,
109
+
110
+ // Use this configuration option to add custom reporters to Jest
111
+ // reporters: undefined,
112
+
113
+ // Automatically reset mock state before every test
114
+ // resetMocks: false,
115
+
116
+ // Reset the module registry before running each individual test
117
+ // resetModules: false,
118
+
119
+ // A path to a custom resolver
120
+ // resolver: undefined,
121
+
122
+ // Automatically restore mock state and implementation before every test
123
+ // restoreMocks: false,
124
+
125
+ // The root directory that Jest should scan for tests and modules within
126
+ // rootDir: undefined,
127
+
128
+ // A list of paths to directories that Jest should use to search for files in
129
+ roots: ['<rootDir>/src'],
130
+
131
+ // Allows you to use a custom runner instead of Jest's default test runner
132
+ // runner: "jest-runner",
133
+
134
+ // The paths to modules that run some code to configure or set up the testing environment before each test
135
+ // setupFiles: [],
136
+
137
+ // A list of paths to modules that run some code to configure or set up the testing framework before each test
138
+ // setupFilesAfterEnv: [],
139
+
140
+ // The number of seconds after which a test is considered as slow and reported as such in the results.
141
+ // slowTestThreshold: 5,
142
+
143
+ // A list of paths to snapshot serializer modules Jest should use for snapshot testing
144
+ // snapshotSerializers: [],
145
+
146
+ // The test environment that will be used for testing
147
+ testEnvironment: 'jsdom',
148
+
149
+ // Options that will be passed to the testEnvironment
150
+ // testEnvironmentOptions: {},
151
+
152
+ // Adds a location field to test results
153
+ // testLocationInResults: false,
154
+
155
+ // The glob patterns Jest uses to detect test files
156
+ // testMatch: [
157
+ // "**/__tests__/**/*.[jt]s?(x)",
158
+ // "**/?(*.)+(spec|test).[tj]s?(x)"
159
+ // ],
160
+
161
+ // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
162
+ // testPathIgnorePatterns: [
163
+ // "\\\\node_modules\\\\"
164
+ // ],
165
+
166
+ // The regexp pattern or array of patterns that Jest uses to detect test files
167
+ // testRegex: [],
168
+
169
+ // This option allows the use of a custom results processor
170
+ // testResultsProcessor: undefined,
171
+
172
+ // This option allows use of a custom test runner
173
+ // testRunner: "jest-circus/runner",
174
+
175
+ // A map from regular expressions to paths to transformers
176
+ // transform: undefined,
177
+
178
+ // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
179
+ // transformIgnorePatterns: [
180
+ // "\\\\node_modules\\\\",
181
+ // "\\.pnp\\.[^\\\\]+$"
182
+ // ],
183
+
184
+ // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
185
+ // unmockedModulePathPatterns: undefined,
186
+
187
+ // Indicates whether each individual test should be reported during the run
188
+ // verbose: undefined,
189
+
190
+ // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
191
+ // watchPathIgnorePatterns: [],
192
+
193
+ // Whether to use watchman for file crawling
194
+ // watchman: true,
195
+ };
196
+
197
+ export default config;
package/package.json ADDED
@@ -0,0 +1,97 @@
1
+ {
2
+ "name": "@mmb-digital/design-system-web",
3
+ "version": "0.1.0",
4
+ "description": "MMB design-system-web",
5
+ "main": "dist/cjs/index.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "repository": "https://bitbucket.lb.mbid.cz/scm/react/design-system-web.git",
9
+ "author": "Kasman, Samuel (MONETA,consultant) <samuel.kasman@moneta.cz>",
10
+ "license": "UNLICENSED",
11
+ "private": false,
12
+ "engines": {
13
+ "node": ">=16.20 <17"
14
+ },
15
+ "scripts": {
16
+ "build": "rollup -c --bundleConfigAsCjs",
17
+ "l": "yarn eslint src",
18
+ "lint:fix": "yarn eslint --fix",
19
+ "lf": "yarn lint:fix",
20
+ "prettier": "./node_modules/.bin/prettier --check \"src/**/*.tsx\" \"src/**/*.ts\"",
21
+ "p": "yarn prettier",
22
+ "prettier:fix": "yarn prettier --write",
23
+ "pf": "yarn prettier:fix",
24
+ "tsc": "./node_modules/.bin/tsc -p ./tsconfig.json --strict",
25
+ "storybook": "storybook dev -p 6006",
26
+ "sb": "yarn storybook",
27
+ "build-storybook": "storybook build",
28
+ "stylelint": "stylelint \"./src/**/*.ts\" \"./src/**/*.tsx\"",
29
+ "sl": "yarn stylelint",
30
+ "jest": "jest",
31
+ "j": "yarn jest",
32
+ "jest:watch": "jest --watch",
33
+ "jw": "yarn jest:watch"
34
+ },
35
+ "devDependencies": {
36
+ "@babel/preset-env": "7.23.9",
37
+ "@babel/preset-react": "7.23.3",
38
+ "@babel/preset-typescript": "7.23.3",
39
+ "@rollup/plugin-commonjs": "25.0.7",
40
+ "@rollup/plugin-node-resolve": "15.2.3",
41
+ "@rollup/plugin-typescript": "11.1.6",
42
+ "@storybook/addon-essentials": "7.6.12",
43
+ "@storybook/addon-interactions": "7.6.12",
44
+ "@storybook/addon-links": "7.6.12",
45
+ "@storybook/blocks": "7.6.12",
46
+ "@storybook/react": "7.6.12",
47
+ "@storybook/react-webpack5": "7.6.12",
48
+ "@storybook/testing-library": "0.0.14-next.2",
49
+ "@testing-library/jest-dom": "6.4.0",
50
+ "@testing-library/react": "14.2.0",
51
+ "@testing-library/user-event": "14.5.2",
52
+ "@types/base-64": "1.0.2",
53
+ "@types/jest": "29.5.11",
54
+ "@types/react": "18.2.48",
55
+ "@types/styled-components": "5.1.34",
56
+ "@typescript-eslint/eslint-plugin": "6.20.0",
57
+ "@typescript-eslint/parser": "6.20.0",
58
+ "babel-plugin-styled-components": "2.1.4",
59
+ "base-64": "1.0.0",
60
+ "eslint": "8.56.0",
61
+ "eslint-plugin-import": "2.29.1",
62
+ "eslint-plugin-react": "7.33.2",
63
+ "eslint-plugin-react-hooks": "4.6.0",
64
+ "eslint-plugin-sort-destructure-keys": "1.5.0",
65
+ "eslint-plugin-storybook": "0.6.15",
66
+ "eslint-plugin-typescript-sort-keys": "3.1.0",
67
+ "eslint-plugin-unicorn": "51.0.1",
68
+ "husky": "8.0.3",
69
+ "jest": "29.7.0",
70
+ "jest-environment-jsdom": "29.7.0",
71
+ "lint-staged": "14.0.1",
72
+ "postcss-styled-syntax": "0.6.4",
73
+ "prettier": "3.2.4",
74
+ "prop-types": "15.8.1",
75
+ "rc-slider": "10.5.0",
76
+ "react": "18.2.0",
77
+ "react-dom": "18.2.0",
78
+ "rollup": "3.29.4",
79
+ "rollup-plugin-dts": "6.1.0",
80
+ "rollup-plugin-peer-deps-external": "2.2.4",
81
+ "rollup-plugin-terser": "7.0.2",
82
+ "storybook": "7.6.12",
83
+ "styled-components": "6.1.8",
84
+ "stylelint": "15.11.0",
85
+ "stylelint-config-recess-order": "4.4.0",
86
+ "stylelint-config-standard": "34.0.0",
87
+ "ts-node": "10.9.2",
88
+ "typescript": "5.3.3"
89
+ },
90
+ "resolutions": {
91
+ "jackspeak": "2.1.1"
92
+ },
93
+ "lint-staged": {
94
+ "*.{js,ts}": "l",
95
+ "*.{css,scss}": "sl"
96
+ }
97
+ }
package/readme.md ADDED
@@ -0,0 +1,39 @@
1
+ design-system-web (react components library)
2
+
3
+ Prerequisities:
4
+
5
+ - node v16.20.2
6
+ - yarn v1.22.19
7
+
8
+ Startup:
9
+
10
+ - checkout repo
11
+
12
+ - run in command prompt:
13
+ "set HTTP_PROXY=http://{USER_SSO}:{SSO_PASSWORD}@wsa.lb.mbid.cz:8008"
14
+ "set HTTPS_PROXY=http://{USER_SSO}:{SSO_PASSWORD}@wsa.lb.mbid.cz:8008"
15
+ "set NO_PROXY=sourcerepos,artifactory,rhproxy,bitbucket,.ux.mbid.cz,.lb.mbid.cz,.mbid.cz"
16
+ "set NODE_OPTIONS=--max-old-space-size=8192"
17
+ "set Path={NODE_PATH};%Path%"
18
+
19
+ - "yarn"
20
+
21
+ Scripts:
22
+
23
+ - fix lint errors
24
+ "yarn lint:fix"
25
+
26
+ - fix prettier errors
27
+ "yarn prettier:fix"
28
+
29
+ - storybook dev
30
+ "yarn storybook"
31
+
32
+ - storybook build
33
+ "yarn storybook:build"
34
+
35
+ - run jest tests
36
+ "yarn test"
37
+
38
+ - rollup bundle
39
+ "yarn build"
@@ -0,0 +1,33 @@
1
+ import resolve from '@rollup/plugin-node-resolve';
2
+ import commonjs from '@rollup/plugin-commonjs';
3
+ import typescript from '@rollup/plugin-typescript';
4
+ import dts from 'rollup-plugin-dts';
5
+ import { terser } from 'rollup-plugin-terser';
6
+ import peerDepsExternal from 'rollup-plugin-peer-deps-external';
7
+
8
+ const packageJson = require('./package.json');
9
+
10
+ export default [
11
+ {
12
+ input: 'src/index.ts',
13
+ output: [
14
+ {
15
+ file: packageJson.main,
16
+ format: 'cjs',
17
+ sourcemap: true,
18
+ },
19
+ {
20
+ file: packageJson.module,
21
+ format: 'esm',
22
+ sourcemap: true,
23
+ },
24
+ ],
25
+ plugins: [peerDepsExternal(), resolve(), commonjs(), typescript({ tsconfig: './tsconfig.json' }), terser()],
26
+ external: ['react', 'react-dom', 'styled-components'],
27
+ },
28
+ {
29
+ input: 'src/index.ts',
30
+ output: [{ file: 'dist/types.d.ts', format: 'es' }],
31
+ plugins: [dts.default()],
32
+ },
33
+ ];
@@ -0,0 +1,5 @@
1
+ declare module '*.json' {
2
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
+ const value: any;
4
+ export default value;
5
+ }
@@ -0,0 +1,11 @@
1
+ import { CSSProp } from 'styled-components';
2
+
3
+ import { theme } from '@/style/styledComponents/theme';
4
+
5
+ type CustomTheme = typeof theme;
6
+
7
+ declare module 'react' {
8
+ interface Attributes {
9
+ css?: CSSProp<CustomTheme>;
10
+ }
11
+ }
@@ -0,0 +1,9 @@
1
+ import 'styled-components';
2
+
3
+ import { theme } from '@/style/styledComponents/theme';
4
+
5
+ type CustomTheme = typeof theme;
6
+
7
+ declare module 'styled-components' {
8
+ export interface DefaultTheme extends CustomTheme {}
9
+ }
@@ -0,0 +1,97 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+
3
+ import Button from './button';
4
+ import { ButtonSize, ButtonStyle, ButtonType, Props } from './button.types';
5
+ import React from 'react';
6
+ import { SystemIcon } from '@/icons/systemIcon';
7
+
8
+ const meta = {
9
+ title: 'Button',
10
+ component: Button,
11
+ parameters: {},
12
+ tags: ['autodocs'],
13
+ argTypes: {},
14
+ decorators: [
15
+ (story) => {
16
+ return <>{story()}</>;
17
+ },
18
+ ],
19
+ } satisfies Meta<typeof Button>;
20
+
21
+ export default meta;
22
+
23
+ type Story = StoryObj<typeof meta>;
24
+
25
+ const defaultStyle: ButtonStyle = ButtonStyle.PRIMARY;
26
+ const defaultSize: ButtonSize = ButtonSize.MD;
27
+ const defaultChildren = 'button';
28
+
29
+ const defaultProps: Props = {
30
+ buttonStyle: defaultStyle,
31
+ size: defaultSize,
32
+ children: defaultChildren,
33
+ };
34
+
35
+ export const Default: Story = {
36
+ args: {
37
+ children: 'button',
38
+ buttonStyle: ButtonStyle.PRIMARY,
39
+ size: ButtonSize.MD,
40
+ disabled: false,
41
+ displayOnlyIcon: false,
42
+ iconLeft: <SystemIcon />,
43
+ iconRight: <SystemIcon />,
44
+ type: ButtonType.BUTTON,
45
+ },
46
+ argTypes: {
47
+ buttonStyle: {
48
+ type: {
49
+ name: 'enum',
50
+ value: Object.values(ButtonStyle),
51
+ },
52
+ },
53
+ size: {
54
+ type: {
55
+ name: 'enum',
56
+ value: Object.values(ButtonSize),
57
+ },
58
+ },
59
+ displayOnlyIcon: {
60
+ type: {
61
+ name: 'boolean',
62
+ },
63
+ },
64
+ disabled: {
65
+ type: {
66
+ name: 'boolean',
67
+ },
68
+ },
69
+ },
70
+ };
71
+
72
+ export const TypeButton: Story = {
73
+ args: {
74
+ ...defaultProps,
75
+ },
76
+ };
77
+
78
+ export const TypePrimary: Story = {
79
+ args: { children: 'Primary button', buttonStyle: ButtonStyle.PRIMARY, size: defaultSize },
80
+ };
81
+
82
+ export const TypeSecondary: Story = {
83
+ args: { children: 'Secondary button', buttonStyle: ButtonStyle.SECONDARY, size: defaultSize },
84
+ };
85
+
86
+ export const TypeTertiary: Story = {
87
+ args: { children: 'Tertiary button', buttonStyle: ButtonStyle.TERTIARY, size: defaultSize },
88
+ };
89
+
90
+ export const WithOnClick: Story = {
91
+ args: {
92
+ ...defaultProps,
93
+ onClick: () => {
94
+ console.log('onClick');
95
+ },
96
+ },
97
+ };
@@ -0,0 +1,162 @@
1
+ import styled, { css } from 'styled-components';
2
+
3
+ import { ButtonSize, ButtonStyle, Props } from './button.types';
4
+
5
+ export const ButtonStyled = styled.button<Partial<Props>>`
6
+ /* common styles */
7
+ display: flex;
8
+ flex-shrink: 0;
9
+ align-items: center;
10
+ justify-content: center;
11
+ cursor: pointer;
12
+
13
+ /* type specific styles */
14
+ ${({ buttonStyle }) => {
15
+ switch (buttonStyle) {
16
+ case ButtonStyle.PRIMARY:
17
+ return css`
18
+ color: ${({ theme }) => theme.colors.fg.neutral.white.light};
19
+ background-color: ${({ theme }) => theme.colors.bg.brand.bold.light};
20
+ border: 1px solid ${({ theme }) => theme.colors.border.brand.bold.light};
21
+
22
+ &:hover {
23
+ background-color: ${({ theme }) => theme.colors.bg.brand.bold.hover.light};
24
+ }
25
+
26
+ &:focus {
27
+ box-shadow: ${({ theme }) => theme.colors.shadow.buttonFocus};
28
+ }
29
+
30
+ &:active {
31
+ background-color: ${({ theme }) => theme.colors.bg.brand.bold.pressed.light};
32
+ }
33
+
34
+ &:disabled {
35
+ color: ${({ theme }) => theme.colors.fg.disabled.light};
36
+ background-color: ${({ theme }) => theme.colors.bg.disabled.light};
37
+ border: 1px solid ${({ theme }) => theme.colors.bg.disabled.light};
38
+ }
39
+ `;
40
+ case ButtonStyle.SECONDARY:
41
+ return css`
42
+ color: ${({ theme }) => theme.colors.fg.neutral.subtle.light};
43
+ background-color: ${({ theme }) => theme.colors.bg.neutral.white.light};
44
+ border: 1px solid ${({ theme }) => theme.colors.border.neutral.subtle.light};
45
+
46
+ &:hover {
47
+ background-color: ${({ theme }) => theme.colors.bg.brand.default.light};
48
+ border: 2px solid ${({ theme }) => theme.colors.border.brand.subtle.light};
49
+ }
50
+
51
+ &:focus {
52
+ box-shadow: ${({ theme }) => theme.colors.shadow.buttonFocus};
53
+ }
54
+
55
+ &:active {
56
+ background-color: ${({ theme }) => theme.colors.bg.brand.default.pressed.light};
57
+ border: 2px solid ${({ theme }) => theme.colors.border.brand.subtle.light};
58
+ }
59
+
60
+ &:disabled {
61
+ color: ${({ theme }) => theme.colors.fg.disabled.light};
62
+ background-color: ${({ theme }) => theme.colors.bg.neutral.white.light};
63
+ border: 1px solid ${({ theme }) => theme.colors.bg.disabled.light};
64
+ }
65
+ `;
66
+ case ButtonStyle.TERTIARY:
67
+ return css`
68
+ color: ${({ theme }) => theme.colors.fg.neutral.subtle.light};
69
+ background-color: ${({ theme }) => theme.colors.bg.neutral.white.light};
70
+ border: none;
71
+
72
+ &:hover {
73
+ background-color: ${({ theme }) => theme.colors.bg.brand.default.light};
74
+ }
75
+
76
+ &:focus {
77
+ box-shadow: ${({ theme }) => theme.colors.shadow.buttonFocus};
78
+ }
79
+
80
+ &:active {
81
+ background-color: ${({ theme }) => theme.colors.bg.brand.default.pressed.light};
82
+ }
83
+
84
+ &:disabled {
85
+ color: ${({ theme }) => theme.colors.fg.disabled.light};
86
+ background-color: ${({ theme }) => theme.colors.bg.neutral.white.light};
87
+ }
88
+ `;
89
+ default:
90
+ return '';
91
+ }
92
+ }}
93
+
94
+ /* size specific styles */
95
+ ${({ size }) => {
96
+ switch (size) {
97
+ case ButtonSize.XS:
98
+ return css`
99
+ gap: ${({ theme }) => theme.spacing.xxs};
100
+ min-height: ${({ theme }) => theme.spacing.xl};
101
+ padding: ${({ theme }) => theme.spacing.xxs} ${({ theme }) => theme.spacing.xs};
102
+ font-size: ${({ theme }) => theme.font.size.body.xs};
103
+ font-weight: ${({ theme }) => theme.font.weight.medium};
104
+ line-height: ${({ theme }) => theme.font.lineHeight.body.xs};
105
+ letter-spacing: ${({ theme }) => theme.font.letterSpacing.body.md};
106
+ border-radius: ${({ theme }) => theme.borderRadius.xxs};
107
+ `;
108
+ case ButtonSize.SM:
109
+ return css`
110
+ gap: ${({ theme }) => theme.spacing.xxs};
111
+ min-height: ${({ theme }) => theme.spacing.xl};
112
+ padding: ${({ theme }) => theme.spacing.xxs} ${({ theme }) => theme.spacing.xs};
113
+ font-size: ${({ theme }) => theme.font.size.body.sm};
114
+ font-weight: ${({ theme }) => theme.font.weight.medium};
115
+ line-height: ${({ theme }) => theme.font.lineHeight.body.sm};
116
+ letter-spacing: ${({ theme }) => theme.font.letterSpacing.body.md};
117
+ border-radius: ${({ theme }) => theme.borderRadius.xxs};
118
+ `;
119
+ case ButtonSize.MD:
120
+ return css`
121
+ gap: ${({ theme }) => theme.spacing.xxs};
122
+ min-height: ${({ theme }) => theme.spacing.xxl};
123
+ padding: ${({ theme }) => theme.spacing.xs} ${({ theme }) => theme.spacing.sm};
124
+ font-size: ${({ theme }) => theme.font.size.body.sm};
125
+ font-weight: ${({ theme }) => theme.font.weight.medium};
126
+ line-height: ${({ theme }) => theme.font.lineHeight.body.sm};
127
+ letter-spacing: ${({ theme }) => theme.font.letterSpacing.body.md};
128
+ border-radius: ${({ theme }) => theme.borderRadius.xs};
129
+ `;
130
+ case ButtonSize.XL:
131
+ return css`
132
+ gap: ${({ theme }) => theme.spacing.xs};
133
+ min-height: ${({ theme }) => theme.spacing.xxxl};
134
+ padding: ${({ theme }) => theme.spacing.sm};
135
+ font-size: ${({ theme }) => theme.font.size.body.md};
136
+ font-weight: ${({ theme }) => theme.font.weight.medium};
137
+ line-height: ${({ theme }) => theme.font.lineHeight.body.md};
138
+ border-radius: ${({ theme }) => theme.borderRadius.xs};
139
+ `;
140
+ case ButtonSize.XXL:
141
+ return css`
142
+ gap: ${({ theme }) => theme.spacing.sm};
143
+ min-height: ${({ theme }) => theme.spacing.xxxxl};
144
+ padding: ${({ theme }) => theme.spacing.md} ${({ theme }) => theme.spacing.xl};
145
+ font-size: ${({ theme }) => theme.font.size.body.lg};
146
+ font-weight: ${({ theme }) => theme.font.weight.medium};
147
+ line-height: ${({ theme }) => theme.font.lineHeight.body.lg};
148
+ border-radius: ${({ theme }) => theme.borderRadius.sm};
149
+ `;
150
+ default:
151
+ return css`
152
+ border-radius: ${({ theme }) => theme.borderRadius.xxs};
153
+ `;
154
+ }
155
+ }}
156
+ `;
157
+
158
+ export const IconWrapperStyled = styled.div<Partial<Props>>`
159
+ display: flex;
160
+ align-items: center;
161
+ height: 100%;
162
+ `;
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import '@testing-library/jest-dom';
3
+ import { render, screen } from '@testing-library/react';
4
+
5
+ import { ButtonSize, ButtonStyle, ButtonType } from './button.types';
6
+ import Button from './button';
7
+ import StyledComponentsThemeProvider from '@/provider/styledComponents/theme/styledComponentsThemeProvider';
8
+
9
+ describe('Running Test for Button', () => {
10
+ test('Check Button Disabled', () => {
11
+ render(
12
+ <StyledComponentsThemeProvider>
13
+ <Button
14
+ buttonStyle={ButtonStyle.PRIMARY}
15
+ disabled={true}
16
+ size={ButtonSize.MD}
17
+ type={ButtonType.BUTTON}
18
+ >
19
+ Button
20
+ </Button>
21
+ </StyledComponentsThemeProvider>,
22
+ );
23
+ expect(screen.getByRole('button', { name: 'Button' })).toBeDisabled();
24
+ });
25
+ });