@osrd-project/ui-core 0.0.18

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 (47) hide show
  1. package/LICENSE +165 -0
  2. package/README.md +7 -0
  3. package/dist/components/inputs/Input.d.ts +23 -0
  4. package/dist/components/inputs/PasswordInput.d.ts +4 -0
  5. package/dist/components/inputs/TokenInput.d.ts +7 -0
  6. package/dist/components/inputs/checkbox.d.ts +6 -0
  7. package/dist/components/inputs/hooks/useKeyPress.d.ts +1 -0
  8. package/dist/index.d.ts +5 -0
  9. package/dist/index.esm.js +2 -0
  10. package/dist/index.esm.js.map +1 -0
  11. package/dist/stories/Input.stories.d.ts +20 -0
  12. package/dist/stories/PasswordInput.stories.d.ts +7 -0
  13. package/dist/stories/TokenInput.stories.d.ts +7 -0
  14. package/dist/theme.css +956 -0
  15. package/dist/theme.css.map +1 -0
  16. package/fonts/IBMPlexMono-Italic.ttf +0 -0
  17. package/fonts/IBMPlexMono-Regular.ttf +0 -0
  18. package/fonts/IBMPlexMono-SemiBold.ttf +0 -0
  19. package/fonts/IBMPlexMono-SemiBoldItalic.ttf +0 -0
  20. package/fonts/IBMPlexSans-Bold.ttf +0 -0
  21. package/fonts/IBMPlexSans-BoldItalic.ttf +0 -0
  22. package/fonts/IBMPlexSans-Italic.ttf +0 -0
  23. package/fonts/IBMPlexSans-Regular.ttf +0 -0
  24. package/fonts/IBMPlexSans-SemiBold.ttf +0 -0
  25. package/fonts/IBMPlexSans-SemiBoldItalic.ttf +0 -0
  26. package/fonts/IBMPlexSerif-Italic.ttf +0 -0
  27. package/fonts/IBMPlexSerif-Regular.ttf +0 -0
  28. package/fonts/IBMPlexSerif-SemiBold.ttf +0 -0
  29. package/fonts/IBMPlexSerif-SemiBoldItalic.ttf +0 -0
  30. package/package.json +49 -0
  31. package/postcss.config.cjs +12 -0
  32. package/rollup.config.js +35 -0
  33. package/src/components/inputs/Input.tsx +148 -0
  34. package/src/components/inputs/PasswordInput.tsx +23 -0
  35. package/src/components/inputs/TokenInput.tsx +61 -0
  36. package/src/components/inputs/checkbox.tsx +25 -0
  37. package/src/components/inputs/hooks/useKeyPress.tsx +19 -0
  38. package/src/index.ts +6 -0
  39. package/src/stories/Input.stories.tsx +160 -0
  40. package/src/stories/PasswordInput.stories.tsx +19 -0
  41. package/src/stories/TokenInput.stories.tsx +19 -0
  42. package/src/styles/inputs/input.css +339 -0
  43. package/src/styles/inputs/passwordInput.css +8 -0
  44. package/src/styles/inputs/tokenInput.css +77 -0
  45. package/src/styles/main.css +52 -0
  46. package/tailwind.config.js +102 -0
  47. package/tsconfig.json +9 -0
