hds-web 1.0.1 → 1.0.2

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.
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import {HDSColor} from '../../../foundation/ColorPalette';
2
3
  import PropTypes from 'prop-types';
3
4
  import {ReactComponent as HasuraPrimaryIcon } from "../../../assets/icons/HasuraPrimary.svg"
4
5
  import {ReactComponent as ClockrewindIcon } from "../../../assets/icons/clock-rewind.svg"
@@ -2351,12 +2352,13 @@ const iconReferenceMap = {
2351
2352
  home03: Home03Icon,
2352
2353
  HasuraBlueLogo: HasuraBlueLogoIcon,
2353
2354
  };
2354
- export default function Icon ({ variant, height, strokeColor, className }){
2355
+ export default function Icon ({ variant, height, strokeColor, strokeClass, className }){
2355
2356
  const CurrentActiveIcon = iconReferenceMap[variant];
2357
+ const IconStrokeCLass = HDSColor(strokeClass);
2356
2358
  return (
2357
2359
  <div style={{ stroke: `${strokeColor}` }}>
2358
2360
  <CurrentActiveIcon
2359
- className={[`${height}`, `stroke-${strokeColor}`, `${className}` ].join(' ')}
2361
+ className={[`${height}`, `${IconStrokeCLass}`, `${className}` ].join(' ')}
2360
2362
  />
2361
2363
  </div>
2362
2364
  );
@@ -2364,4 +2366,9 @@ export default function Icon ({ variant, height, strokeColor, className }){
2364
2366
  Icon.propTypes = {
2365
2367
  fillColor: PropTypes.string,
2366
2368
  strokeColor: PropTypes.string,
2369
+ };
2370
+
2371
+ Icon.defaultProps = {
2372
+ strokeClass: 'stroke-neutral-0',
2373
+ height: 'h-6 w-6'
2367
2374
  };
@@ -479,7 +479,102 @@ const HDSColors = {
479
479
  "to-red-500": "to-red-500",
480
480
  "to-red-600": "to-red-600",
481
481
  "to-red-700": "to-red-700",
482
- "to-red-800": "to-red-800"
482
+ "to-red-800": "to-red-800",
483
+ "stroke-base-0": "stroke-base-0",
484
+ "stroke-base-1000": "stroke-base-1000",
485
+ "stroke-neutral-0": "stroke-neutral-0",
486
+ "stroke-neutral-50": "stroke-neutral-50",
487
+ "stroke-neutral-100": "stroke-neutral-100",
488
+ "stroke-neutral-150": "stroke-neutral-150",
489
+ "stroke-neutral-200": "stroke-neutral-200",
490
+ "stroke-neutral-300": "stroke-neutral-300",
491
+ "stroke-neutral-400": "stroke-neutral-400",
492
+ "stroke-neutral-500": "stroke-neutral-500",
493
+ "stroke-neutral-600": "stroke-neutral-600",
494
+ "stroke-neutral-700": "stroke-neutral-700",
495
+ "stroke-neutral-800": "stroke-neutral-800",
496
+ "stroke-neutral-850": "stroke-neutral-850",
497
+ "stroke-neutral-900": "stroke-neutral-900",
498
+ "stroke-neutral-950": "stroke-neutral-950",
499
+ "stroke-neutral-1000": "stroke-neutral-1000",
500
+ "stroke-blue-100": "stroke-blue-100",
501
+ "stroke-blue-200": "stroke-blue-200",
502
+ "stroke-blue-300": "stroke-blue-300",
503
+ "stroke-blue-400": "stroke-blue-400",
504
+ "stroke-blue-500": "stroke-blue-500",
505
+ "stroke-blue-600": "stroke-blue-600",
506
+ "stroke-blue-700": "stroke-blue-700",
507
+ "stroke-blue-800": "stroke-blue-800",
508
+ "stroke-blue-900": "stroke-blue-900",
509
+ "stroke-purple-100": "stroke-purple-100",
510
+ "stroke-purple-200": "stroke-purple-200",
511
+ "stroke-purple-300": "stroke-purple-300",
512
+ "stroke-purple-400": "stroke-purple-400",
513
+ "stroke-purple-500": "stroke-purple-500",
514
+ "stroke-purple-600": "stroke-purple-600",
515
+ "stroke-purple-700": "stroke-purple-700",
516
+ "stroke-purple-800": "stroke-purple-800",
517
+ "stroke-purple-900": "stroke-purple-900",
518
+ "stroke-cyan-100": "stroke-cyan-100",
519
+ "stroke-cyan-200": "stroke-cyan-200",
520
+ "stroke-cyan-300": "stroke-cyan-300",
521
+ "stroke-cyan-400": "stroke-cyan-400",
522
+ "stroke-cyan-500": "stroke-cyan-500",
523
+ "stroke-cyan-600": "stroke-cyan-600",
524
+ "stroke-cyan-700": "stroke-cyan-700",
525
+ "stroke-cyan-800": "stroke-cyan-800",
526
+ "stroke-cyan-900": "stroke-cyan-900",
527
+ "stroke-green-100": "stroke-green-100",
528
+ "stroke-green-200": "stroke-green-200",
529
+ "stroke-green-300": "stroke-green-300",
530
+ "stroke-green-400": "stroke-green-400",
531
+ "stroke-green-500": "stroke-green-500",
532
+ "stroke-green-600": "stroke-green-600",
533
+ "stroke-green-700": "stroke-green-700",
534
+ "stroke-green-800": "stroke-green-800",
535
+ "stroke-green-900": "stroke-green-900",
536
+ "stroke-pink-100": "stroke-pink-100",
537
+ "stroke-pink-200": "stroke-pink-200",
538
+ "stroke-pink-300": "stroke-pink-300",
539
+ "stroke-pink-400": "stroke-pink-400",
540
+ "stroke-pink-500": "stroke-pink-500",
541
+ "stroke-pink-600": "stroke-pink-600",
542
+ "stroke-pink-700": "stroke-pink-700",
543
+ "stroke-pink-800": "stroke-pink-800",
544
+ "stroke-pink-900": "stroke-pink-900",
545
+ "stroke-amber-100": "stroke-amber-100",
546
+ "stroke-amber-200": "stroke-amber-200",
547
+ "stroke-amber-300": "stroke-amber-300",
548
+ "stroke-amber-400": "stroke-amber-400",
549
+ "stroke-amber-500": "stroke-amber-500",
550
+ "stroke-amber-600": "stroke-amber-600",
551
+ "stroke-amber-700": "stroke-amber-700",
552
+ "stroke-amber-800": "stroke-amber-800",
553
+ "stroke-amber-900": "stroke-amber-900",
554
+ "stroke-yellow-100": "stroke-yellow-100",
555
+ "stroke-yellow-200": "stroke-yellow-200",
556
+ "stroke-yellow-300": "stroke-yellow-300",
557
+ "stroke-yellow-400": "stroke-yellow-400",
558
+ "stroke-yellow-500": "stroke-yellow-500",
559
+ "stroke-yellow-600": "stroke-yellow-600",
560
+ "stroke-yellow-700": "stroke-yellow-700",
561
+ "stroke-yellow-800": "stroke-yellow-800",
562
+ "stroke-orange-100": "stroke-orange-100",
563
+ "stroke-orange-200": "stroke-orange-200",
564
+ "stroke-orange-300": "stroke-orange-300",
565
+ "stroke-orange-400": "stroke-orange-400",
566
+ "stroke-orange-500": "stroke-orange-500",
567
+ "stroke-orange-600": "stroke-orange-600",
568
+ "stroke-orange-700": "stroke-orange-700",
569
+ "stroke-orange-800": "stroke-orange-800",
570
+ "stroke-red-100": "stroke-red-100",
571
+ "stroke-red-200": "stroke-red-200",
572
+ "stroke-red-300": "stroke-red-300",
573
+ "stroke-red-400": "stroke-red-400",
574
+ "stroke-red-500": "stroke-red-500",
575
+ "stroke-red-600": "stroke-red-600",
576
+ "stroke-red-700": "stroke-red-700",
577
+ "stroke-red-800": "stroke-red-800"
483
578
  };
484
579
 
485
580
  export default function HDSColor(color = 'bg-blue-600') {
@@ -1,73 +1,95 @@
1
1
  import React, { useState, useEffect } from 'react';
2
- import { Typography } from '../../foundation/Typography';
3
2
 
4
- const TimeComponent = ({ dateTimeString, className }) => {
3
+ const TimeComponent = ({ format, countdownTime }) => {
5
4
  const [currentTime, setCurrentTime] = useState(new Date());
6
- const [userTimeZone, setUserTimeZone] = useState('');
7
5
 
8
6
  useEffect(() => {
9
7
  const interval = setInterval(() => {
10
8
  setCurrentTime(new Date());
11
9
  }, 1000);
12
-
13
- getUserTimeZone();
14
-
15
10
  return () => clearInterval(interval);
16
11
  }, []);
17
12
 
18
- const formatTime = (time, timeZone) => {
19
- return time.toLocaleString('en-US', {
20
- month: 'long',
21
- day: 'numeric',
22
- year: 'numeric',
23
- hour: 'numeric',
24
- minute: 'numeric',
25
- hour12: true,
26
- timeZone,
27
- });
13
+ const formatTime = () => {
14
+ switch (format) {
15
+ case 'MM/dd/yyyy hh:mm:ss tt':
16
+ return currentTime.toLocaleString('en-US', {
17
+ month: '2-digit',
18
+ day: '2-digit',
19
+ year: 'numeric',
20
+ hour: 'numeric',
21
+ minute: 'numeric',
22
+ second: 'numeric',
23
+ hour12: true,
24
+ });
25
+ case 'yyyy-mm-dd hh:mm:ss':
26
+ return currentTime.toLocaleString('en-US', {
27
+ year: 'numeric',
28
+ month: '2-digit',
29
+ day: '2-digit',
30
+ hour: 'numeric',
31
+ minute: 'numeric',
32
+ second: 'numeric',
33
+ }).replace(/,/g, '');
34
+ case 'yyyy-mm-dd HH:MM:SS tt':
35
+ return currentTime.toLocaleString('en-US', {
36
+ year: 'numeric',
37
+ month: '2-digit',
38
+ day: '2-digit',
39
+ hour: 'numeric',
40
+ minute: 'numeric',
41
+ second: 'numeric',
42
+ hour12: false,
43
+ });
44
+ case 'm/d/yyyy':
45
+ return currentTime.toLocaleString('en-US', {
46
+ month: 'numeric',
47
+ day: 'numeric',
48
+ year: 'numeric',
49
+ });
50
+ case 'yyyy-mm-dd':
51
+ return currentTime.toLocaleString('en-US', {
52
+ year: 'numeric',
53
+ month: '2-digit',
54
+ day: '2-digit',
55
+ });
56
+ default:
57
+ return currentTime.toLocaleString();
58
+ }
28
59
  };
29
60
 
30
- const getUserTimeZone = () => {
31
- const getTimeZone = () => {
32
- const offset = new Date().getTimezoneOffset();
33
- const offsetHours = Math.abs(Math.floor(offset / 60));
34
- const offsetMinutes = Math.abs(offset % 60);
35
- const sign = offset < 0 ? '+' : '-';
36
- return `GMT${sign}${offsetHours.toString().padStart(2, '0')}:${offsetMinutes
37
- .toString()
38
- .padStart(2, '0')}`;
39
- };
61
+ const countdown = () => {
62
+ if (!countdownTime) {
63
+ return null;
64
+ }
40
65
 
41
- setUserTimeZone(getTimeZone());
42
- };
66
+ const remainingTime = countdownTime - currentTime;
43
67
 
44
- const getUserDateTime = () => {
45
- if (!dateTimeString) {
46
- return null;
68
+ if (remainingTime <= 0) {
69
+ return <div>Time's up!</div>;
47
70
  }
48
71
 
49
- const parseDateTime = (dateTimeString) => {
50
- const parts = dateTimeString.split('|');
51
- const dateString = parts[0].trim();
52
- const timeString = parts[1].trim();
53
- const [month, day, year] = dateString.split(' ');
54
- const [time, timezone] = timeString.split(' ');
55
- const [hours, minutes] = time.split(':');
56
- const dateTime = new Date(`${month} ${day}, ${year} ${hours}:${minutes}`);
57
- return dateTime.toLocaleString('en-US', { timeZone: timezone });
58
- };
72
+ const seconds = Math.floor(remainingTime / 1000) % 60;
73
+ const minutes = Math.floor(remainingTime / 1000 / 60) % 60;
74
+ const hours = Math.floor(remainingTime / 1000 / 60 / 60) % 24;
75
+ const days = Math.floor(remainingTime / 1000 / 60 / 60 / 24);
59
76
 
60
- const userDateTime = parseDateTime(dateTimeString);
61
- return userDateTime;
77
+ return (
78
+ <div>
79
+ <div>{days} days</div>
80
+ <div>
81
+ {hours.toString().padStart(2, '0')}:
82
+ {minutes.toString().padStart(2, '0')}:
83
+ {seconds.toString().padStart(2, '0')}
84
+ </div>
85
+ </div>
86
+ );
62
87
  };
63
88
 
64
89
  return (
65
90
  <div>
66
- <div className={className}>
67
- <Typography textStyle='h6'>
68
- {getUserDateTime() || formatTime(currentTime, userTimeZone)}
69
- </Typography>
70
- </div>
91
+ <div>{formatTime()}</div>
92
+ {countdown()}
71
93
  </div>
72
94
  );
73
95
  };
package/src/HDS/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './foundation';
2
2
  export * from './helpers';
3
- export * from './components';
3
+ export * from './components';
4
+ export * from './modules';
@@ -0,0 +1 @@
1
+ export {default as TextCard} from './textCard';
@@ -0,0 +1,132 @@
1
+ import React from "react";
2
+ import { Typography } from "../../foundation/Typography";
3
+ import { HDSColor } from "../../foundation/ColorPalette";
4
+ import { HDSButton } from '../../components/Buttons';
5
+ import { Icon } from '../../components/common-components/Icon';
6
+
7
+ export default function TextCard(props) {
8
+ const titleColor = HDSColor(props.title_color);
9
+ console.log(props.descriptions);
10
+ return (
11
+ <>
12
+ {
13
+ props.feature_cards_links && (<Typography textStyle="h3" as="h3" className={`${titleColor} pb-8 tb-l:w-1/2`}>{props.title}</Typography>)
14
+ }
15
+ <div className={'grid grid-cols-1 tb:grid-cols-2 gap-10' + ((props.feature_cards_links) ? ' tb:gap-0 tb-l:gap-0' : ' tb:gap-16 tb-l:gap-36')}>
16
+ <div>
17
+ {
18
+ !props.feature_cards_links && (<Typography textStyle="h3" as="h3" className={`${titleColor} pb-6`}>{props.title}</Typography>)
19
+ }
20
+ {
21
+ props.descriptions && props.descriptions.map((desc, i) => (
22
+ <Typography key={i} textStyle="body1" className="pb-6">{desc.description}</Typography>
23
+ ))
24
+ }
25
+ {
26
+ props.descriptions_list && (
27
+ <div className="pb-6">
28
+ {
29
+ props.descriptions_list && props.descriptions_list.map((descList, j) => {
30
+ const iconBgColor = HDSColor(descList.icon_bg_color);
31
+ const iconColor = HDSColor(descList.icon_color);
32
+ return (
33
+ <div className='flex items-start pb-4 last:pb-0' key={j}>
34
+ <div className={`${iconBgColor} w-6 h-6 rounded-full mr-2 flex items-center justify-center`}>
35
+ <Icon
36
+ height={`h-3 w-3 stroke-[1.5px]` }
37
+ variant={descList.icon_name}
38
+ strokeColor={iconColor}
39
+ />
40
+ </div>
41
+ <Typography textStyle='body1' className='text-neutral-1000'>{descList.description}</Typography>
42
+ </div>
43
+ )
44
+ })
45
+ }
46
+ </div>
47
+ )
48
+ }
49
+ {
50
+ props.feature_cards_links && (
51
+ <div className='border border-neutral-150 rounded-2xl tb:rounded-e-none'>
52
+ {
53
+ props.feature_cards_links.map((list, i) => {
54
+ const currentStrokeColor = HDSColor(list.icon_color)
55
+ return (
56
+ <div className='border-b border-b-neutral-150 last:border-b-0'>
57
+ <div className='m-2 p-6 rounded-lg hover:bg-neutral-100' key={i}>
58
+ <div className='flex items-center pb-4'>
59
+ <Icon
60
+ height={`w-6 h-6 mr-2 stroke-[1.5px]` }
61
+ variant={list.icon_name}
62
+ strokeColor={currentStrokeColor}
63
+ />
64
+ <Typography textStyle='h5' as='h5' className='text-neutral-1000'>{list.title}</Typography>
65
+ </div>
66
+ {list.description && <Typography textStyle='body3' className='pb-4 text-neutral-1000'>{list.description}</Typography>}
67
+ {
68
+ list.descriptions_list && list.descriptions_list.map((descList, j) => {
69
+ const iconBgColor = HDSColor(descList.icon_bg_color);
70
+ const iconColor = HDSColor(descList.icon_color);
71
+ return (
72
+ <div className='flex items-start pb-4 last:pb-0' key={j}>
73
+ <div className={`${iconBgColor} w-5 h-5 rounded-full mr-2 flex items-center justify-center`}>
74
+ <Icon
75
+ height={`h-3 w-3 stroke-[1.5px]` }
76
+ variant={descList.icon_name}
77
+ strokeColor={iconColor}
78
+ />
79
+ </div>
80
+ <Typography textStyle='body3' className='text-neutral-1000'>{descList.description}</Typography>
81
+ </div>
82
+ )
83
+ })
84
+ }
85
+ {
86
+ props.button && (
87
+ <HDSButton
88
+ label={props.button.cta_text}
89
+ type='primaryLink'
90
+ leftIconVariant='none'
91
+ rightIconVariant='none'
92
+ state='default'
93
+ size='md'
94
+ rightAnimatedArrow={true}
95
+ rightAnimatedArrowColor='#3970FD'
96
+ />
97
+ )
98
+ }
99
+ </div>
100
+ </div>
101
+ )
102
+ })
103
+ }
104
+ </div>
105
+ )
106
+ }
107
+ {
108
+ props.button && (
109
+ <HDSButton
110
+ label={props.button.cta_text}
111
+ type='secondary'
112
+ leftIconVariant='none'
113
+ rightIconVariant='none'
114
+ state='default'
115
+ size='md'
116
+ rightAnimatedArrow={true}
117
+ rightAnimatedArrowColor='#3970FD'
118
+ />
119
+ )
120
+ }
121
+ </div>
122
+ <div>
123
+ {
124
+ props.img_url && (
125
+ <img src={props.img_url} alt={props.title} />
126
+ )
127
+ }
128
+ </div>
129
+ </div>
130
+ </>
131
+ )
132
+ }
@@ -0,0 +1 @@
1
+ export * from './TextCard';