hds-web 1.0.3 → 1.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hds-web",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
@@ -1,21 +1,20 @@
1
1
  import React from 'react';
2
- import { v4 as uuidv4 } from 'uuid';
2
+ import { useState } from 'react';
3
3
  import { Typography } from '../../foundation/Typography'
4
4
  import { Icon } from '../common-components/Icon'
5
+ import { Tab } from '../Tabs'
5
6
 
6
- const test = (TABLE_HEADER) => (
7
- console.log(TABLE_HEADER[0]['title']),
8
- Object.keys(TABLE_HEADER[0]).map((key, value) => (
7
+ const tabs = [
8
+ { name: 'My Account', href: '', current: false },
9
+ { name: 'Company', href: '', current: false },
10
+ { name: 'Team Members', href: '', current: true },
11
+ { name: 'Billing', href: '', current: false },
12
+ ]
9
13
 
10
- <th
11
- key={key}
12
- scope="col"
13
- className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900 sm:table-cell"
14
- >
15
- {key}
16
- </th>
17
- ))
18
- )
14
+ function handleTabClick(tab) {
15
+ console.log(`Tab "${tab.name}" updatedTabs`);
16
+ // Perform any other actions based on the clicked tab
17
+ }
19
18
 
20
19
  export default function TableB(props) {
21
20
  const {
@@ -24,31 +23,130 @@ export default function TableB(props) {
24
23
  TABLE_VALUE,
25
24
  TABLE_HEADER,
26
25
  children
27
-
28
26
  } = props;
29
- test(TABLE_HEADER);
27
+ const [activeTab, setActiveTab] = useState(2);
30
28
  return (
31
- <div className="px-4 sm:px-6 lg:px-8 ">
32
- <div className="sm:flex sm:items-center ">
33
- <div className="sm:flex-auto flex flex-col items-center">
34
- {title && (
35
- <Typography
36
- textStyle='h2'>
37
- {title}
38
- </Typography>
39
- )
40
- }
41
- {description && (
29
+ <div className=" max-w-7xl">
30
+ <div className="sm:flex sm:items-center flex justify-around ">
31
+
32
+ <div className="w-full items-center flex justify-around md:flex md:flex-col md:items-center">
33
+ <div>
34
+
35
+
36
+ {title && (
37
+ <Typography
38
+ textStyle='h3'>
39
+ {title}
40
+ </Typography>
41
+ )
42
+ }
43
+ {/* {description && (
42
44
  <Typography
43
45
  textStyle='body1c'>
44
46
  {description}
45
47
  </Typography>
46
48
  )
47
- }
49
+ } */}
50
+ </div>
51
+ <div className=''>
52
+ <Tab onTabClick={handleTabClick} tabs={tabs} />
53
+ </div>
54
+ </div>
55
+ </div>
56
+
57
+ <div className=''>
58
+ <div className="-mx-4 mt-8 sm:-mx-0 bg-neutral-0 rounded-3xl ">
59
+ <table className="min-w-full shadow rounded-3xl ">
60
+ <thead>
61
+ <tr className='divide-x divide-neutral-200 text-center rounded-t-3xl'>
62
+ <th
63
+ key={activeTab}
64
+ scope="col"
65
+ className="px-8 py-6 sm:table-cell"
66
+ >
67
+ <div className=''>
68
+ <div className='flex flex-col justify-center items-center text-center'>
69
+ <div className={'flex items-center gap-2'}>
70
+ {TABLE_HEADER[activeTab]['icon'] &&
71
+ (
72
+ <Icon
73
+ height='h-6 w-6'
74
+ variant={TABLE_HEADER[activeTab]['icon']}
75
+ strokeClass={TABLE_HEADER[activeTab]['iconStrokeClass']} />
76
+ )
77
+ }
78
+ {
79
+ TABLE_HEADER[activeTab]['title'] && activeTab == 0 && (
80
+ <Typography
81
+ textStyle='h5'
82
+ className={TABLE_HEADER[activeTab]['title_text_color']}>
83
+ {TABLE_HEADER[activeTab]['title']}
84
+ </Typography>)
85
+ }
86
+ {
87
+ TABLE_HEADER[activeTab]['title'] && activeTab != 0 && (
88
+ <Typography
89
+ textStyle='h5'
90
+ className={TABLE_HEADER[activeTab]['title_text_color']}>
91
+ {TABLE_HEADER[activeTab]['title']}
92
+ </Typography>)
93
+ }
94
+
95
+
96
+ </div>
97
+ <div className=' max-w-[10rem]'>
98
+ {TABLE_HEADER[activeTab]['descr'] && (
99
+ <Typography
100
+ textStyle='body1'
101
+ className={TABLE_HEADER[activeTab]['descr_text_color']}>
102
+ {TABLE_HEADER[activeTab]['descr']}
103
+ </Typography>)}
104
+ </div>
105
+ </div>
106
+ </div>
107
+ </th>
108
+ </tr>
109
+ </thead>
110
+ <tbody className="divide-y divide-neutral-200 rounded-b-3xl">
111
+ {TABLE_VALUE.map((value, index) => (
112
+ <tr className='divide-x divide-neutral-200' key={index}>
113
+ {Object.keys(value).map((key, index) => (
114
+ <React.Fragment key={index}>
115
+ {key === 'rowTitle' && (<td
116
+ key={key}
117
+ className="px-8 py-7 w-[22.5rem] whitespace-pre-line "
118
+ >
119
+ <Typography className='max-w-[22rem] text-neutral-700' textStyle='body1c'>{value[key]}</Typography>
120
+
121
+ </td>)}
122
+
123
+ {key !== 'rowTitle' && (
124
+ <td
125
+ key={key}
126
+ className="px-8 py-7 text-center"
127
+ >
128
+ {value[key]['text'] && (
129
+ <Typography className='text-neutral-700' textStyle='body1c'>{value[key]['text']}</Typography>
130
+
131
+ )}
132
+ {!value[key]['text'] && (
133
+ <div className='flex justify-center'>
134
+ <Icon height='h-5 w-5' variant={value[key]['iconVariant']} strokeClass={value[key]['iconStrokeClass']} />
135
+ </div>
136
+ )}
137
+
138
+
139
+ </td>)}
140
+ </React.Fragment>
141
+ ))}
142
+ </tr>
143
+ ))}
144
+ </tbody>
145
+ </table>
48
146
  </div>
49
147
  </div>
50
148
 
51
- <div>
149
+ <div className='hidden md:block' >
52
150
  <div className="-mx-4 mt-8 sm:-mx-0 bg-neutral-0 rounded-3xl ">
53
151
  <table className="min-w-full shadow rounded-3xl ">
54
152
  <thead>
@@ -71,7 +169,7 @@ export default function TableB(props) {
71
169
  )
72
170
  }
73
171
  {
74
- TABLE_HEADER[key]['title'] && key==0 && (
172
+ TABLE_HEADER[key]['title'] && key == 0 && (
75
173
  <Typography
76
174
  textStyle='h5'
77
175
  className={TABLE_HEADER[key]['title_text_color']}>
@@ -79,15 +177,15 @@ export default function TableB(props) {
79
177
  </Typography>)
80
178
  }
81
179
  {
82
- TABLE_HEADER[key]['title'] && key!=0 && (
180
+ TABLE_HEADER[key]['title'] && key != 0 && (
83
181
  <Typography
84
182
  textStyle='h5'
85
183
  className={TABLE_HEADER[key]['title_text_color']}>
86
184
  {TABLE_HEADER[key]['title']}
87
185
  </Typography>)
88
186
  }
89
-
90
-
187
+
188
+
91
189
  </div>
92
190
  <div className=' max-w-[10rem]'>
93
191
  {TABLE_HEADER[key]['descr'] && (
@@ -104,12 +202,12 @@ export default function TableB(props) {
104
202
  </tr>
105
203
  </thead>
106
204
  <tbody className="divide-y divide-neutral-200 rounded-b-3xl">
107
- {TABLE_VALUE.map((value) => (
108
- <tr className='divide-x divide-neutral-200' key={uuidv4()}>
205
+ {TABLE_VALUE.map((value, index) => (
206
+ <tr className='divide-x divide-neutral-200' key={index}>
109
207
  {Object.keys(value).map((key) => (
110
- <React.Fragment key={uuidv4()}>
208
+ <React.Fragment key={key}>
111
209
  {key === 'rowTitle' && (<td
112
- key={uuidv4()}
210
+ key={key}
113
211
  className="px-8 py-7 w-[22.5rem] whitespace-pre-line "
114
212
  >
115
213
  <Typography className='max-w-[22rem] text-neutral-700' textStyle='body1c'>{value[key]}</Typography>
@@ -118,7 +216,7 @@ export default function TableB(props) {
118
216
 
119
217
  {key !== 'rowTitle' && (
120
218
  <td
121
- key={uuidv4()}
219
+ key={key}
122
220
  className="px-8 py-7 text-center"
123
221
  >
124
222
  {value[key]['text'] && (
@@ -133,7 +231,7 @@ export default function TableB(props) {
133
231
 
134
232
 
135
233
  </td>)}
136
- </React.Fragment>
234
+ </React.Fragment>
137
235
  ))}
138
236
  </tr>
139
237
  ))}
@@ -0,0 +1,61 @@
1
+ import React, { useState, useRef, useEffect } from 'react';
2
+
3
+ export default function Tab(props) {
4
+ const { tabs, onTabClick } = props;
5
+ const [activeTab, setActiveTab] = useState(tabs.find(tab => tab.current) || tabs[0]);
6
+ const pillRef = useRef(null);
7
+ const activeTabRef = useRef(null);
8
+
9
+ const handleTabClick = (event, clickedTab) => {
10
+ event.preventDefault();
11
+ setActiveTab(clickedTab);
12
+ if (onTabClick) {
13
+ onTabClick(clickedTab);
14
+ }
15
+ };
16
+
17
+ useEffect(() => {
18
+ // Update the pill position and height when activeTab changes
19
+ const pill = pillRef.current;
20
+ const activeTabElement = activeTabRef.current;
21
+
22
+ if (pill && activeTabElement) {
23
+ const pillWidth = activeTabElement.offsetWidth;
24
+ const pillHeight = activeTabElement.offsetHeight;
25
+ const pillOffset = activeTabElement.offsetLeft;
26
+
27
+ pill.style.transform = `translateX(${pillOffset}px)`;
28
+ pill.style.width = `${pillWidth}px`;
29
+ pill.style.height = `${pillHeight}px`;
30
+ }
31
+ }, [activeTab]);
32
+
33
+ return (
34
+ <div>
35
+ <div className="hidden md:block">
36
+ <nav className="relative inline-flex bg-neutral-0 p-2 rounded-full" aria-label="Tabs">
37
+ {tabs.map((tab, index) => (
38
+ <a
39
+ key={tab.name}
40
+ href="#"
41
+ className={`relative px-3 py-1 font-medium text-sm rounded-full ${
42
+ activeTab === tab
43
+ ? 'bg-blue-600 text-neutral-0 z-10' // Increase z-index for active tab
44
+ : 'text-neutral-500 bg-neutral-0 hover:bg-neutral-100 flex-nowrap transition-all duration-500'
45
+ }`}
46
+ aria-current={activeTab === tab ? 'page' : undefined}
47
+ onClick={(event) => handleTabClick(event, tab)}
48
+ ref={activeTab === tab ? activeTabRef : null}
49
+ >
50
+ {tab.name}
51
+ </a>
52
+ ))}
53
+ <span
54
+ ref={pillRef}
55
+ className="absolute bg-blue-600 rounded-full transition-all duration-500 z-0 -mt-px" // Add negative margin to counteract the gap
56
+ />
57
+ </nav>
58
+ </div>
59
+ </div>
60
+ );
61
+ }
@@ -1,47 +1,61 @@
1
- import React from 'react';
1
+ import React, { useState, useRef } from 'react';
2
+ import { Typography } from '../../foundation/Typography'
2
3
 
3
- function classNames(...classes) {
4
- return classes.filter(Boolean).join(' ')
5
- }
6
-
7
- export default function Tab(props){
8
- const tabs = Array.isArray(props.tabs) ? props.tabs : [];
9
- return (
10
- <div>
11
- <div className="md:hidden">
12
- <label htmlFor="tabs" className="sr-only">
13
- Select a tab
14
- </label >
15
- {/* Use an "onChange" listener to redirect the user to the selected tab URL. */}
16
- <select
17
- id="tabs"
18
- name="tabs"
19
- className="block w-full rounded-md border-pink-300 focus:border-pink-500 focus:ring-pink-500"
20
- defaultValue={tabs.length && tabs.find((tab) => tab.current).name}
21
- >
22
- {tabs.length && tabs.map((tab) => (
23
- <option key={tab.name}>{tab.name}</option>
24
- ))}
25
- </select>
26
- </div>
27
- <div className="hidden md:block">
28
- <nav className="inline-flex gap-2 bg-neutral-0 p-2 rounded-full" aria-label="Tabs">
29
- {tabs.length && tabs.map((tab) => (
30
- <a
31
- key={tab.name}
32
- href={tab.href}
33
- className={classNames(
34
- tab.current ? 'bg-blue-600 text-neutral-0' : 'text-neutral-500 bg-neutral-0 hover:bg-neutral-100 hover:transition-all hover: delay-100 flex-nowrap ',
35
- 'px-3 py-1 font-medium text-sm rounded-full'
36
- )}
37
- aria-current={tab.current ? 'page' : undefined}
38
- >
39
- {tab.name}
40
- </a>
41
- ))}
42
- </nav>
43
- </div>
4
+ export default function Tab(props) {
5
+ const { tabs, onTabClick } = props;
6
+ const [activeTab, setActiveTab] = useState(tabs.find(tab => tab.current) || tabs[0]);
7
+ const pillRef = useRef(null);
8
+
9
+ const handleTabClick = (event, clickedTab) => {
10
+ event.preventDefault();
11
+ setActiveTab(clickedTab);
12
+ if (onTabClick) {
13
+ onTabClick(clickedTab);
14
+ }
15
+
16
+ // Move the pill indicator to the clicked tab
17
+ const pill = pillRef.current;
18
+ if (pill) {
19
+ const pillWidth = event.currentTarget.offsetWidth;
20
+ const clickedTabOffset = event.currentTarget.offsetLeft;
21
+ const pillOffset = pill.parentElement.offsetLeft;
22
+ const translateX = clickedTabOffset ;
23
+
24
+ pill.style.transform = `translateX(${translateX}px)`;
25
+ pill.style.width = `${pillWidth}px`;
26
+ }
27
+ };
28
+
29
+ return (
30
+ <div>
31
+ <div className="block">
32
+ <nav className="relative inline-flex gap-2 p-2 rounded-full" aria-label="Tabs">
33
+ {tabs.map(tab => (
34
+ <a
35
+ key={tab.name}
36
+ href="#"
37
+ className={`px-3 py-1 font-medium text-sm rounded-full ${
38
+ activeTab === tab
39
+ ? 'bg-blue-600 text-neutral-0'
40
+ : 'text-neutral-500 bg-neutral-0 hover:bg-neutral-100 flex-nowrap transition-all duration-500'
41
+ }`}
42
+ aria-current={activeTab === tab ? 'page' : undefined}
43
+ onClick={(event) => handleTabClick(event, tab)}
44
+ >
45
+ <Typography className='z-10 whitespace-nowrap' textStyle='body3c-medium'>{tab.name}</Typography>
46
+ </a>
47
+ ))}
48
+ <span
49
+ ref={pillRef}
50
+ className="absolute left-0 -z-10 bg-blue-600 rounded-full transition-all ease-in-out duration-500"
51
+ style={{
52
+ left: `${activeTab.index * 100}%`,
53
+ width: `${activeTab.width}px`, // Use the width of the clicked tab
54
+ height: '28px' // Add desired height to make the pill visible
55
+ }}
56
+ />
57
+ </nav>
44
58
  </div>
45
- )
46
- }
47
-
59
+ </div>
60
+ );
61
+ }
@@ -11,4 +11,5 @@ export * from './InputFields';
11
11
  export * from './Snippet';
12
12
  export * from './Tabs';
13
13
  export * from './Tooltip';
14
- export * from './Hero';
14
+ export * from './Hero';
15
+ export * from './Tables';
@@ -6,7 +6,6 @@ import { Icon } from '../../components/common-components/Icon';
6
6
 
7
7
  export default function TextCard(props) {
8
8
  const titleColor = HDSColor(props.title_color);
9
- console.log(props.descriptions);
10
9
  return (
11
10
  <>
12
11
  {
package/src/index.css CHANGED
@@ -3,6 +3,38 @@
3
3
  @tailwind utilities;
4
4
  /* Typography classes */
5
5
 
6
+
7
+ @keyframes pill-move-left {
8
+ 0% {
9
+ left: 0;
10
+ width: 0%;
11
+ }
12
+ 50% {
13
+ left: 0;
14
+ width: 100%;
15
+ }
16
+ 100% {
17
+ left: 0;
18
+ width: 0%;
19
+ }
20
+ }
21
+
22
+ @keyframes pill-move-right {
23
+ 0% {
24
+ left: 0;
25
+ width: 0%;
26
+ }
27
+ 50% {
28
+ left: 100%;
29
+ width: 0%;
30
+ }
31
+ 100% {
32
+ left: 0;
33
+ width: 0%;
34
+ }
35
+ }
36
+
37
+
6
38
  .card-animation-wrapper {
7
39
  position: relative;
8
40
  }