@@ -0,0 +1,339 @@
1
+ .feed-back {
2
+ border-radius: 8px;
3
+ width: max-content;
4
+ position: relative;
5
+ padding: 10px 0 16px 16px;
6
+
7
+ &.info {
8
+ @apply bg-info-5;
9
+ }
10
+
11
+ &.warning {
12
+ @apply bg-warning-5;
13
+ }
14
+
15
+ &.error {
16
+ @apply bg-error-5;
17
+ }
18
+
19
+ .custom-input {
20
+ display: flex;
21
+ flex-direction: column;
22
+ width: max-content;
23
+
24
+ .label-wrapper {
25
+ display: flex;
26
+ align-items: center;
27
+
28
+ &.has-hint {
29
+ margin-bottom: 0;
30
+ }
31
+
32
+ .required {
33
+ position: absolute;
34
+ left: -8px;
35
+ border-radius: 0.5px;
36
+ @apply text-info-30;
37
+ }
38
+
39
+ .label {
40
+ display: inline-block;
41
+ height: 24px;
42
+ line-height: 24px;
43
+ letter-spacing: 0;
44
+ text-align: left;
45
+ vertical-align: top;
46
+ @apply text-grey-80 font-sans font-semibold;
47
+
48
+ &.disabled {
49
+ @apply text-grey-30;
50
+ }
51
+ }
52
+ }
53
+
54
+ .hint {
55
+ height: 20px;
56
+ margin-bottom: 4px;
57
+ font-size: 14px;
58
+ line-height: 20px;
59
+ @apply text-grey-50;
60
+ }
61
+
62
+ .input-wrapper-and-status-icon {
63
+ display: flex;
64
+ align-items: center;
65
+ margin-right: 13px;
66
+
67
+ .input-wrapper {
68
+ display: flex;
69
+ align-items: center;
70
+ padding: 3px;
71
+ margin-left: -2px;
72
+ width: max-content;
73
+
74
+ &.focused {
75
+ box-shadow: 0 0 0 1px rgba(37, 106, 250, 1) inset;
76
+ }
77
+
78
+ .leading-content-wrapper {
79
+ height: 40px;
80
+ padding: 9px 16px 11px 16px;
81
+ border-radius: 4px 0 0 4px;
82
+ box-shadow: 0px 0px 0px 1px rgba(148, 145, 142, 1) inset;
83
+ margin-right: -1px;
84
+ display: flex;
85
+ align-items: center;
86
+ justify-content: center;
87
+
88
+ .leading-content {
89
+ line-height: 20px;
90
+ font-size: 14px;
91
+ text-align: center;
92
+ @apply text-grey-80;
93
+ }
94
+ }
95
+
96
+ .input {
97
+ height: 40px;
98
+ line-height: 24px;
99
+ text-align: left;
100
+ vertical-align: top;
101
+ letter-spacing: 0px;
102
+ padding: 8px 12px;
103
+ border-radius: 4px;
104
+ box-shadow:
105
+ 0px 0px 0px 1px rgba(148, 145, 142, 1) inset,
106
+ 0px 1px 3px rgba(0, 0, 0, 0.5) inset;
107
+ @apply bg-black-1 text-black-100;
108
+
109
+ &.with-leading-only {
110
+ border-radius: 0px 4px 4px 0px;
111
+ }
112
+
113
+ &.with-trailing-only {
114
+ border-radius: 4px 0 0 4px;
115
+ }
116
+
117
+ &.with-leading-and-trailing {
118
+ border-radius: 0;
119
+ }
120
+
121
+ &.with-leading-only,
122
+ &.with-trailing-only,
123
+ &.with-leading-and-trailing {
124
+ width: 96px;
125
+ }
126
+
127
+ &:focus {
128
+ outline: none;
129
+ }
130
+
131
+ &:read-only {
132
+ box-shadow:
133
+ 0px 0px 0px 1px rgba(211, 209, 207, 1) inset,
134
+ 0px 0px 0px 3px rgba(255, 255, 255, 1) inset;
135
+ @apply text-grey-50 bg-black-2;
136
+ }
137
+
138
+ &:disabled {
139
+ box-shadow: 0px 0px 0px 1px rgba(235, 235, 234, 1) inset;
140
+ @apply text-grey-30 bg-black-2;
141
+ }
142
+
143
+ &.success {
144
+ box-shadow:
145
+ 0px 0px 0px 1px rgba(11, 114, 60, 1) inset,
146
+ 0px 0px 0px 4px rgba(230, 247, 238, 1) inset;
147
+ background-color: rgba(255, 255, 255, 0.5);
148
+ }
149
+
150
+ &.info {
151
+ border: 1.5px solid rgba(112, 193, 229, 1);
152
+ box-shadow:
153
+ 0px 1px 3px rgba(0, 0, 0, 0.5) inset,
154
+ 0px 0px 0px 0.5px rgba(0, 0, 0, 1) inset;
155
+ background-color: rgba(255, 255, 255, 1);
156
+ }
157
+
158
+ &.warning {
159
+ border: 1.5px solid rgba(234, 167, 43, 1);
160
+ box-shadow:
161
+ 0px 1px 3px rgba(0, 0, 0, 0.5) inset,
162
+ 0px 0px 0px 0.5px rgba(0, 0, 0, 1) inset;
163
+ background-color: rgba(255, 255, 255, 1);
164
+ }
165
+
166
+ &.error {
167
+ border: 1.5px solid rgba(255, 104, 104, 1);
168
+ box-shadow:
169
+ 0px 1px 3px rgba(0, 0, 0, 0.5) inset,
170
+ 0px 0px 0px 0.5px rgba(0, 0, 0, 1) inset;
171
+ background-color: rgba(255, 255, 255, 1);
172
+ }
173
+
174
+ &::-webkit-inner-spin-button,
175
+ &::-webkit-outer-spin-button {
176
+ -webkit-appearance: none;
177
+ margin: 0;
178
+ }
179
+
180
+ &[type='number'] {
181
+ appearance: none;
182
+ -moz-appearance: textfield;
183
+ }
184
+ }
185
+
186
+ .trailing-content-wrapper {
187
+ height: 40px;
188
+ padding: 9px 16px 11px;
189
+ border-radius: 0 4px 4px 0;
190
+ box-shadow: 0px 0px 0px 1px rgba(148, 145, 142, 1) inset;
191
+ margin-left: -1px;
192
+ display: flex;
193
+ align-items: center;
194
+ justify-content: center;
195
+
196
+ .trailing-content {
197
+ line-height: 20px;
198
+ font-size: 14px;
199
+ text-align: center;
200
+ @apply text-grey-80;
201
+ }
202
+ }
203
+ }
204
+ .status-icon {
205
+ margin-left: 9px;
206
+
207
+ &.loading {
208
+ animation: spin 3s linear infinite;
209
+ @apply text-info-30;
210
+ }
211
+
212
+ &.info {
213
+ @apply text-info-30;
214
+ }
215
+
216
+ &.success {
217
+ @apply text-success-30;
218
+ }
219
+
220
+ &.warning {
221
+ @apply text-warning-30;
222
+ }
223
+
224
+ &.error {
225
+ @apply text-error-60;
226
+ }
227
+
228
+ &.small {
229
+ margin: 5px 0 5px 8px;
230
+ }
231
+ }
232
+ }
233
+
234
+ .status-message {
235
+ letter-spacing: 0px;
236
+ text-align: left;
237
+ line-height: 24px;
238
+ margin-top: 11px;
239
+ margin-bottom: 2px;
240
+ @apply font-semibold;
241
+
242
+ &.info {
243
+ @apply text-info-60;
244
+ }
245
+
246
+ &.success {
247
+ @apply text-success-60;
248
+ }
249
+
250
+ &.warning {
251
+ @apply text-warning-60;
252
+ }
253
+
254
+ &.error {
255
+ @apply text-error-60;
256
+ }
257
+ }
258
+ }
259
+
260
+ &.small {
261
+ .custom-input {
262
+ .label-wrapper {
263
+ .label {
264
+ height: 20px;
265
+ font-size: 14px;
266
+ line-height: 20px;
267
+ }
268
+ }
269
+
270
+ .hint {
271
+ margin-bottom: 3px;
272
+ }
273
+
274
+ .input-wrapper-and-status-icon {
275
+ .input-wrapper {
276
+ height: 34px;
277
+
278
+ .leading-content-wrapper {
279
+ height: 28px;
280
+ border-radius: 3px 0px 0px 3px;
281
+ .leading-content {
282
+ font-size: 12px;
283
+ line-height: 8px; /* à check avec thibaut*/
284
+ }
285
+ }
286
+
287
+ .input {
288
+ height: 28px;
289
+ line-height: 20px;
290
+ font-size: 14px;
291
+ padding: 3px 8px 3px 7px;
292
+ border-radius: 3px;
293
+
294
+ &.with-leading-only {
295
+ border-radius: 0px 4px 4px 0px;
296
+ }
297
+
298
+ &.with-trailing-only {
299
+ border-radius: 4px 0 0 4px;
300
+ }
301
+
302
+ &.with-leading-and-trailing {
303
+ border-radius: 0;
304
+ }
305
+
306
+ &.with-leading-only,
307
+ &.with-trailing-only,
308
+ &.with-leading-and-trailing {
309
+ width: 96px;
310
+ }
311
+ }
312
+
313
+ .trailing-content-wrapper {
314
+ height: 28px;
315
+ border-radius: 0 3px 3px 0;
316
+
317
+ .trailing-content {
318
+ font-size: 12px;
319
+ line-height: 8px;
320
+ }
321
+ }
322
+ }
323
+
324
+ .status-icon {
325
+ margin: 5px 0 5px 8px;
326
+ }
327
+ }
328
+ }
329
+ }
330
+ }
331
+
332
+ @keyframes spin {
333
+ from {
334
+ transform: rotate(0deg);
335
+ }
336
+ to {
337
+ transform: rotate(360deg);
338
+ }
339
+ }
@@ -0,0 +1,8 @@
1
+ .password-input {
2
+ .input {
3
+ width: 235px !important;
4
+ }
5
+ .trailing-content {
6
+ @apply text-primary-60 !important;
7
+ }
8
+ }
@@ -0,0 +1,77 @@
1
+ .token-input-wrapper {
2
+ .input-label {
3
+ font-size: 16px;
4
+ letter-spacing: 0px;
5
+ text-align: left;
6
+ line-height: 24px;
7
+ @apply text-grey-80 font-sans font-semibold;
8
+ }
9
+
10
+ .tokens-wrapper {
11
+ display: flex;
12
+ flex-wrap: wrap;
13
+ min-height: 40px;
14
+ padding: 4px;
15
+ width: 344px;
16
+ border-radius: 4px;
17
+ box-shadow:
18
+ 0px 1px 3px rgba(0, 0, 0, 0.5) inset,
19
+ 0px 0px 0px 1px rgba(148, 145, 142, 1) inset;
20
+ @apply bg-black-1;
21
+
22
+ .token-item-wrapper {
23
+ display: flex;
24
+ margin: 4px;
25
+ align-items: center;
26
+ justify-content: center;
27
+ border-radius: 3px;
28
+ box-shadow:
29
+ 0px 0px 0px 2px rgba(255, 255, 255, 0.5) inset,
30
+ 0px 0px 0px 1px rgba(196, 218, 245, 1) inset;
31
+ background-color: rgba(227, 237, 252, 1);
32
+
33
+ .token-label {
34
+ margin: 2px 6px 2px 8px;
35
+ font-size: 14px;
36
+ letter-spacing: 0px;
37
+ text-align: left;
38
+ line-height: 20px;
39
+ @apply text-black-100;
40
+ }
41
+
42
+ .token-close-btn {
43
+ margin: 4px 4px 4px 0;
44
+ @apply text-black-25;
45
+ }
46
+
47
+ &:hover {
48
+ cursor: pointer;
49
+ box-shadow:
50
+ 0px 0px 0px 2px rgba(255, 255, 255, 0.5) inset,
51
+ 0px 0px 0px 1px rgb(152, 192, 245) inset;
52
+ background-color: rgba(255, 255, 255, 0.75);
53
+
54
+ .token-close-btn {
55
+ @apply text-black-75;
56
+ }
57
+ }
58
+
59
+ &:active {
60
+ box-shadow: 0px 0px 0px 1px rgb(32, 30, 222) inset;
61
+ @apply text-white-50;
62
+
63
+ .token-close-btn {
64
+ @apply text-black-100;
65
+ }
66
+ }
67
+ }
68
+
69
+ .token-input {
70
+ outline: none;
71
+ margin: 4px;
72
+ min-width: 100px;
73
+ flex: 1;
74
+ @apply bg-transparent;
75
+ }
76
+ }
77
+ }
@@ -0,0 +1,52 @@
1
+ @import 'tailwindcss/base';
2
+ @import 'tailwindcss/components';
3
+ @import 'tailwindcss/utilities';
4
+ @import './inputs/input.css';
5
+ @import './inputs/passwordInput.css';
6
+ @import './inputs/tokenInput.css';
7
+
8
+ /* REGULAR */
9
+
10
+ @font-face {
11
+ font-family: 'IBM Plex Sans';
12
+ src: inline('./fonts/IBMPlexSans-Regular.ttf') format('truetype');
13
+ font-weight: 400;
14
+ }
15
+
16
+ @font-face {
17
+ font-family: 'IBM Plex Sans';
18
+ src: inline('./fonts/IBMPlexSans-SemiBold.ttf') format('truetype');
19
+ font-weight: 600;
20
+ }
21
+
22
+ @font-face {
23
+ font-family: 'IBM Plex Sans';
24
+ src: inline('./fonts/IBMPlexSans-Bold.ttf') format('truetype');
25
+ font-weight: 900;
26
+ }
27
+
28
+ /* SERIF */
29
+
30
+ @font-face {
31
+ font-family: 'IBM Plex Serif', serif;
32
+ src: inline('./fonts/IBMPlexSerif-Regular.ttf') format('truetype');
33
+ font-weight: 400;
34
+ }
35
+ @font-face {
36
+ font-family: 'IBM Plex Serif', serif;
37
+ src: inline('./fonts/IBMPlexSerif-SemiBold.ttf') format('truetype');
38
+ font-weight: 600;
39
+ }
40
+
41
+ /* MONOSPACE */
42
+
43
+ @font-face {
44
+ font-family: 'IBM Plex Mono', monospace;
45
+ src: inline('./fonts/IBMPlexMono-Regular.ttf') format('truetype');
46
+ font-weight: 400;
47
+ }
48
+ @font-face {
49
+ font-family: 'IBM Plex Mono', monospace;
50
+ src: inline('fonts/IBMPlexMono-SemiBold.ttf') format('truetype');
51
+ font-weight: 600;
52
+ }
@@ -0,0 +1,102 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ module.exports = {
3
+ content: ['./src/**/*.{js,jsx,ts,tsx}'],
4
+
5
+ theme: {
6
+ extend: {
7
+ colors: {
8
+ transparent: 'transparent',
9
+ black: {
10
+ 1: 'rgba(0, 0, 0, 0.01)',
11
+ 2: 'rgba(0, 0, 0, 0.02)',
12
+ 25: 'rgba(0, 0, 0, 0.25)',
13
+ 75: 'rgba(0, 0, 0, 0.75)',
14
+ 50: '#94918E',
15
+ 100: '#000000',
16
+ },
17
+ white: {
18
+ 50: 'rgba(255, 255, 255, 0.5)',
19
+ 75: 'rgba(255, 255, 255, 0.75)',
20
+ },
21
+ ambientA: {
22
+ 5: '#F6F8F9',
23
+ 10: '#EFF3F5',
24
+ 15: '#E9EFF2',
25
+ },
26
+ ambientB: {
27
+ 5: '#FAF9F5',
28
+ 10: '#F7F6EE',
29
+ 15: '#F2F0E4',
30
+ },
31
+ ambientC: {
32
+ 5: '#F6F9F6',
33
+ 10: '#F0F4F1',
34
+ 15: '#EAF0EB',
35
+ },
36
+ ambientD: {
37
+ 5: '#F8F7FD',
38
+ 10: '#F4F3FC',
39
+ 15: '#EFEDF7',
40
+ },
41
+ grey: {
42
+ 5: '#F5F5F5',
43
+ 10: '#EBEBEA',
44
+ 20: '#D3D1CF',
45
+ 30: '#B6B2AF',
46
+ 40: '#94918E',
47
+ 50: '#797671',
48
+ 60: '#5C5955',
49
+ 70: '#494641',
50
+ 80: '#312E2B',
51
+ 90: '#1F1B17',
52
+ },
53
+ primary: {
54
+ 5: '#E3EDFC',
55
+ 10: '#C4DAF5',
56
+ 20: '#98C0F5',
57
+ 30: '#72A8F7',
58
+ 40: '#3C8AFF',
59
+ 50: '#256AFA',
60
+ 60: '#1844EF',
61
+ 70: '#201EDE',
62
+ 80: '#1F0F96',
63
+ 90: '#180F47',
64
+ },
65
+ info: {
66
+ 5: '#E6F7FF',
67
+ 30: '#70C1E5',
68
+ 60: '#216482',
69
+ 80: '#053348',
70
+ },
71
+ success: {
72
+ 5: '#E6F7EE',
73
+ 30: '#3CCA80',
74
+ 60: '#0B723C',
75
+ 80: '#003F1E',
76
+ },
77
+ warning: {
78
+ 5: '#FDF5E1',
79
+ 30: '#EAA72B',
80
+ 60: '#7D521E',
81
+ 80: '#432807',
82
+ },
83
+ error: {
84
+ 5: '#FFEEED',
85
+ 30: '#FF6868',
86
+ 60: '#D91C1C',
87
+ 80: '#6B0000',
88
+ },
89
+ highlight: {
90
+ 30: '#FFF700',
91
+ 50: '#E8D900',
92
+ },
93
+ },
94
+ },
95
+ fontFamily: {
96
+ sans: ['IBM Plex sans', 'sans-serif'],
97
+ serif: ['IBM Plex serif', 'serif'],
98
+ mono: ['IBM Plex mono', 'monospace'],
99
+ },
100
+ },
101
+ plugins: [],
102
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../tsconfig.base.json",
3
+ "include": ["./src/**/*"],
4
+ "compilerOptions": {
5
+ "rootDir": "./src",
6
+ "outDir": "./dist",
7
+ "declarationDir": "./dist"
8
+ }
9
+ }