@creativecodeco/ui 0.0.5 → 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.
- package/README.md +37 -4
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/theme/css/avatar.css +37 -0
- package/lib/theme/css/main.css +1 -0
- package/lib/theme/main.css +217 -0
- package/lib/types/index.d.ts +3 -2
- package/lib/types/index.js +3 -1
- package/lib/types/ui/base/constants.types.d.ts +1 -0
- package/lib/types/ui/base/constants.types.js +1 -0
- package/lib/types/ui/base/index.d.ts +1 -0
- package/lib/types/ui/base/index.js +1 -0
- package/lib/types/ui/components/avatar.types.d.ts +9 -0
- package/lib/types/ui/components/avatar.types.js +1 -0
- package/lib/types/ui/components/index.d.ts +2 -0
- package/lib/types/ui/components/index.js +1 -0
- package/lib/types/ui/forms/text-box.types.d.ts +2 -1
- package/lib/ui/components/avatar/avatar.component.d.ts +3 -0
- package/lib/ui/components/avatar/avatar.component.js +18 -0
- package/lib/ui/components/avatar/index.d.ts +2 -0
- package/lib/ui/components/avatar/index.js +2 -0
- package/lib/ui/components/index.d.ts +1 -0
- package/lib/ui/components/index.js +1 -0
- package/lib/ui/forms/drop-down/drop-down.component.js +2 -0
- package/lib/ui/forms/index.d.ts +2 -3
- package/lib/ui/forms/index.js +2 -3
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/lib/utils/string.utils.d.ts +25 -0
- package/lib/utils/string.utils.js +38 -0
- package/package.json +20 -17
package/README.md
CHANGED
|
@@ -25,11 +25,11 @@ yarn add @creativecodeco/ui
|
|
|
25
25
|
### Dependencies
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
npm install --save-dev tailwindcss postcss postcss-import autoprefixer usehooks-ts
|
|
28
|
+
npm install --save-dev tailwindcss postcss postcss-import autoprefixer usehooks-ts cssnano
|
|
29
29
|
|
|
30
30
|
or
|
|
31
31
|
|
|
32
|
-
yarn add -D tailwindcss postcss postcss-import autoprefixer usehooks-ts
|
|
32
|
+
yarn add -D tailwindcss postcss postcss-import autoprefixer usehooks-ts cssnano
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
### Setting Tailwind
|
|
@@ -46,13 +46,45 @@ const themeConfig = {
|
|
|
46
46
|
...creativeCodeTheme.content,
|
|
47
47
|
'./src/**/*.{js,jsx,ts,tsx}',
|
|
48
48
|
'./app/**/*.{js,jsx,ts,tsx}',
|
|
49
|
-
'./node_modules/@creativecodeco/ui/lib/**/*.{js,jsx,ts,tsx}',
|
|
50
49
|
],
|
|
51
50
|
};
|
|
52
51
|
|
|
53
52
|
export default themeConfig;
|
|
54
53
|
```
|
|
55
54
|
|
|
55
|
+
#### Custom theme
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
/** @type {import('tailwindcss').Config} */
|
|
59
|
+
import { creativeCodeTheme } from '@creativecodeco/ui';
|
|
60
|
+
|
|
61
|
+
const themeConfig = {
|
|
62
|
+
...creativeCodeTheme,
|
|
63
|
+
content: [
|
|
64
|
+
...creativeCodeTheme.content,
|
|
65
|
+
'./src/**/*.{js,jsx,ts,tsx}',
|
|
66
|
+
'./app/**/*.{js,jsx,ts,tsx}',
|
|
67
|
+
],
|
|
68
|
+
daisyui: {
|
|
69
|
+
...creativeCodeTheme.daisyui,
|
|
70
|
+
themes: [
|
|
71
|
+
{
|
|
72
|
+
customTheme: {
|
|
73
|
+
...require('daisyui/src/theming/themes')['light'],
|
|
74
|
+
primary: '#08448c',
|
|
75
|
+
secondary: '#427AA1',
|
|
76
|
+
neutral: '#EBF2FA',
|
|
77
|
+
accent: '#679436',
|
|
78
|
+
other: '#A5BE00',
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default themeConfig;
|
|
86
|
+
```
|
|
87
|
+
|
|
56
88
|
### Setting Postcss
|
|
57
89
|
|
|
58
90
|
Create file `postcss.config.js` and add
|
|
@@ -64,6 +96,7 @@ module.exports = {
|
|
|
64
96
|
'tailwindcss/nesting': {},
|
|
65
97
|
tailwindcss: {},
|
|
66
98
|
autoprefixer: {},
|
|
99
|
+
...(process.env.NODE_ENV === 'production' ? { cssnano: {} } : {}),
|
|
67
100
|
},
|
|
68
101
|
};
|
|
69
102
|
```
|
|
@@ -75,7 +108,7 @@ Add on layout `layout.tsx`
|
|
|
75
108
|
```tsx
|
|
76
109
|
import { CreativeCodeUIProvider } from '@creativecodeco/ui';
|
|
77
110
|
|
|
78
|
-
import '@creativecodeco/ui/lib/theme/main.css';
|
|
111
|
+
import '@creativecodeco/ui/lib/theme/css/main.css';
|
|
79
112
|
|
|
80
113
|
export default function RootLayout({ children }) {
|
|
81
114
|
return (
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.avatar-size {
|
|
2
|
+
&-xs {
|
|
3
|
+
@apply w-8;
|
|
4
|
+
|
|
5
|
+
> span {
|
|
6
|
+
@apply text-xs;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
&-sm {
|
|
11
|
+
@apply w-12;
|
|
12
|
+
|
|
13
|
+
> span {
|
|
14
|
+
@apply text-sm;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&-md {
|
|
19
|
+
@apply w-16;
|
|
20
|
+
|
|
21
|
+
> span {
|
|
22
|
+
@apply text-xl;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&-lg {
|
|
27
|
+
@apply w-24;
|
|
28
|
+
|
|
29
|
+
> span {
|
|
30
|
+
@apply text-3xl;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.avatar-ring {
|
|
36
|
+
@apply ring ring-primary ring-offset-base-100 ring-offset-2;
|
|
37
|
+
}
|
package/lib/theme/css/main.css
CHANGED
package/lib/theme/main.css
CHANGED
|
@@ -622,6 +622,26 @@ html {
|
|
|
622
622
|
max-width: 1536px;
|
|
623
623
|
}
|
|
624
624
|
}
|
|
625
|
+
.avatar {
|
|
626
|
+
position: relative;
|
|
627
|
+
display: inline-flex;
|
|
628
|
+
}
|
|
629
|
+
.avatar > div {
|
|
630
|
+
display: block;
|
|
631
|
+
aspect-ratio: 1 / 1;
|
|
632
|
+
overflow: hidden;
|
|
633
|
+
}
|
|
634
|
+
.avatar img {
|
|
635
|
+
height: 100%;
|
|
636
|
+
width: 100%;
|
|
637
|
+
-o-object-fit: cover;
|
|
638
|
+
object-fit: cover;
|
|
639
|
+
}
|
|
640
|
+
.avatar.placeholder > div {
|
|
641
|
+
display: flex;
|
|
642
|
+
align-items: center;
|
|
643
|
+
justify-content: center;
|
|
644
|
+
}
|
|
625
645
|
@media (hover:hover) {
|
|
626
646
|
|
|
627
647
|
.label a:hover {
|
|
@@ -774,11 +794,61 @@ html {
|
|
|
774
794
|
--tw-bg-opacity: 1;
|
|
775
795
|
background-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-bg-opacity)));
|
|
776
796
|
}
|
|
797
|
+
.join {
|
|
798
|
+
display: inline-flex;
|
|
799
|
+
align-items: stretch;
|
|
800
|
+
border-radius: var(--rounded-btn, 0.5rem);
|
|
801
|
+
}
|
|
802
|
+
.join :where(.join-item) {
|
|
803
|
+
border-start-end-radius: 0;
|
|
804
|
+
border-end-end-radius: 0;
|
|
805
|
+
border-end-start-radius: 0;
|
|
806
|
+
border-start-start-radius: 0;
|
|
807
|
+
}
|
|
808
|
+
.join .join-item:not(:first-child):not(:last-child),
|
|
809
|
+
.join *:not(:first-child):not(:last-child) .join-item {
|
|
810
|
+
border-start-end-radius: 0;
|
|
811
|
+
border-end-end-radius: 0;
|
|
812
|
+
border-end-start-radius: 0;
|
|
813
|
+
border-start-start-radius: 0;
|
|
814
|
+
}
|
|
815
|
+
.join .join-item:first-child:not(:last-child),
|
|
816
|
+
.join *:first-child:not(:last-child) .join-item {
|
|
817
|
+
border-start-end-radius: 0;
|
|
818
|
+
border-end-end-radius: 0;
|
|
819
|
+
}
|
|
777
820
|
.join .dropdown .join-item:first-child:not(:last-child),
|
|
778
821
|
.join *:first-child:not(:last-child) .dropdown .join-item {
|
|
779
822
|
border-start-end-radius: inherit;
|
|
780
823
|
border-end-end-radius: inherit;
|
|
781
824
|
}
|
|
825
|
+
.join :where(.join-item:first-child:not(:last-child)),
|
|
826
|
+
.join :where(*:first-child:not(:last-child) .join-item) {
|
|
827
|
+
border-end-start-radius: inherit;
|
|
828
|
+
border-start-start-radius: inherit;
|
|
829
|
+
}
|
|
830
|
+
.join .join-item:last-child:not(:first-child),
|
|
831
|
+
.join *:last-child:not(:first-child) .join-item {
|
|
832
|
+
border-end-start-radius: 0;
|
|
833
|
+
border-start-start-radius: 0;
|
|
834
|
+
}
|
|
835
|
+
.join :where(.join-item:last-child:not(:first-child)),
|
|
836
|
+
.join :where(*:last-child:not(:first-child) .join-item) {
|
|
837
|
+
border-start-end-radius: inherit;
|
|
838
|
+
border-end-end-radius: inherit;
|
|
839
|
+
}
|
|
840
|
+
@supports not selector(:has(*)) {
|
|
841
|
+
|
|
842
|
+
:where(.join *) {
|
|
843
|
+
border-radius: inherit;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
@supports selector(:has(*)) {
|
|
847
|
+
|
|
848
|
+
:where(.join *:has(.join-item)) {
|
|
849
|
+
border-radius: inherit;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
782
852
|
.menu {
|
|
783
853
|
display: flex;
|
|
784
854
|
flex-direction: column;
|
|
@@ -858,6 +928,13 @@ html {
|
|
|
858
928
|
.select[multiple] {
|
|
859
929
|
height: auto;
|
|
860
930
|
}
|
|
931
|
+
.avatar-group :where(.avatar) {
|
|
932
|
+
overflow: hidden;
|
|
933
|
+
border-radius: 9999px;
|
|
934
|
+
border-width: 4px;
|
|
935
|
+
--tw-border-opacity: 1;
|
|
936
|
+
border-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-border-opacity)));
|
|
937
|
+
}
|
|
861
938
|
.btm-nav > *.disabled,
|
|
862
939
|
.btm-nav > *[disabled] {
|
|
863
940
|
pointer-events: none;
|
|
@@ -964,6 +1041,11 @@ html {
|
|
|
964
1041
|
.input::-webkit-date-and-time-value {
|
|
965
1042
|
text-align: inherit;
|
|
966
1043
|
}
|
|
1044
|
+
.join > :where(*:not(:first-child)) {
|
|
1045
|
+
margin-top: 0px;
|
|
1046
|
+
margin-bottom: 0px;
|
|
1047
|
+
margin-inline-start: -1px;
|
|
1048
|
+
}
|
|
967
1049
|
:where(.menu li:empty) {
|
|
968
1050
|
--tw-bg-opacity: 1;
|
|
969
1051
|
background-color: var(--fallback-bc,oklch(var(--bc)/var(--tw-bg-opacity)));
|
|
@@ -1189,6 +1271,82 @@ html {
|
|
|
1189
1271
|
opacity: 1;
|
|
1190
1272
|
}
|
|
1191
1273
|
}
|
|
1274
|
+
.join.join-vertical {
|
|
1275
|
+
flex-direction: column;
|
|
1276
|
+
}
|
|
1277
|
+
.join.join-vertical .join-item:first-child:not(:last-child),
|
|
1278
|
+
.join.join-vertical *:first-child:not(:last-child) .join-item {
|
|
1279
|
+
border-end-start-radius: 0;
|
|
1280
|
+
border-end-end-radius: 0;
|
|
1281
|
+
border-start-start-radius: inherit;
|
|
1282
|
+
border-start-end-radius: inherit;
|
|
1283
|
+
}
|
|
1284
|
+
.join.join-vertical .join-item:last-child:not(:first-child),
|
|
1285
|
+
.join.join-vertical *:last-child:not(:first-child) .join-item {
|
|
1286
|
+
border-start-start-radius: 0;
|
|
1287
|
+
border-start-end-radius: 0;
|
|
1288
|
+
border-end-start-radius: inherit;
|
|
1289
|
+
border-end-end-radius: inherit;
|
|
1290
|
+
}
|
|
1291
|
+
.join.join-horizontal {
|
|
1292
|
+
flex-direction: row;
|
|
1293
|
+
}
|
|
1294
|
+
.join.join-horizontal .join-item:first-child:not(:last-child),
|
|
1295
|
+
.join.join-horizontal *:first-child:not(:last-child) .join-item {
|
|
1296
|
+
border-end-end-radius: 0;
|
|
1297
|
+
border-start-end-radius: 0;
|
|
1298
|
+
border-end-start-radius: inherit;
|
|
1299
|
+
border-start-start-radius: inherit;
|
|
1300
|
+
}
|
|
1301
|
+
.join.join-horizontal .join-item:last-child:not(:first-child),
|
|
1302
|
+
.join.join-horizontal *:last-child:not(:first-child) .join-item {
|
|
1303
|
+
border-end-start-radius: 0;
|
|
1304
|
+
border-start-start-radius: 0;
|
|
1305
|
+
border-end-end-radius: inherit;
|
|
1306
|
+
border-start-end-radius: inherit;
|
|
1307
|
+
}
|
|
1308
|
+
.avatar.online:before {
|
|
1309
|
+
content: "";
|
|
1310
|
+
position: absolute;
|
|
1311
|
+
z-index: 10;
|
|
1312
|
+
display: block;
|
|
1313
|
+
border-radius: 9999px;
|
|
1314
|
+
--tw-bg-opacity: 1;
|
|
1315
|
+
background-color: var(--fallback-su,oklch(var(--su)/var(--tw-bg-opacity)));
|
|
1316
|
+
outline-style: solid;
|
|
1317
|
+
outline-width: 2px;
|
|
1318
|
+
outline-color: var(--fallback-b1,oklch(var(--b1)/1));
|
|
1319
|
+
width: 15%;
|
|
1320
|
+
height: 15%;
|
|
1321
|
+
top: 7%;
|
|
1322
|
+
right: 7%;
|
|
1323
|
+
}
|
|
1324
|
+
.avatar.offline:before {
|
|
1325
|
+
content: "";
|
|
1326
|
+
position: absolute;
|
|
1327
|
+
z-index: 10;
|
|
1328
|
+
display: block;
|
|
1329
|
+
border-radius: 9999px;
|
|
1330
|
+
--tw-bg-opacity: 1;
|
|
1331
|
+
background-color: var(--fallback-b3,oklch(var(--b3)/var(--tw-bg-opacity)));
|
|
1332
|
+
outline-style: solid;
|
|
1333
|
+
outline-width: 2px;
|
|
1334
|
+
outline-color: var(--fallback-b1,oklch(var(--b1)/1));
|
|
1335
|
+
width: 15%;
|
|
1336
|
+
height: 15%;
|
|
1337
|
+
top: 7%;
|
|
1338
|
+
right: 7%;
|
|
1339
|
+
}
|
|
1340
|
+
.join.join-vertical > :where(*:not(:first-child)) {
|
|
1341
|
+
margin-left: 0px;
|
|
1342
|
+
margin-right: 0px;
|
|
1343
|
+
margin-top: -1px;
|
|
1344
|
+
}
|
|
1345
|
+
.join.join-horizontal > :where(*:not(:first-child)) {
|
|
1346
|
+
margin-top: 0px;
|
|
1347
|
+
margin-bottom: 0px;
|
|
1348
|
+
margin-inline-start: -1px;
|
|
1349
|
+
}
|
|
1192
1350
|
.relative {
|
|
1193
1351
|
position: relative;
|
|
1194
1352
|
}
|
|
@@ -1207,17 +1365,76 @@ html {
|
|
|
1207
1365
|
.cursor-pointer {
|
|
1208
1366
|
cursor: pointer;
|
|
1209
1367
|
}
|
|
1368
|
+
.\!rounded {
|
|
1369
|
+
border-radius: 0.25rem !important;
|
|
1370
|
+
}
|
|
1371
|
+
.rounded {
|
|
1372
|
+
border-radius: 0.25rem;
|
|
1373
|
+
}
|
|
1374
|
+
.rounded-full {
|
|
1375
|
+
border-radius: 9999px;
|
|
1376
|
+
}
|
|
1210
1377
|
.bg-base-100 {
|
|
1211
1378
|
--tw-bg-opacity: 1;
|
|
1212
1379
|
background-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-bg-opacity)));
|
|
1213
1380
|
}
|
|
1381
|
+
.bg-neutral {
|
|
1382
|
+
--tw-bg-opacity: 1;
|
|
1383
|
+
background-color: var(--fallback-n,oklch(var(--n)/var(--tw-bg-opacity)));
|
|
1384
|
+
}
|
|
1385
|
+
.text-neutral-content {
|
|
1386
|
+
--tw-text-opacity: 1;
|
|
1387
|
+
color: var(--fallback-nc,oklch(var(--nc)/var(--tw-text-opacity)));
|
|
1388
|
+
}
|
|
1214
1389
|
.text-red-500 {
|
|
1215
1390
|
--tw-text-opacity: 1;
|
|
1216
1391
|
color: rgb(239 68 68 / var(--tw-text-opacity));
|
|
1217
1392
|
}
|
|
1393
|
+
.ring {
|
|
1394
|
+
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
|
1395
|
+
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color);
|
|
1396
|
+
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
|
|
1397
|
+
}
|
|
1218
1398
|
.filter {
|
|
1219
1399
|
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
1220
1400
|
}
|
|
1401
|
+
.avatar-size-xs {
|
|
1402
|
+
width: 2rem;
|
|
1403
|
+
}
|
|
1404
|
+
.avatar-size-xs > span {
|
|
1405
|
+
font-size: 0.75rem;
|
|
1406
|
+
line-height: 1rem;
|
|
1407
|
+
}
|
|
1408
|
+
.avatar-size-sm {
|
|
1409
|
+
width: 3rem;
|
|
1410
|
+
}
|
|
1411
|
+
.avatar-size-sm > span {
|
|
1412
|
+
font-size: 0.875rem;
|
|
1413
|
+
line-height: 1.25rem;
|
|
1414
|
+
}
|
|
1415
|
+
.avatar-size-md {
|
|
1416
|
+
width: 4rem;
|
|
1417
|
+
}
|
|
1418
|
+
.avatar-size-md > span {
|
|
1419
|
+
font-size: 1.25rem;
|
|
1420
|
+
line-height: 1.75rem;
|
|
1421
|
+
}
|
|
1422
|
+
.avatar-size-lg {
|
|
1423
|
+
width: 6rem;
|
|
1424
|
+
}
|
|
1425
|
+
.avatar-size-lg > span {
|
|
1426
|
+
font-size: 1.875rem;
|
|
1427
|
+
line-height: 2.25rem;
|
|
1428
|
+
}
|
|
1429
|
+
.avatar-ring {
|
|
1430
|
+
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
|
1431
|
+
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color);
|
|
1432
|
+
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
|
|
1433
|
+
--tw-ring-opacity: 1;
|
|
1434
|
+
--tw-ring-color: var(--fallback-p,oklch(var(--p)/var(--tw-ring-opacity)));
|
|
1435
|
+
--tw-ring-offset-width: 2px;
|
|
1436
|
+
--tw-ring-offset-color: var(--fallback-b1,oklch(var(--b1)/1));
|
|
1437
|
+
}
|
|
1221
1438
|
.text-box-size-xs {
|
|
1222
1439
|
height: 1.5rem;
|
|
1223
1440
|
padding-left: 0.5rem;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
export * from './ui/base';
|
|
2
|
+
export * from './ui/components';
|
|
3
|
+
export * from './ui/forms';
|
package/lib/types/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type SizeType = 'xs' | 'sm' | 'md' | 'lg';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './constants.types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { IconType } from 'react-icons';
|
|
3
|
+
import { SizeType } from '../../../types';
|
|
3
4
|
export interface TextBoxType extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'> {
|
|
4
5
|
name: string;
|
|
5
6
|
label?: string;
|
|
6
7
|
isError?: boolean;
|
|
7
8
|
error?: string;
|
|
8
9
|
disabled?: boolean;
|
|
9
|
-
size?:
|
|
10
|
+
size?: SizeType;
|
|
10
11
|
leftIcon?: IconType;
|
|
11
12
|
rightIcon?: IconType;
|
|
12
13
|
rightButton?: boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import cls from 'classnames';
|
|
4
|
+
import { getInitials } from '../../../utils';
|
|
5
|
+
const Avatar = ({ isOnline = false, ring = false, rounded = false, size = 'md', src, withStatus = false }) => {
|
|
6
|
+
const isUri = useMemo(() => URL.canParse(src), [src]);
|
|
7
|
+
const letters = useMemo(() => getInitials(src), [src, isUri]);
|
|
8
|
+
return (_jsx("div", { "data-testid": 'avatar', className: cls('avatar', {
|
|
9
|
+
online: withStatus && isOnline,
|
|
10
|
+
offline: withStatus && !isOnline,
|
|
11
|
+
placeholder: !isUri
|
|
12
|
+
}), children: _jsxs("div", { "data-testid": 'avatar-content', className: cls(`bg-neutral text-neutral-content avatar-size-${size}`, {
|
|
13
|
+
'rounded-full': rounded,
|
|
14
|
+
rounded: !rounded,
|
|
15
|
+
'avatar-ring': ring
|
|
16
|
+
}), children: [!isUri && _jsx("span", { children: letters }), isUri && _jsx("img", { src: src, alt: 'Avatar' })] }) }));
|
|
17
|
+
};
|
|
18
|
+
export default Avatar;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './avatar';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './avatar';
|
|
@@ -21,9 +21,11 @@ const DropDown = forwardRef(({ name, options = [], disabled, onChange, onTextCha
|
|
|
21
21
|
const option = options.find((option) => String(option.value) === String(value));
|
|
22
22
|
if (!option) {
|
|
23
23
|
setLabel('');
|
|
24
|
+
setValueFilter(undefined);
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
26
27
|
setLabel(option.label);
|
|
28
|
+
setValueFilter(option.label);
|
|
27
29
|
}, [value]);
|
|
28
30
|
const handleFocus = useCallback(() => {
|
|
29
31
|
if (disabled) {
|
package/lib/ui/forms/index.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export { DropDown, TextBox };
|
|
1
|
+
export * from '../../ui/forms/drop-down';
|
|
2
|
+
export * from '../../ui/forms/text-box';
|
package/lib/ui/forms/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export { DropDown, TextBox };
|
|
1
|
+
export * from '../../ui/forms/drop-down';
|
|
2
|
+
export * from '../../ui/forms/text-box';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './string.utils';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './string.utils';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates initials from the given name.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This function takes a full name as input and returns the initials.
|
|
6
|
+
*
|
|
7
|
+
* @param name - The full name from which initials are generated.
|
|
8
|
+
* @returns The initials generated from the name.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // Example 1:
|
|
13
|
+
* const name1 = "John Doe";
|
|
14
|
+
* const initials1 = getInitials(name1);
|
|
15
|
+
* console.log(initials1); // Output: "JD"
|
|
16
|
+
*
|
|
17
|
+
* // Example 2:
|
|
18
|
+
* const name2 = "Alice Bob Charlie";
|
|
19
|
+
* const initials2 = getInitials(name2);
|
|
20
|
+
* console.log(initials2); // Output: "AC"
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export declare function getInitials(name: string): string;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates initials from the given name.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This function takes a full name as input and returns the initials.
|
|
6
|
+
*
|
|
7
|
+
* @param name - The full name from which initials are generated.
|
|
8
|
+
* @returns The initials generated from the name.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // Example 1:
|
|
13
|
+
* const name1 = "John Doe";
|
|
14
|
+
* const initials1 = getInitials(name1);
|
|
15
|
+
* console.log(initials1); // Output: "JD"
|
|
16
|
+
*
|
|
17
|
+
* // Example 2:
|
|
18
|
+
* const name2 = "Alice Bob Charlie";
|
|
19
|
+
* const initials2 = getInitials(name2);
|
|
20
|
+
* console.log(initials2); // Output: "AC"
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export function getInitials(name) {
|
|
26
|
+
const words = name.split(' ');
|
|
27
|
+
const getCharAt = (word) => word.charAt(0).toUpperCase();
|
|
28
|
+
if (words.length === 1) {
|
|
29
|
+
return name.substring(0, 2).toUpperCase();
|
|
30
|
+
}
|
|
31
|
+
if (words.length === 2) {
|
|
32
|
+
return words.map(getCharAt).join('');
|
|
33
|
+
}
|
|
34
|
+
return words
|
|
35
|
+
.filter((_, index) => index % 2 === 0)
|
|
36
|
+
.map(getCharAt)
|
|
37
|
+
.join('');
|
|
38
|
+
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@creativecodeco/ui",
|
|
3
|
-
"description": "CreativeCode.com.co
|
|
3
|
+
"description": "System Design CreativeCode.com.co",
|
|
4
4
|
"keywords": [
|
|
5
|
-
"
|
|
5
|
+
"creativeCode.com.co",
|
|
6
6
|
"creativecodeco/ui",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
7
|
+
"tailwindcss",
|
|
8
|
+
"daisyui",
|
|
9
|
+
"ui",
|
|
10
|
+
"framework design",
|
|
11
|
+
"design system"
|
|
11
12
|
],
|
|
12
|
-
"version": "0.0
|
|
13
|
+
"version": "0.1.0",
|
|
13
14
|
"homepage": "https://github.com/creativecodeco/ui",
|
|
14
15
|
"author": {
|
|
15
16
|
"name": "John Toro",
|
|
@@ -46,6 +47,14 @@
|
|
|
46
47
|
"tailwindcss": "3.4.0",
|
|
47
48
|
"usehooks-ts": "2.9.1"
|
|
48
49
|
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"postcss": "8.4.32",
|
|
52
|
+
"postcss-import": "16.0.0",
|
|
53
|
+
"react": "18.2.0",
|
|
54
|
+
"react-hook-form": "7.49.2",
|
|
55
|
+
"tailwindcss": "3.4.0",
|
|
56
|
+
"usehooks-ts": "2.9.1"
|
|
57
|
+
},
|
|
49
58
|
"devDependencies": {
|
|
50
59
|
"@babel/core": "7.23.7",
|
|
51
60
|
"@babel/preset-env": "7.23.7",
|
|
@@ -61,7 +70,7 @@
|
|
|
61
70
|
"@storybook/react-webpack5": "7.6.7",
|
|
62
71
|
"@storybook/test": "7.6.7",
|
|
63
72
|
"@testing-library/dom": "9.3.3",
|
|
64
|
-
"@testing-library/jest-dom": "6.
|
|
73
|
+
"@testing-library/jest-dom": "6.2.0",
|
|
65
74
|
"@testing-library/react": "14.1.2",
|
|
66
75
|
"@testing-library/user-event": "14.5.2",
|
|
67
76
|
"@types/jest": "29.5.11",
|
|
@@ -73,7 +82,7 @@
|
|
|
73
82
|
"chromatic": "10.2.0",
|
|
74
83
|
"classnames": "2.5.1",
|
|
75
84
|
"cpx2": "7.0.1",
|
|
76
|
-
"daisyui": "4.
|
|
85
|
+
"daisyui": "4.5.0",
|
|
77
86
|
"eslint": "8.56.0",
|
|
78
87
|
"eslint-config-prettier": "9.1.0",
|
|
79
88
|
"eslint-config-standard": "17.1.0",
|
|
@@ -94,25 +103,19 @@
|
|
|
94
103
|
"jest-environment-jsdom": "29.7.0",
|
|
95
104
|
"jest-junit": "16.0.0",
|
|
96
105
|
"jest-transform-css": "6.0.1",
|
|
97
|
-
"postcss": "
|
|
98
|
-
"postcss-cli": "11.0.0",
|
|
99
|
-
"postcss-import": "15.1.0",
|
|
106
|
+
"postcss-cli": "^11.0.0",
|
|
100
107
|
"prettier": "3.1.1",
|
|
101
108
|
"prop-types": "15.8.1",
|
|
102
|
-
"react": "18.2.0",
|
|
103
109
|
"react-dom": "18.2.0",
|
|
104
|
-
"react-hook-form": "7.49.2",
|
|
105
110
|
"react-icons": "4.12.0",
|
|
106
111
|
"storybook": "7.6.7",
|
|
107
112
|
"storybook-addon-themes": "6.1.0",
|
|
108
113
|
"string-width": "7.0.0",
|
|
109
|
-
"tailwindcss": "3.4.0",
|
|
110
114
|
"ts-jest": "29.1.1",
|
|
111
115
|
"ts-node": "10.9.2",
|
|
112
116
|
"tsc-alias": "1.8.8",
|
|
113
117
|
"tsconfig-paths-webpack-plugin": "4.1.0",
|
|
114
|
-
"typescript": "5.3.3"
|
|
115
|
-
"usehooks-ts": "2.9.1"
|
|
118
|
+
"typescript": "5.3.3"
|
|
116
119
|
},
|
|
117
120
|
"files": [
|
|
118
121
|
"lib"
|