@abcagency/hc-ui-components 1.3.14 → 1.3.16
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/dist/_virtual/_rollupPluginBabelHelpers.js +1 -1
- package/dist/apis/hcApi.js +1 -1
- package/dist/apis/hcApi.js.map +1 -1
- package/dist/clientToken.js.map +1 -1
- package/dist/components/HireControlMap.js +15 -5
- package/dist/components/HireControlMap.js.map +1 -1
- package/dist/components/modules/accordions/MapAccordionItem.js +11 -1
- package/dist/components/modules/accordions/MapAccordionItem.js.map +1 -1
- package/dist/components/modules/accordions/default.js.map +1 -1
- package/dist/components/modules/accordions/filterItem.js +2 -1
- package/dist/components/modules/accordions/filterItem.js.map +1 -1
- package/dist/components/modules/accordions/filters.js +0 -3
- package/dist/components/modules/accordions/filters.js.map +1 -1
- package/dist/components/modules/buttons/button-group-apply.js +36 -15
- package/dist/components/modules/buttons/button-group-apply.js.map +1 -1
- package/dist/components/modules/buttons/commute-pill.js.map +1 -1
- package/dist/components/modules/buttons/default.js.map +1 -1
- package/dist/components/modules/buttons/items-pill.js.map +1 -1
- package/dist/components/modules/buttons/pill-wrapper.js.map +1 -1
- package/dist/components/modules/buttons/show-all-button.js.map +1 -1
- package/dist/components/modules/cards/default.js.map +1 -1
- package/dist/components/modules/cards/filter.js.map +1 -1
- package/dist/components/modules/dialogs/apply-dialog.js.map +1 -1
- package/dist/components/modules/filter/commute.js +22 -6
- package/dist/components/modules/filter/commute.js.map +1 -1
- package/dist/components/modules/filter/index.js +7 -0
- package/dist/components/modules/filter/index.js.map +1 -1
- package/dist/components/modules/filter/item.js +16 -1
- package/dist/components/modules/filter/item.js.map +1 -1
- package/dist/components/modules/filter/location.js +1 -1
- package/dist/components/modules/filter/location.js.map +1 -1
- package/dist/components/modules/filter/points-of-interest.js.map +1 -1
- package/dist/components/modules/filter/radio-item.js +7 -0
- package/dist/components/modules/filter/radio-item.js.map +1 -1
- package/dist/components/modules/filter/search.js.map +1 -1
- package/dist/components/modules/filter/sort.js.map +1 -1
- package/dist/components/modules/grid.js.map +1 -1
- package/dist/components/modules/icon.js.map +1 -1
- package/dist/components/modules/jobListing/listing-details.js +6 -0
- package/dist/components/modules/jobListing/listing-details.js.map +1 -1
- package/dist/components/modules/maps/info-window-card.js.map +1 -1
- package/dist/components/modules/maps/info-window-content.js +20 -0
- package/dist/components/modules/maps/info-window-content.js.map +1 -1
- package/dist/components/modules/maps/list/field-mapper.js.map +1 -1
- package/dist/components/modules/maps/list/header-item.js.map +1 -1
- package/dist/components/modules/maps/list/header.js.map +1 -1
- package/dist/components/modules/maps/list/index.js +21 -12
- package/dist/components/modules/maps/list/index.js.map +1 -1
- package/dist/components/modules/maps/list/item-expand-card/index.js.map +1 -1
- package/dist/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js.map +1 -1
- package/dist/components/modules/maps/list/item-expand-card/recruiter-details.js.map +1 -1
- package/dist/components/modules/maps/list/item-expand-card/recruiter-headshot.js.map +1 -1
- package/dist/components/modules/maps/list/list-item/index.js +12 -2
- package/dist/components/modules/maps/list/list-item/index.js.map +1 -1
- package/dist/components/modules/maps/map-list.js.map +1 -1
- package/dist/components/modules/maps/map-marker.js +10 -0
- package/dist/components/modules/maps/map-marker.js.map +1 -1
- package/dist/components/modules/maps/map.js.map +1 -1
- package/dist/components/modules/maps/place-marker.js.map +1 -1
- package/dist/components/modules/maps/tabs.js.map +1 -1
- package/dist/constants/eventTypes.js +16 -0
- package/dist/constants/eventTypes.js.map +1 -0
- package/dist/constants/placeTypes.js.map +1 -1
- package/dist/contexts/mapContext.js +9 -27
- package/dist/contexts/mapContext.js.map +1 -1
- package/dist/contexts/mapListContext.js +57 -38
- package/dist/contexts/mapListContext.js.map +1 -1
- package/dist/contexts/placesContext.js.map +1 -1
- package/dist/contexts/trackEventContext.js +20 -0
- package/dist/contexts/trackEventContext.js.map +1 -0
- package/dist/hooks/useList.js +1 -13
- package/dist/hooks/useList.js.map +1 -1
- package/dist/services/apis/hcApi.js +1 -1
- package/dist/services/apis/hcApi.js.map +1 -1
- package/dist/services/clientToken.js.map +1 -1
- package/dist/services/configService.js.map +1 -1
- package/dist/services/googlePlacesNearbyService.js.map +1 -1
- package/dist/services/listingAggregatorService.js +43 -16
- package/dist/services/listingAggregatorService.js.map +1 -1
- package/dist/services/listingEntityService.js.map +1 -1
- package/dist/services/listingService.js.map +1 -1
- package/dist/services/recruiterService.js.map +1 -1
- package/dist/util/filterUtil.js.map +1 -1
- package/dist/util/loading.js.map +1 -1
- package/dist/util/localStorageUtil.js.map +1 -1
- package/dist/util/mapIconUtil.js.map +1 -1
- package/dist/util/mapUtil.js.map +1 -1
- package/dist/util/sortUtil.js.map +1 -1
- package/dist/util/stringUtils.js.map +1 -1
- package/jsconfig.json +7 -7
- package/package.json +60 -60
- package/postcss.config.js +13 -13
- package/preset.default.js +15 -15
- package/rollup.config.mjs +88 -87
- package/src/apis/hcApi.js +93 -93
- package/src/clientToken.js +9 -9
- package/src/components/HireControlMap.js +129 -124
- package/src/components/modules/accordions/MapAccordionItem.js +74 -72
- package/src/components/modules/accordions/default.js +171 -171
- package/src/components/modules/accordions/filterItem.js +55 -53
- package/src/components/modules/accordions/filters.js +47 -47
- package/src/components/modules/buttons/button-group-apply.js +123 -116
- package/src/components/modules/buttons/commute-pill.js +22 -22
- package/src/components/modules/buttons/default.js +194 -194
- package/src/components/modules/buttons/items-pill.js +35 -35
- package/src/components/modules/buttons/pill-wrapper.js +27 -27
- package/src/components/modules/buttons/show-all-button.js +20 -20
- package/src/components/modules/cards/default.js +167 -167
- package/src/components/modules/cards/filter.js +56 -56
- package/src/components/modules/dialogs/apply-dialog.js +48 -48
- package/src/components/modules/filter/commute.js +154 -149
- package/src/components/modules/filter/index.js +89 -87
- package/src/components/modules/filter/item.js +87 -76
- package/src/components/modules/filter/location.js +71 -71
- package/src/components/modules/filter/points-of-interest.js +44 -44
- package/src/components/modules/filter/radio-item.js +57 -53
- package/src/components/modules/filter/search.js +92 -92
- package/src/components/modules/filter/sort.js +83 -83
- package/src/components/modules/grid.js +54 -54
- package/src/components/modules/icon.js +33 -33
- package/src/components/modules/jobListing/listing-details.js +99 -95
- package/src/components/modules/maps/info-window-card.js +17 -17
- package/src/components/modules/maps/info-window-content.js +81 -74
- package/src/components/modules/maps/list/field-mapper.js +112 -112
- package/src/components/modules/maps/list/header-item.js +91 -91
- package/src/components/modules/maps/list/header.js +47 -47
- package/src/components/modules/maps/list/index.js +112 -107
- package/src/components/modules/maps/list/item-expand-card/index.js +22 -22
- package/src/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js +50 -50
- package/src/components/modules/maps/list/item-expand-card/recruiter-details.js +68 -68
- package/src/components/modules/maps/list/item-expand-card/recruiter-headshot.js +22 -22
- package/src/components/modules/maps/list/list-item/index.js +135 -133
- package/src/components/modules/maps/map-list.js +74 -74
- package/src/components/modules/maps/map-marker.js +88 -86
- package/src/components/modules/maps/map.js +230 -230
- package/src/components/modules/maps/place-marker.js +41 -41
- package/src/components/modules/maps/tabs.js +81 -81
- package/src/constants/eventTypes.js +13 -0
- package/src/constants/placeTypes.js +8 -8
- package/src/contexts/mapContext.js +101 -115
- package/src/contexts/mapListContext.js +242 -222
- package/src/contexts/placesContext.js +102 -102
- package/src/contexts/trackEventContext.js +14 -0
- package/src/hooks/useList.js +89 -100
- package/src/index.js +3 -3
- package/src/services/configService.js +16 -16
- package/src/services/googlePlacesNearbyService.js +33 -33
- package/src/services/listingAggregatorService.js +50 -45
- package/src/services/listingEntityService.js +15 -15
- package/src/services/listingService.js +26 -26
- package/src/services/recruiterService.js +17 -17
- package/src/styles/index.css +23 -23
- package/src/util/arrayUtil.js +3 -3
- package/src/util/fieldMapper.js +22 -22
- package/src/util/filterUtil.js +195 -195
- package/src/util/loading.js +17 -17
- package/src/util/localStorageUtil.js +26 -26
- package/src/util/mapIconUtil.js +180 -180
- package/src/util/mapUtil.js +91 -91
- package/src/util/sortUtil.js +32 -32
- package/src/util/stringUtils.js +6 -6
- package/src/util/urlFilterUtil.js +90 -90
- package/tailwind.config.js +126 -126
- package/.editorconfig +0 -12
- package/.eslintrc +0 -105
- package/.prettierignore +0 -3
|
@@ -1,116 +1,123 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { twMerge } from 'tailwind-merge';
|
|
3
|
-
|
|
4
|
-
import Button from '~/components/modules/buttons/default';
|
|
5
|
-
import ApplyDialog from '../dialogs/apply-dialog';
|
|
6
|
-
|
|
7
|
-
const ButtonGroupApply = ({
|
|
8
|
-
applyUrl,
|
|
9
|
-
useDetailsPostMessage,
|
|
10
|
-
navigateToDetails,
|
|
11
|
-
navigateToEasyApply,
|
|
12
|
-
Link,
|
|
13
|
-
linkFormat,
|
|
14
|
-
applyText = 'Apply Now',
|
|
15
|
-
detailsUrl,
|
|
16
|
-
detailsText = 'View Details',
|
|
17
|
-
className,
|
|
18
|
-
buttonSize = 'sm',
|
|
19
|
-
applyButtonVariant = 'primary',
|
|
20
|
-
detailsButtonVariant = 'outline',
|
|
21
|
-
includeDialog = false,
|
|
22
|
-
internalApplyLink,
|
|
23
|
-
itemId,
|
|
24
|
-
item,
|
|
25
|
-
companyName
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { twMerge } from 'tailwind-merge';
|
|
3
|
+
|
|
4
|
+
import Button from '~/components/modules/buttons/default';
|
|
5
|
+
import ApplyDialog from '../dialogs/apply-dialog';
|
|
6
|
+
|
|
7
|
+
const ButtonGroupApply = ({
|
|
8
|
+
applyUrl,
|
|
9
|
+
useDetailsPostMessage,
|
|
10
|
+
navigateToDetails,
|
|
11
|
+
navigateToEasyApply,
|
|
12
|
+
Link,
|
|
13
|
+
linkFormat,
|
|
14
|
+
applyText = 'Apply Now',
|
|
15
|
+
detailsUrl,
|
|
16
|
+
detailsText = 'View Details',
|
|
17
|
+
className,
|
|
18
|
+
buttonSize = 'sm',
|
|
19
|
+
applyButtonVariant = 'primary',
|
|
20
|
+
detailsButtonVariant = 'outline',
|
|
21
|
+
includeDialog = false,
|
|
22
|
+
internalApplyLink,
|
|
23
|
+
itemId,
|
|
24
|
+
item,
|
|
25
|
+
companyName,
|
|
26
|
+
trackEvent,
|
|
27
|
+
eventTypes
|
|
28
|
+
}) => {
|
|
29
|
+
const href = linkFormat.replace('[slug]', item.slug ?? item.id);
|
|
30
|
+
|
|
31
|
+
const trackApply = () => {
|
|
32
|
+
trackEvent(eventTypes.APPLY_NOW_CLICKED, { jobTitle: item.fields.position, jobCategory: item.fields.category, entityDisplayName: item?.mapDetails?.entityDisplayName });
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const trackViewDetails = () => {
|
|
36
|
+
trackEvent(eventTypes.VIEW_DETAILS_CLICKED, { jobTitle: item.fields.position, jobCategory: item.fields.category, entityDisplayName: item?.mapDetails?.entityDisplayName });
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<nav
|
|
41
|
+
className={twMerge`
|
|
42
|
+
hc-flex hc-flex-row hc-justify-between hc-gap-2 hc-w-full
|
|
43
|
+
${className ?? ''}
|
|
44
|
+
`}
|
|
45
|
+
>
|
|
46
|
+
{Link &&
|
|
47
|
+
<Button.Link
|
|
48
|
+
Link={Link}
|
|
49
|
+
href={href}
|
|
50
|
+
variant={detailsButtonVariant}
|
|
51
|
+
size={buttonSize}
|
|
52
|
+
onClick={trackViewDetails}
|
|
53
|
+
>
|
|
54
|
+
{detailsText}
|
|
55
|
+
</Button.Link>
|
|
56
|
+
}
|
|
57
|
+
{navigateToDetails &&
|
|
58
|
+
<Button.Anchor
|
|
59
|
+
href={href}
|
|
60
|
+
onClick={e => {
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
navigateToDetails(item);
|
|
63
|
+
trackViewDetails();
|
|
64
|
+
}}
|
|
65
|
+
variant={detailsButtonVariant}
|
|
66
|
+
size={buttonSize}
|
|
67
|
+
>
|
|
68
|
+
{detailsText}
|
|
69
|
+
</Button.Anchor>
|
|
70
|
+
}
|
|
71
|
+
{detailsUrl && useDetailsPostMessage !== true && navigateToDetails === null &&
|
|
72
|
+
<Button.Anchor
|
|
73
|
+
href={detailsUrl}
|
|
74
|
+
variant={detailsButtonVariant}
|
|
75
|
+
size={buttonSize}
|
|
76
|
+
onClick={trackViewDetails}
|
|
77
|
+
>
|
|
78
|
+
{detailsText}
|
|
79
|
+
</Button.Anchor>
|
|
80
|
+
}
|
|
81
|
+
{useDetailsPostMessage === true && navigateToDetails === null &&
|
|
82
|
+
<Button.Btn
|
|
83
|
+
onClick={() => {trackViewDetails; window.parent.postMessage({ itemId: itemId, type: 'LISTING_ID' }, '*'); }}
|
|
84
|
+
variant={detailsButtonVariant}
|
|
85
|
+
size={buttonSize}
|
|
86
|
+
>
|
|
87
|
+
{detailsText}
|
|
88
|
+
</Button.Btn>}
|
|
89
|
+
{applyUrl && !includeDialog && navigateToEasyApply == null &&
|
|
90
|
+
<Button.Anchor
|
|
91
|
+
href={applyUrl}
|
|
92
|
+
variant={applyButtonVariant}
|
|
93
|
+
size={buttonSize}
|
|
94
|
+
onClick={trackApply}
|
|
95
|
+
>
|
|
96
|
+
{applyText}
|
|
97
|
+
</Button.Anchor>
|
|
98
|
+
}
|
|
99
|
+
{applyUrl && !includeDialog && navigateToEasyApply != null &&
|
|
100
|
+
<Button.Btn
|
|
101
|
+
onClick={() => { navigateToEasyApply(item); trackApply(); }}
|
|
102
|
+
variant={applyButtonVariant}
|
|
103
|
+
size={buttonSize}
|
|
104
|
+
>
|
|
105
|
+
{applyText}
|
|
106
|
+
</Button.Btn>
|
|
107
|
+
}
|
|
108
|
+
{applyUrl && includeDialog &&
|
|
109
|
+
<ApplyDialog applyUrl={applyUrl} internalApplyLink={internalApplyLink} companyName={companyName}>
|
|
110
|
+
<Button.Anchor
|
|
111
|
+
variant={applyButtonVariant}
|
|
112
|
+
size={buttonSize}
|
|
113
|
+
onClick={trackApply}
|
|
114
|
+
>
|
|
115
|
+
{applyText}
|
|
116
|
+
</Button.Anchor>
|
|
117
|
+
</ApplyDialog>
|
|
118
|
+
}
|
|
119
|
+
</nav>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export default ButtonGroupApply;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import Icon from '~/components/modules/icon';
|
|
4
|
-
import PillWrapper from '~/components/modules/buttons/pill-wrapper';
|
|
5
|
-
|
|
6
|
-
const CommutePill = ({ travelTime }) => {
|
|
7
|
-
if (!travelTime) return;
|
|
8
|
-
return (
|
|
9
|
-
<div className="pt-2">
|
|
10
|
-
<PillWrapper >
|
|
11
|
-
<Icon
|
|
12
|
-
icon="ri:pin-distance-fill"
|
|
13
|
-
size="hc-size-5"
|
|
14
|
-
className="hc-text-uiAccent/30"
|
|
15
|
-
/>
|
|
16
|
-
commute time = {travelTime}
|
|
17
|
-
</PillWrapper>
|
|
18
|
-
</div>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default CommutePill;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import Icon from '~/components/modules/icon';
|
|
4
|
+
import PillWrapper from '~/components/modules/buttons/pill-wrapper';
|
|
5
|
+
|
|
6
|
+
const CommutePill = ({ travelTime }) => {
|
|
7
|
+
if (!travelTime) return;
|
|
8
|
+
return (
|
|
9
|
+
<div className="pt-2">
|
|
10
|
+
<PillWrapper >
|
|
11
|
+
<Icon
|
|
12
|
+
icon="ri:pin-distance-fill"
|
|
13
|
+
size="hc-size-5"
|
|
14
|
+
className="hc-text-uiAccent/30"
|
|
15
|
+
/>
|
|
16
|
+
commute time = {travelTime}
|
|
17
|
+
</PillWrapper>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default CommutePill;
|
|
@@ -1,194 +1,194 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { forwardRef } from 'react';
|
|
3
|
-
import { Link } from 'react-router-dom';
|
|
4
|
-
import { twMerge } from 'tailwind-merge';
|
|
5
|
-
|
|
6
|
-
import Icon from '~/components/modules/icon';
|
|
7
|
-
|
|
8
|
-
const linkDefaultClasses = "hc-normal-case hc-text-inherit !hc-font-[inherit] hc-[font-weight:inherit] !hc-p-0 hc-rounded-none";
|
|
9
|
-
const underlineClasses = "!underline decoration-1 underline-offset-2 hover:!no-underline focus:!no-underline";
|
|
10
|
-
|
|
11
|
-
const ButtonVariant = {
|
|
12
|
-
none: '',
|
|
13
|
-
primary: 'hc-bg-primary hc-border hc-border-primary hc-text-white hover:hc-bg-opacity-70 focus:hc-bg-opacity-70',
|
|
14
|
-
secondary: 'hc-bg-secondary hc-border hc-border-secondary hc-text-white hover:hc-bg-opacity-70 focus:hc-bg-opacity-70',
|
|
15
|
-
outline: 'hc-bg-transparent hc-border hc-border-primary hc-text-primary hover:hc-bg-primaryDark hover:hc-border-primaryDark hover:hc-text-white focus:hc-bg-primaryDark focus:hc-border-primaryDark focus:hc-text-white',
|
|
16
|
-
link: `${linkDefaultClasses} hc-text-primary hover:hc-text-uiText focus:hc-text-uiText`,
|
|
17
|
-
icon: 'hc-opacity-100 hover:hc-opacity-70 focus:hc-opacity-70'
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const ButtonSize = {
|
|
21
|
-
none: '',
|
|
22
|
-
default: 'hc-py-2 hc-px-6 hc-text-base',
|
|
23
|
-
sq: 'hc-p-2.5',
|
|
24
|
-
sqsm: 'hc-p-1',
|
|
25
|
-
xs: 'hc-py-1.5 hc-px-3 hc-text-xs',
|
|
26
|
-
sm: 'hc-py-1.5 hc-px-4 hc-text-sm',
|
|
27
|
-
lg: 'hc-py-4 hc-px-10 hc-text-lg'
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const ButtonDefaults = {
|
|
31
|
-
style: 'hc-group hc-font-medium hc-uppercase hc-text-center hc-rounded hc-transition',
|
|
32
|
-
size: ButtonSize.default,
|
|
33
|
-
variant: ButtonVariant.primary,
|
|
34
|
-
block: 'hc-block hc-w-full'
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const linkVariants = variant => variant === 'link';
|
|
38
|
-
|
|
39
|
-
const buttonClasses = (variant, size, isBlock, hasUnderline, className) => twMerge(
|
|
40
|
-
isBlock ? ButtonDefaults.block : linkVariants(variant) ? 'hc-inline' : 'hc-inline-block',
|
|
41
|
-
ButtonDefaults.style,
|
|
42
|
-
variant ? ButtonVariant[variant] : ButtonDefaults.variant,
|
|
43
|
-
size ? ButtonSize[size] : ButtonDefaults.size,
|
|
44
|
-
hasUnderline ? underlineClasses : '',
|
|
45
|
-
className ?? ''
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
const Button = ({
|
|
49
|
-
children
|
|
50
|
-
}) => {
|
|
51
|
-
return (
|
|
52
|
-
{ children }
|
|
53
|
-
);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const Anchor = ({
|
|
57
|
-
children,
|
|
58
|
-
href,
|
|
59
|
-
className,
|
|
60
|
-
size,
|
|
61
|
-
variant,
|
|
62
|
-
isBlock,
|
|
63
|
-
hasUnderline,
|
|
64
|
-
target = '_blank',
|
|
65
|
-
...rest
|
|
66
|
-
}) => {
|
|
67
|
-
return (
|
|
68
|
-
<a
|
|
69
|
-
href={href}
|
|
70
|
-
target={target}
|
|
71
|
-
className={buttonClasses(variant, size, isBlock, hasUnderline, className)}
|
|
72
|
-
onClick={href === '#' ? e => {
|
|
73
|
-
e.preventDefault();
|
|
74
|
-
} : null}
|
|
75
|
-
{...rest}
|
|
76
|
-
>
|
|
77
|
-
{children}
|
|
78
|
-
</a>
|
|
79
|
-
);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export const AnchorLink = ({
|
|
83
|
-
children,
|
|
84
|
-
Link,
|
|
85
|
-
href,
|
|
86
|
-
className,
|
|
87
|
-
size,
|
|
88
|
-
variant,
|
|
89
|
-
isBlock,
|
|
90
|
-
hasUnderline,
|
|
91
|
-
...rest
|
|
92
|
-
}) => {
|
|
93
|
-
return (
|
|
94
|
-
<Link
|
|
95
|
-
href={href}
|
|
96
|
-
className={`
|
|
97
|
-
${buttonClasses(variant, size, isBlock, hasUnderline, className)}
|
|
98
|
-
`}
|
|
99
|
-
{...rest}
|
|
100
|
-
>
|
|
101
|
-
{children}
|
|
102
|
-
</Link>
|
|
103
|
-
);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export const ScrollAnchor = forwardRef((props, ref) => {
|
|
107
|
-
const {
|
|
108
|
-
children,
|
|
109
|
-
href,
|
|
110
|
-
className,
|
|
111
|
-
size,
|
|
112
|
-
variant,
|
|
113
|
-
isBlock,
|
|
114
|
-
hasUnderline,
|
|
115
|
-
...rest
|
|
116
|
-
} = props;
|
|
117
|
-
|
|
118
|
-
return (
|
|
119
|
-
<Link
|
|
120
|
-
ref={ref}
|
|
121
|
-
href={`#${href}`}
|
|
122
|
-
scroll={false}
|
|
123
|
-
className={buttonClasses(variant, size, isBlock, hasUnderline, className)}
|
|
124
|
-
{...rest}
|
|
125
|
-
>
|
|
126
|
-
{children}
|
|
127
|
-
</Link>
|
|
128
|
-
);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
export const Btn = forwardRef((props, ref) => {
|
|
132
|
-
const {
|
|
133
|
-
children,
|
|
134
|
-
type = 'button',
|
|
135
|
-
className,
|
|
136
|
-
size,
|
|
137
|
-
variant,
|
|
138
|
-
isBlock,
|
|
139
|
-
hasUnderline,
|
|
140
|
-
...rest
|
|
141
|
-
} = props;
|
|
142
|
-
return (
|
|
143
|
-
<button
|
|
144
|
-
ref={ref}
|
|
145
|
-
type={type}
|
|
146
|
-
className={buttonClasses(variant, size, isBlock, hasUnderline, className)}
|
|
147
|
-
{...rest}
|
|
148
|
-
>
|
|
149
|
-
{children}
|
|
150
|
-
</button>
|
|
151
|
-
);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
export const ButtonBody = ({
|
|
155
|
-
children,
|
|
156
|
-
className
|
|
157
|
-
}) => {
|
|
158
|
-
return (
|
|
159
|
-
<span
|
|
160
|
-
className={twMerge(
|
|
161
|
-
'hc-inline-flex hc-w-full hc-items-center hc-justify-between hc-gap-1.5',
|
|
162
|
-
className ?? ''
|
|
163
|
-
)}
|
|
164
|
-
>
|
|
165
|
-
{children}
|
|
166
|
-
</span>
|
|
167
|
-
);
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
export const ButtonIcon = ({
|
|
171
|
-
icon,
|
|
172
|
-
size = 'hc-size-4',
|
|
173
|
-
className
|
|
174
|
-
}) => {
|
|
175
|
-
return (
|
|
176
|
-
<Icon
|
|
177
|
-
|
|
178
|
-
icon={icon}
|
|
179
|
-
size={size}
|
|
180
|
-
className={className ?? ''}
|
|
181
|
-
/>
|
|
182
|
-
);
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
Button.Anchor = Anchor;
|
|
186
|
-
Button.Link = AnchorLink;
|
|
187
|
-
Button.Scroll = ScrollAnchor;
|
|
188
|
-
Button.Btn = Btn;
|
|
189
|
-
Button.Body = ButtonBody;
|
|
190
|
-
Button.Icon = ButtonIcon;
|
|
191
|
-
|
|
192
|
-
Btn.displayName = 'Button:Button';
|
|
193
|
-
ScrollAnchor.displayName = 'Button:ScrollAnchor';
|
|
194
|
-
export default Button;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
|
+
import { twMerge } from 'tailwind-merge';
|
|
5
|
+
|
|
6
|
+
import Icon from '~/components/modules/icon';
|
|
7
|
+
|
|
8
|
+
const linkDefaultClasses = "hc-normal-case hc-text-inherit !hc-font-[inherit] hc-[font-weight:inherit] !hc-p-0 hc-rounded-none";
|
|
9
|
+
const underlineClasses = "!underline decoration-1 underline-offset-2 hover:!no-underline focus:!no-underline";
|
|
10
|
+
|
|
11
|
+
const ButtonVariant = {
|
|
12
|
+
none: '',
|
|
13
|
+
primary: 'hc-bg-primary hc-border hc-border-primary hc-text-white hover:hc-bg-opacity-70 focus:hc-bg-opacity-70',
|
|
14
|
+
secondary: 'hc-bg-secondary hc-border hc-border-secondary hc-text-white hover:hc-bg-opacity-70 focus:hc-bg-opacity-70',
|
|
15
|
+
outline: 'hc-bg-transparent hc-border hc-border-primary hc-text-primary hover:hc-bg-primaryDark hover:hc-border-primaryDark hover:hc-text-white focus:hc-bg-primaryDark focus:hc-border-primaryDark focus:hc-text-white',
|
|
16
|
+
link: `${linkDefaultClasses} hc-text-primary hover:hc-text-uiText focus:hc-text-uiText`,
|
|
17
|
+
icon: 'hc-opacity-100 hover:hc-opacity-70 focus:hc-opacity-70'
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const ButtonSize = {
|
|
21
|
+
none: '',
|
|
22
|
+
default: 'hc-py-2 hc-px-6 hc-text-base',
|
|
23
|
+
sq: 'hc-p-2.5',
|
|
24
|
+
sqsm: 'hc-p-1',
|
|
25
|
+
xs: 'hc-py-1.5 hc-px-3 hc-text-xs',
|
|
26
|
+
sm: 'hc-py-1.5 hc-px-4 hc-text-sm',
|
|
27
|
+
lg: 'hc-py-4 hc-px-10 hc-text-lg'
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const ButtonDefaults = {
|
|
31
|
+
style: 'hc-group hc-font-medium hc-uppercase hc-text-center hc-rounded hc-transition',
|
|
32
|
+
size: ButtonSize.default,
|
|
33
|
+
variant: ButtonVariant.primary,
|
|
34
|
+
block: 'hc-block hc-w-full'
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const linkVariants = variant => variant === 'link';
|
|
38
|
+
|
|
39
|
+
const buttonClasses = (variant, size, isBlock, hasUnderline, className) => twMerge(
|
|
40
|
+
isBlock ? ButtonDefaults.block : linkVariants(variant) ? 'hc-inline' : 'hc-inline-block',
|
|
41
|
+
ButtonDefaults.style,
|
|
42
|
+
variant ? ButtonVariant[variant] : ButtonDefaults.variant,
|
|
43
|
+
size ? ButtonSize[size] : ButtonDefaults.size,
|
|
44
|
+
hasUnderline ? underlineClasses : '',
|
|
45
|
+
className ?? ''
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const Button = ({
|
|
49
|
+
children
|
|
50
|
+
}) => {
|
|
51
|
+
return (
|
|
52
|
+
{ children }
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const Anchor = ({
|
|
57
|
+
children,
|
|
58
|
+
href,
|
|
59
|
+
className,
|
|
60
|
+
size,
|
|
61
|
+
variant,
|
|
62
|
+
isBlock,
|
|
63
|
+
hasUnderline,
|
|
64
|
+
target = '_blank',
|
|
65
|
+
...rest
|
|
66
|
+
}) => {
|
|
67
|
+
return (
|
|
68
|
+
<a
|
|
69
|
+
href={href}
|
|
70
|
+
target={target}
|
|
71
|
+
className={buttonClasses(variant, size, isBlock, hasUnderline, className)}
|
|
72
|
+
onClick={href === '#' ? e => {
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
} : null}
|
|
75
|
+
{...rest}
|
|
76
|
+
>
|
|
77
|
+
{children}
|
|
78
|
+
</a>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const AnchorLink = ({
|
|
83
|
+
children,
|
|
84
|
+
Link,
|
|
85
|
+
href,
|
|
86
|
+
className,
|
|
87
|
+
size,
|
|
88
|
+
variant,
|
|
89
|
+
isBlock,
|
|
90
|
+
hasUnderline,
|
|
91
|
+
...rest
|
|
92
|
+
}) => {
|
|
93
|
+
return (
|
|
94
|
+
<Link
|
|
95
|
+
href={href}
|
|
96
|
+
className={`
|
|
97
|
+
${buttonClasses(variant, size, isBlock, hasUnderline, className)}
|
|
98
|
+
`}
|
|
99
|
+
{...rest}
|
|
100
|
+
>
|
|
101
|
+
{children}
|
|
102
|
+
</Link>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const ScrollAnchor = forwardRef((props, ref) => {
|
|
107
|
+
const {
|
|
108
|
+
children,
|
|
109
|
+
href,
|
|
110
|
+
className,
|
|
111
|
+
size,
|
|
112
|
+
variant,
|
|
113
|
+
isBlock,
|
|
114
|
+
hasUnderline,
|
|
115
|
+
...rest
|
|
116
|
+
} = props;
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<Link
|
|
120
|
+
ref={ref}
|
|
121
|
+
href={`#${href}`}
|
|
122
|
+
scroll={false}
|
|
123
|
+
className={buttonClasses(variant, size, isBlock, hasUnderline, className)}
|
|
124
|
+
{...rest}
|
|
125
|
+
>
|
|
126
|
+
{children}
|
|
127
|
+
</Link>
|
|
128
|
+
);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
export const Btn = forwardRef((props, ref) => {
|
|
132
|
+
const {
|
|
133
|
+
children,
|
|
134
|
+
type = 'button',
|
|
135
|
+
className,
|
|
136
|
+
size,
|
|
137
|
+
variant,
|
|
138
|
+
isBlock,
|
|
139
|
+
hasUnderline,
|
|
140
|
+
...rest
|
|
141
|
+
} = props;
|
|
142
|
+
return (
|
|
143
|
+
<button
|
|
144
|
+
ref={ref}
|
|
145
|
+
type={type}
|
|
146
|
+
className={buttonClasses(variant, size, isBlock, hasUnderline, className)}
|
|
147
|
+
{...rest}
|
|
148
|
+
>
|
|
149
|
+
{children}
|
|
150
|
+
</button>
|
|
151
|
+
);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
export const ButtonBody = ({
|
|
155
|
+
children,
|
|
156
|
+
className
|
|
157
|
+
}) => {
|
|
158
|
+
return (
|
|
159
|
+
<span
|
|
160
|
+
className={twMerge(
|
|
161
|
+
'hc-inline-flex hc-w-full hc-items-center hc-justify-between hc-gap-1.5',
|
|
162
|
+
className ?? ''
|
|
163
|
+
)}
|
|
164
|
+
>
|
|
165
|
+
{children}
|
|
166
|
+
</span>
|
|
167
|
+
);
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export const ButtonIcon = ({
|
|
171
|
+
icon,
|
|
172
|
+
size = 'hc-size-4',
|
|
173
|
+
className
|
|
174
|
+
}) => {
|
|
175
|
+
return (
|
|
176
|
+
<Icon
|
|
177
|
+
|
|
178
|
+
icon={icon}
|
|
179
|
+
size={size}
|
|
180
|
+
className={className ?? ''}
|
|
181
|
+
/>
|
|
182
|
+
);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
Button.Anchor = Anchor;
|
|
186
|
+
Button.Link = AnchorLink;
|
|
187
|
+
Button.Scroll = ScrollAnchor;
|
|
188
|
+
Button.Btn = Btn;
|
|
189
|
+
Button.Body = ButtonBody;
|
|
190
|
+
Button.Icon = ButtonIcon;
|
|
191
|
+
|
|
192
|
+
Btn.displayName = 'Button:Button';
|
|
193
|
+
ScrollAnchor.displayName = 'Button:ScrollAnchor';
|
|
194
|
+
export default Button;
|