@envive-ai/react-toolkit 0.3.66 → 0.3.68
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/components/Accordion/Accordion.d.cts +2 -2
- package/dist/components/Accordion/Accordion.d.ts +2 -2
- package/dist/components/AnimatedChevron/AnimatedChevron.d.cts +2 -2
- package/dist/components/AnimatedChevron/AnimatedChevron.d.ts +2 -2
- package/dist/components/AppliedFiltersScrollbar/AppliedFiltersScrollbar.d.cts +2 -2
- package/dist/components/AppliedFiltersScrollbar/AppliedFiltersScrollbar.d.ts +2 -2
- package/dist/components/ButtonBase/ButtonBase.cjs +3 -1
- package/dist/components/ButtonBase/ButtonBase.d.cts +5 -3
- package/dist/components/ButtonBase/ButtonBase.d.ts +5 -3
- package/dist/components/ButtonBase/ButtonBase.js +3 -1
- package/dist/components/ButtonBase/types.d.cts +4 -0
- package/dist/components/ButtonBase/types.d.ts +4 -0
- package/dist/components/DynamicFiltersScrollbar/DynamicFiltersScrollbar.d.cts +2 -2
- package/dist/components/DynamicFiltersScrollbar/DynamicFiltersScrollbar.d.ts +2 -2
- package/dist/components/FilterScrollbar/AppliedFiltersScrollbar.d.cts +2 -2
- package/dist/components/FilterScrollbar/AppliedFiltersScrollbar.d.ts +2 -2
- package/dist/components/FilterScrollbar/DynamicFiltersScrollbar.d.cts +2 -2
- package/dist/components/FilterScrollbar/DynamicFiltersScrollbar.d.ts +2 -2
- package/dist/components/ImageWithFallback/ImageWithFallback.d.cts +2 -2
- package/dist/components/ImageWithFallback/ImageWithFallback.d.ts +2 -2
- package/dist/components/ModalSheet/ModalSheet.d.cts +2 -2
- package/dist/components/ModalSheet/ModalSheet.d.ts +2 -2
- package/dist/components/ProductCard/ProductCard.d.cts +4 -4
- package/dist/components/ProductCard/ProductCard.d.ts +4 -4
- package/dist/components/ProductGrid/ProductGrid.cjs +1 -1
- package/dist/components/ProductGrid/ProductGrid.d.cts +2 -2
- package/dist/components/ProductGrid/ProductGrid.d.ts +2 -2
- package/dist/components/ProductGrid/ProductGrid.js +1 -1
- package/dist/components/RadioButton/RadioButton.d.cts +2 -2
- package/dist/components/RadioButton/RadioButton.d.ts +2 -2
- package/dist/components/RadioButtonGroup/RadioButtonGroup.d.cts +2 -2
- package/dist/components/RadioButtonGroup/RadioButtonGroup.d.ts +2 -2
- package/dist/components/SearchAutocomplete/SearchAutocomplete.d.cts +2 -2
- package/dist/components/SearchFilter/SearchFilter.d.cts +2 -2
- package/dist/components/SearchFilter/SearchFilter.d.ts +2 -2
- package/dist/components/SearchFilter/SearchFilterFooter.d.cts +2 -2
- package/dist/components/SearchFilter/SearchFilterFooter.d.ts +2 -2
- package/dist/components/SearchFilter/SearchFilterHeader.d.cts +2 -2
- package/dist/components/SearchFilter/SearchFilterHeader.d.ts +2 -2
- package/dist/components/SearchFilter/SearchFilterItem.d.cts +2 -2
- package/dist/components/SearchFilter/SearchFilterItem.d.ts +2 -2
- package/dist/components/SearchInputForm/SearchInputForm.d.cts +2 -2
- package/dist/components/SearchResultsContent/SearchResultsContent.d.ts +2 -2
- package/dist/components/SearchResultsFilterButton/SearchResultsFilterButton.d.cts +2 -2
- package/dist/components/SearchResultsFilterButton/SearchResultsFilterButton.d.ts +2 -2
- package/dist/components/SearchResultsFilterModal/SearchResultsFilterModal.d.ts +2 -2
- package/dist/components/SearchResultsFilterSidebar/SearchResultsFilter.d.cts +2 -2
- package/dist/components/SearchResultsFilterSidebar/SearchResultsFilter.d.ts +2 -2
- package/dist/components/SearchResultsStates/NoSearchResultsFound.d.cts +2 -2
- package/dist/components/SearchResultsStates/NoSearchResultsFound.d.ts +2 -2
- package/dist/components/SearchResultsStates/SearchResultsGrid.d.cts +2 -2
- package/dist/components/SearchResultsStates/SearchResultsGrid.d.ts +2 -2
- package/dist/components/SearchResultsStates/SearchResultsLoadingGrid.cjs +1 -1
- package/dist/components/SearchResultsStates/SearchResultsLoadingGrid.d.cts +2 -2
- package/dist/components/SearchResultsStates/SearchResultsLoadingGrid.d.ts +2 -2
- package/dist/components/SearchResultsStates/SearchResultsLoadingGrid.js +1 -1
- package/dist/components/SearchResultsToolbar/SearchResultsToolbar.d.cts +2 -2
- package/dist/components/SearchResultsToolbar/SearchResultsToolbar.d.ts +2 -2
- package/dist/components/SparkleAnimation/SparkleAnimation.d.cts +2 -2
- package/dist/components/SparkleAnimation/SparkleAnimation.d.ts +2 -2
- package/dist/components/Spinner/Spinner.d.cts +2 -2
- package/dist/components/SuggestionButton/SuggestionButton.cjs +8 -138
- package/dist/components/SuggestionButton/SuggestionButton.d.cts +7 -3
- package/dist/components/SuggestionButton/SuggestionButton.d.ts +7 -3
- package/dist/components/SuggestionButton/SuggestionButton.js +6 -136
- package/dist/components/SuggestionButton/index.cjs +3 -1
- package/dist/components/SuggestionButton/index.d.cts +2 -1
- package/dist/components/SuggestionButton/index.d.ts +2 -1
- package/dist/components/SuggestionButton/index.js +2 -1
- package/dist/components/SuggestionButton/variantClasses.cjs +148 -0
- package/dist/components/SuggestionButton/variantClasses.d.cts +12 -0
- package/dist/components/SuggestionButton/variantClasses.d.ts +12 -0
- package/dist/components/SuggestionButton/variantClasses.js +146 -0
- package/dist/components/ToggleButton/ToggleButton.d.cts +2 -2
- package/package.json +1 -1
- package/src/components/ButtonBase/ButtonBase.tsx +4 -0
- package/src/components/ButtonBase/types.ts +4 -0
- package/src/components/SuggestionButton/SuggestionButton.tsx +9 -190
- package/src/components/SuggestionButton/index.ts +1 -0
- package/src/components/SuggestionButton/variantClasses.ts +204 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ButtonBase } from "../ButtonBase/ButtonBase.js";
|
|
2
|
+
import { borderedVariants, getSuggestionButtonVariantClasses } from "./variantClasses.js";
|
|
2
3
|
import classNames from "classnames";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
5
|
import OutlinedStar from "@envive-ai/react-icons/OutlinedStar";
|
|
@@ -8,134 +9,12 @@ import FourPointStar from "@envive-ai/react-icons/FourPointStar";
|
|
|
8
9
|
const SPIFFY_SUGGESTION_BUTTON_QUESTION_CLASS = "spiffy-suggestion-button-question-class";
|
|
9
10
|
const SPIFFY_SUGGESTION_BUTTON_ANSWER_CLASS = "spiffy-suggestion-button-answer-class";
|
|
10
11
|
const SPIFFY_SUGGESTION_BUTTON_TEXT_CLASS = "spiffy-suggestion-button-text-class";
|
|
11
|
-
const BORDER_CLASS = "spiffy-tw-border";
|
|
12
|
-
const TEXT_LINK_CLASSES = [
|
|
13
|
-
"spiffy-tw-text-[--spiffy-colors-text-link]",
|
|
14
|
-
"spiffy-tw-fill-[--spiffy-colors-text-link]",
|
|
15
|
-
"spiffy-tw-stroke-[--spiffy-colors-text-link]"
|
|
16
|
-
];
|
|
17
|
-
const TEXT_LIGHT_CLASSES = [
|
|
18
|
-
"spiffy-tw-text-[--spiffy-colors-text-light]",
|
|
19
|
-
"spiffy-tw-fill-[--spiffy-colors-text-light]",
|
|
20
|
-
"spiffy-tw-stroke-[--spiffy-colors-text-light]"
|
|
21
|
-
];
|
|
22
|
-
const TEXT_PRIMARY_CLASSES = [
|
|
23
|
-
"spiffy-tw-text-[--spiffy-colors-text-primary]",
|
|
24
|
-
"spiffy-tw-fill-[--spiffy-colors-text-primary]",
|
|
25
|
-
"spiffy-tw-stroke-[--spiffy-colors-text-primary]"
|
|
26
|
-
];
|
|
27
|
-
const ACCENT_PRIMARY_CLASSES = ["spiffy-tw-fill-[--spiffy-colors-accent-primary]", "spiffy-tw-stroke-[--spiffy-colors-accent-primary]"];
|
|
28
|
-
const DARK_BACKGROUND_CLASSES = ["spiffy-tw-bg-[--spiffy-colors-background-dark]", "spiffy-tw-border-[--spiffy-colors-background-dark]"];
|
|
29
|
-
const SECONDARY_DARK_BACKGROUND_CLASSES = ["spiffy-tw-bg-[--spiffy-colors-background-secondary-dark]", "spiffy-tw-border-[--spiffy-colors-background-secondary-dark]"];
|
|
30
|
-
const variantClassMap = new Map([
|
|
31
|
-
["outlined", ["spiffy-tw-border-[--spiffy-colors-border-outline]", ...TEXT_LINK_CLASSES]],
|
|
32
|
-
["outlinedLight", [
|
|
33
|
-
"spiffy-tw-border-[--spiffy-colors-border-outline]",
|
|
34
|
-
"spiffy-tw-bg-[--spiffy-colors-background-light]",
|
|
35
|
-
...TEXT_LINK_CLASSES,
|
|
36
|
-
BORDER_CLASS
|
|
37
|
-
]],
|
|
38
|
-
["primary", [
|
|
39
|
-
"spiffy-tw-bg-[--spiffy-colors-background-primary]",
|
|
40
|
-
"spiffy-tw-border-[--spiffy-colors-background-primary]",
|
|
41
|
-
...TEXT_LIGHT_CLASSES,
|
|
42
|
-
BORDER_CLASS
|
|
43
|
-
]],
|
|
44
|
-
["secondary", [
|
|
45
|
-
"spiffy-tw-bg-[--spiffy-colors-background-secondary]",
|
|
46
|
-
"spiffy-tw-text-[--spiffy-colors-text-link]",
|
|
47
|
-
"spiffy-tw-border-[--spiffy-colors-background-secondary]",
|
|
48
|
-
...ACCENT_PRIMARY_CLASSES,
|
|
49
|
-
BORDER_CLASS
|
|
50
|
-
]],
|
|
51
|
-
["tertiary", [
|
|
52
|
-
"spiffy-tw-bg-[--spiffy-colors-background-tertiary]",
|
|
53
|
-
"spiffy-tw-border-[--spiffy-colors-background-tertiary]",
|
|
54
|
-
...TEXT_LINK_CLASSES,
|
|
55
|
-
BORDER_CLASS
|
|
56
|
-
]],
|
|
57
|
-
["dark", [
|
|
58
|
-
...DARK_BACKGROUND_CLASSES,
|
|
59
|
-
...TEXT_LIGHT_CLASSES,
|
|
60
|
-
BORDER_CLASS
|
|
61
|
-
]],
|
|
62
|
-
["darkPrimary", [
|
|
63
|
-
...DARK_BACKGROUND_CLASSES,
|
|
64
|
-
"spiffy-tw-text-[--spiffy-colors-text-light]",
|
|
65
|
-
...ACCENT_PRIMARY_CLASSES,
|
|
66
|
-
BORDER_CLASS
|
|
67
|
-
]],
|
|
68
|
-
["darkAccent", [
|
|
69
|
-
...DARK_BACKGROUND_CLASSES,
|
|
70
|
-
"spiffy-tw-text-[--spiffy-colors-text-light]",
|
|
71
|
-
"spiffy-tw-fill-[--spiffy-colors-text-accent]",
|
|
72
|
-
"spiffy-tw-stroke-[--spiffy-colors-text-accent]",
|
|
73
|
-
BORDER_CLASS
|
|
74
|
-
]],
|
|
75
|
-
["darkAccentContrast", [
|
|
76
|
-
...DARK_BACKGROUND_CLASSES,
|
|
77
|
-
"spiffy-tw-text-[--spiffy-colors-text-light]",
|
|
78
|
-
"spiffy-tw-fill-[--spiffy-colors-accent-primary]",
|
|
79
|
-
"spiffy-tw-stroke-[--spiffy-colors-accent-primary]",
|
|
80
|
-
BORDER_CLASS
|
|
81
|
-
]],
|
|
82
|
-
["transparent", [
|
|
83
|
-
"spiffy-tw-bg-transparent",
|
|
84
|
-
"spiffy-tw-border-[--spiffy-colors-background-light]",
|
|
85
|
-
"spiffy-tw-text-[--spiffy-colors-text-light]",
|
|
86
|
-
"spiffy-tw-fill-transparent",
|
|
87
|
-
"spiffy-tw-stroke-[--spiffy-colors-text-light]",
|
|
88
|
-
BORDER_CLASS
|
|
89
|
-
]],
|
|
90
|
-
["transparentDark", [
|
|
91
|
-
"spiffy-tw-bg-transparent",
|
|
92
|
-
"spiffy-tw-border-[--spiffy-colors-border-light]",
|
|
93
|
-
"spiffy-tw-text-[--spiffy-colors-text-primary]",
|
|
94
|
-
"spiffy-tw-fill-transparent",
|
|
95
|
-
"spiffy-tw-stroke-[--spiffy-colors-text-primary]",
|
|
96
|
-
BORDER_CLASS
|
|
97
|
-
]],
|
|
98
|
-
["secondaryDark", [
|
|
99
|
-
...SECONDARY_DARK_BACKGROUND_CLASSES,
|
|
100
|
-
...TEXT_LINK_CLASSES,
|
|
101
|
-
BORDER_CLASS
|
|
102
|
-
]],
|
|
103
|
-
["secondaryAccent", [
|
|
104
|
-
...SECONDARY_DARK_BACKGROUND_CLASSES,
|
|
105
|
-
"spiffy-tw-text-[--spiffy-colors-text-link]",
|
|
106
|
-
...ACCENT_PRIMARY_CLASSES,
|
|
107
|
-
BORDER_CLASS
|
|
108
|
-
]],
|
|
109
|
-
["lightDark", [
|
|
110
|
-
"spiffy-tw-bg-[--spiffy-colors-background-light]",
|
|
111
|
-
"spiffy-tw-border-[--spiffy-colors-background-dark]",
|
|
112
|
-
...TEXT_PRIMARY_CLASSES,
|
|
113
|
-
BORDER_CLASS
|
|
114
|
-
]]
|
|
115
|
-
]);
|
|
116
12
|
const Icon = ({ isAnswer, variant }) => {
|
|
117
13
|
if (isAnswer) return void 0;
|
|
118
14
|
if (variant === "transparentDark") return /* @__PURE__ */ jsx(OutlinedStar, {});
|
|
119
15
|
return /* @__PURE__ */ jsx(FourPointStar, {});
|
|
120
16
|
};
|
|
121
|
-
const
|
|
122
|
-
"outlined",
|
|
123
|
-
"outlinedLight",
|
|
124
|
-
"primary",
|
|
125
|
-
"secondary",
|
|
126
|
-
"tertiary",
|
|
127
|
-
"dark",
|
|
128
|
-
"darkAccent",
|
|
129
|
-
"darkAccentContrast",
|
|
130
|
-
"darkPrimary",
|
|
131
|
-
"transparent",
|
|
132
|
-
"transparentDark",
|
|
133
|
-
"secondaryDark",
|
|
134
|
-
"secondaryAccent",
|
|
135
|
-
"lightDark"
|
|
136
|
-
];
|
|
137
|
-
const hoverTransform = (variantClass) => variantClass?.map((className) => `hover:${className}`);
|
|
138
|
-
const SuggestionButton = ({ variant, hoverVariant, isDisabled, content, boldText, borderRadius = "lg", isAnswer = false, dataAttributes, dataTestId, onClick }) => {
|
|
17
|
+
const SuggestionButton = ({ variant, hoverVariant, isDisabled, content, boldText, borderRadius = "lg", isAnswer = false, dataAttributes, dataTestId, onClick, ariaHidden, tabIndex }) => {
|
|
139
18
|
const buttonClassName = classNames({
|
|
140
19
|
[SPIFFY_SUGGESTION_BUTTON_QUESTION_CLASS]: !isAnswer,
|
|
141
20
|
[SPIFFY_SUGGESTION_BUTTON_ANSWER_CLASS]: isAnswer,
|
|
@@ -156,18 +35,7 @@ const SuggestionButton = ({ variant, hoverVariant, isDisabled, content, boldText
|
|
|
156
35
|
"spiffy-tw-stroke-inherit": true,
|
|
157
36
|
"spiffy-tw-fill-inherit": true
|
|
158
37
|
});
|
|
159
|
-
const
|
|
160
|
-
const hoverClasses = variantClassMap.get(hoverVariant) ?? [];
|
|
161
|
-
const baseBorderClasses = baseClasses.filter((cls) => cls.includes("border"));
|
|
162
|
-
const baseNonBorderClasses = baseClasses.filter((cls) => !cls.includes("border"));
|
|
163
|
-
const hoverBorderClasses = hoverClasses.filter((cls) => cls.includes("border"));
|
|
164
|
-
const hoverNonBorderClasses = hoverClasses.filter((cls) => !cls.includes("border"));
|
|
165
|
-
const buttonClass = `${buttonClassName} ${[
|
|
166
|
-
...baseNonBorderClasses,
|
|
167
|
-
...hoverTransform(hoverNonBorderClasses),
|
|
168
|
-
...baseBorderClasses,
|
|
169
|
-
...hoverTransform(hoverBorderClasses)
|
|
170
|
-
].join(" ")}`;
|
|
38
|
+
const buttonClass = `${buttonClassName} ${getSuggestionButtonVariantClasses(variant, hoverVariant)}`;
|
|
171
39
|
return /* @__PURE__ */ jsx(ButtonBase, {
|
|
172
40
|
text: content,
|
|
173
41
|
dataAttributes,
|
|
@@ -180,7 +48,9 @@ const SuggestionButton = ({ variant, hoverVariant, isDisabled, content, boldText
|
|
|
180
48
|
iconClass: isAnswer ? void 0 : iconClass,
|
|
181
49
|
textClass: `${SPIFFY_SUGGESTION_BUTTON_TEXT_CLASS} ${textClassName}`,
|
|
182
50
|
buttonClass,
|
|
183
|
-
onClick
|
|
51
|
+
onClick,
|
|
52
|
+
ariaHidden,
|
|
53
|
+
tabIndex
|
|
184
54
|
});
|
|
185
55
|
};
|
|
186
56
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
const require_variantClasses = require('./variantClasses.cjs');
|
|
1
2
|
const require_SuggestionButton = require('./SuggestionButton.cjs');
|
|
2
3
|
|
|
3
4
|
exports.SPIFFY_SUGGESTION_BUTTON_ANSWER_CLASS = require_SuggestionButton.SPIFFY_SUGGESTION_BUTTON_ANSWER_CLASS;
|
|
4
5
|
exports.SPIFFY_SUGGESTION_BUTTON_QUESTION_CLASS = require_SuggestionButton.SPIFFY_SUGGESTION_BUTTON_QUESTION_CLASS;
|
|
5
6
|
exports.SPIFFY_SUGGESTION_BUTTON_TEXT_CLASS = require_SuggestionButton.SPIFFY_SUGGESTION_BUTTON_TEXT_CLASS;
|
|
6
|
-
exports.SuggestionButton = require_SuggestionButton.SuggestionButton;
|
|
7
|
+
exports.SuggestionButton = require_SuggestionButton.SuggestionButton;
|
|
8
|
+
exports.getSuggestionButtonVariantClasses = require_variantClasses.getSuggestionButtonVariantClasses;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { SuggestionButtonVariant } from "./types.cjs";
|
|
2
2
|
import { SPIFFY_SUGGESTION_BUTTON_ANSWER_CLASS, SPIFFY_SUGGESTION_BUTTON_QUESTION_CLASS, SPIFFY_SUGGESTION_BUTTON_TEXT_CLASS, SuggestionButton } from "./SuggestionButton.cjs";
|
|
3
|
-
|
|
3
|
+
import { getSuggestionButtonVariantClasses } from "./variantClasses.cjs";
|
|
4
|
+
export { SPIFFY_SUGGESTION_BUTTON_ANSWER_CLASS, SPIFFY_SUGGESTION_BUTTON_QUESTION_CLASS, SPIFFY_SUGGESTION_BUTTON_TEXT_CLASS, SuggestionButton, SuggestionButtonVariant, getSuggestionButtonVariantClasses };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { SuggestionButtonVariant } from "./types.js";
|
|
2
2
|
import { SPIFFY_SUGGESTION_BUTTON_ANSWER_CLASS, SPIFFY_SUGGESTION_BUTTON_QUESTION_CLASS, SPIFFY_SUGGESTION_BUTTON_TEXT_CLASS, SuggestionButton } from "./SuggestionButton.js";
|
|
3
|
-
|
|
3
|
+
import { getSuggestionButtonVariantClasses } from "./variantClasses.js";
|
|
4
|
+
export { SPIFFY_SUGGESTION_BUTTON_ANSWER_CLASS, SPIFFY_SUGGESTION_BUTTON_QUESTION_CLASS, SPIFFY_SUGGESTION_BUTTON_TEXT_CLASS, SuggestionButton, SuggestionButtonVariant, getSuggestionButtonVariantClasses };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getSuggestionButtonVariantClasses } from "./variantClasses.js";
|
|
1
2
|
import { SPIFFY_SUGGESTION_BUTTON_ANSWER_CLASS, SPIFFY_SUGGESTION_BUTTON_QUESTION_CLASS, SPIFFY_SUGGESTION_BUTTON_TEXT_CLASS, SuggestionButton } from "./SuggestionButton.js";
|
|
2
3
|
|
|
3
|
-
export { SPIFFY_SUGGESTION_BUTTON_ANSWER_CLASS, SPIFFY_SUGGESTION_BUTTON_QUESTION_CLASS, SPIFFY_SUGGESTION_BUTTON_TEXT_CLASS, SuggestionButton };
|
|
4
|
+
export { SPIFFY_SUGGESTION_BUTTON_ANSWER_CLASS, SPIFFY_SUGGESTION_BUTTON_QUESTION_CLASS, SPIFFY_SUGGESTION_BUTTON_TEXT_CLASS, SuggestionButton, getSuggestionButtonVariantClasses };
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/components/SuggestionButton/variantClasses.ts
|
|
3
|
+
const BORDER_CLASS = "spiffy-tw-border";
|
|
4
|
+
const TEXT_LINK_CLASSES = [
|
|
5
|
+
"spiffy-tw-text-[--spiffy-colors-text-link]",
|
|
6
|
+
"spiffy-tw-fill-[--spiffy-colors-text-link]",
|
|
7
|
+
"spiffy-tw-stroke-[--spiffy-colors-text-link]"
|
|
8
|
+
];
|
|
9
|
+
const TEXT_LIGHT_CLASSES = [
|
|
10
|
+
"spiffy-tw-text-[--spiffy-colors-text-light]",
|
|
11
|
+
"spiffy-tw-fill-[--spiffy-colors-text-light]",
|
|
12
|
+
"spiffy-tw-stroke-[--spiffy-colors-text-light]"
|
|
13
|
+
];
|
|
14
|
+
const TEXT_PRIMARY_CLASSES = [
|
|
15
|
+
"spiffy-tw-text-[--spiffy-colors-text-primary]",
|
|
16
|
+
"spiffy-tw-fill-[--spiffy-colors-text-primary]",
|
|
17
|
+
"spiffy-tw-stroke-[--spiffy-colors-text-primary]"
|
|
18
|
+
];
|
|
19
|
+
const ACCENT_PRIMARY_CLASSES = ["spiffy-tw-fill-[--spiffy-colors-accent-primary]", "spiffy-tw-stroke-[--spiffy-colors-accent-primary]"];
|
|
20
|
+
const DARK_BACKGROUND_CLASSES = ["spiffy-tw-bg-[--spiffy-colors-background-dark]", "spiffy-tw-border-[--spiffy-colors-background-dark]"];
|
|
21
|
+
const SECONDARY_DARK_BACKGROUND_CLASSES = ["spiffy-tw-bg-[--spiffy-colors-background-secondary-dark]", "spiffy-tw-border-[--spiffy-colors-background-secondary-dark]"];
|
|
22
|
+
const variantClassMap = new Map([
|
|
23
|
+
["outlined", ["spiffy-tw-border-[--spiffy-colors-border-outline]", ...TEXT_LINK_CLASSES]],
|
|
24
|
+
["outlinedLight", [
|
|
25
|
+
"spiffy-tw-border-[--spiffy-colors-border-outline]",
|
|
26
|
+
"spiffy-tw-bg-[--spiffy-colors-background-light]",
|
|
27
|
+
...TEXT_LINK_CLASSES,
|
|
28
|
+
BORDER_CLASS
|
|
29
|
+
]],
|
|
30
|
+
["primary", [
|
|
31
|
+
"spiffy-tw-bg-[--spiffy-colors-background-primary]",
|
|
32
|
+
"spiffy-tw-border-[--spiffy-colors-background-primary]",
|
|
33
|
+
...TEXT_LIGHT_CLASSES,
|
|
34
|
+
BORDER_CLASS
|
|
35
|
+
]],
|
|
36
|
+
["secondary", [
|
|
37
|
+
"spiffy-tw-bg-[--spiffy-colors-background-secondary]",
|
|
38
|
+
"spiffy-tw-text-[--spiffy-colors-text-link]",
|
|
39
|
+
"spiffy-tw-border-[--spiffy-colors-background-secondary]",
|
|
40
|
+
...ACCENT_PRIMARY_CLASSES,
|
|
41
|
+
BORDER_CLASS
|
|
42
|
+
]],
|
|
43
|
+
["tertiary", [
|
|
44
|
+
"spiffy-tw-bg-[--spiffy-colors-background-tertiary]",
|
|
45
|
+
"spiffy-tw-border-[--spiffy-colors-background-tertiary]",
|
|
46
|
+
...TEXT_LINK_CLASSES,
|
|
47
|
+
BORDER_CLASS
|
|
48
|
+
]],
|
|
49
|
+
["dark", [
|
|
50
|
+
...DARK_BACKGROUND_CLASSES,
|
|
51
|
+
...TEXT_LIGHT_CLASSES,
|
|
52
|
+
BORDER_CLASS
|
|
53
|
+
]],
|
|
54
|
+
["darkPrimary", [
|
|
55
|
+
...DARK_BACKGROUND_CLASSES,
|
|
56
|
+
"spiffy-tw-text-[--spiffy-colors-text-light]",
|
|
57
|
+
...ACCENT_PRIMARY_CLASSES,
|
|
58
|
+
BORDER_CLASS
|
|
59
|
+
]],
|
|
60
|
+
["darkAccent", [
|
|
61
|
+
...DARK_BACKGROUND_CLASSES,
|
|
62
|
+
"spiffy-tw-text-[--spiffy-colors-text-light]",
|
|
63
|
+
"spiffy-tw-fill-[--spiffy-colors-text-accent]",
|
|
64
|
+
"spiffy-tw-stroke-[--spiffy-colors-text-accent]",
|
|
65
|
+
BORDER_CLASS
|
|
66
|
+
]],
|
|
67
|
+
["darkAccentContrast", [
|
|
68
|
+
...DARK_BACKGROUND_CLASSES,
|
|
69
|
+
"spiffy-tw-text-[--spiffy-colors-text-light]",
|
|
70
|
+
"spiffy-tw-fill-[--spiffy-colors-accent-primary]",
|
|
71
|
+
"spiffy-tw-stroke-[--spiffy-colors-accent-primary]",
|
|
72
|
+
BORDER_CLASS
|
|
73
|
+
]],
|
|
74
|
+
["transparent", [
|
|
75
|
+
"spiffy-tw-bg-transparent",
|
|
76
|
+
"spiffy-tw-border-[--spiffy-colors-background-light]",
|
|
77
|
+
"spiffy-tw-text-[--spiffy-colors-text-light]",
|
|
78
|
+
"spiffy-tw-fill-transparent",
|
|
79
|
+
"spiffy-tw-stroke-[--spiffy-colors-text-light]",
|
|
80
|
+
BORDER_CLASS
|
|
81
|
+
]],
|
|
82
|
+
["transparentDark", [
|
|
83
|
+
"spiffy-tw-bg-transparent",
|
|
84
|
+
"spiffy-tw-border-[--spiffy-colors-border-light]",
|
|
85
|
+
"spiffy-tw-text-[--spiffy-colors-text-primary]",
|
|
86
|
+
"spiffy-tw-fill-transparent",
|
|
87
|
+
"spiffy-tw-stroke-[--spiffy-colors-text-primary]",
|
|
88
|
+
BORDER_CLASS
|
|
89
|
+
]],
|
|
90
|
+
["secondaryDark", [
|
|
91
|
+
...SECONDARY_DARK_BACKGROUND_CLASSES,
|
|
92
|
+
...TEXT_LINK_CLASSES,
|
|
93
|
+
BORDER_CLASS
|
|
94
|
+
]],
|
|
95
|
+
["secondaryAccent", [
|
|
96
|
+
...SECONDARY_DARK_BACKGROUND_CLASSES,
|
|
97
|
+
"spiffy-tw-text-[--spiffy-colors-text-link]",
|
|
98
|
+
...ACCENT_PRIMARY_CLASSES,
|
|
99
|
+
BORDER_CLASS
|
|
100
|
+
]],
|
|
101
|
+
["lightDark", [
|
|
102
|
+
"spiffy-tw-bg-[--spiffy-colors-background-light]",
|
|
103
|
+
"spiffy-tw-border-[--spiffy-colors-background-dark]",
|
|
104
|
+
...TEXT_PRIMARY_CLASSES,
|
|
105
|
+
BORDER_CLASS
|
|
106
|
+
]]
|
|
107
|
+
]);
|
|
108
|
+
const borderedVariants = [
|
|
109
|
+
"outlined",
|
|
110
|
+
"outlinedLight",
|
|
111
|
+
"primary",
|
|
112
|
+
"secondary",
|
|
113
|
+
"tertiary",
|
|
114
|
+
"dark",
|
|
115
|
+
"darkAccent",
|
|
116
|
+
"darkAccentContrast",
|
|
117
|
+
"darkPrimary",
|
|
118
|
+
"transparent",
|
|
119
|
+
"transparentDark",
|
|
120
|
+
"secondaryDark",
|
|
121
|
+
"secondaryAccent",
|
|
122
|
+
"lightDark"
|
|
123
|
+
];
|
|
124
|
+
const hoverTransform = (variantClass) => variantClass?.map((className) => `hover:${className}`);
|
|
125
|
+
/**
|
|
126
|
+
* Background/border/text/icon classes for a suggestion button variant plus its hover
|
|
127
|
+
* variant. Exported so companion controls (e.g. the suggestion bar pause toggle) can
|
|
128
|
+
* match the merchant's button styling.
|
|
129
|
+
*/
|
|
130
|
+
const getSuggestionButtonVariantClasses = (variant, hoverVariant) => {
|
|
131
|
+
const baseClasses = variantClassMap.get(variant) ?? [];
|
|
132
|
+
const hoverClasses = variantClassMap.get(hoverVariant) ?? [];
|
|
133
|
+
const baseBorderClasses = baseClasses.filter((cls) => cls.includes("border"));
|
|
134
|
+
const baseNonBorderClasses = baseClasses.filter((cls) => !cls.includes("border"));
|
|
135
|
+
const hoverBorderClasses = hoverClasses.filter((cls) => cls.includes("border"));
|
|
136
|
+
const hoverNonBorderClasses = hoverClasses.filter((cls) => !cls.includes("border"));
|
|
137
|
+
return [
|
|
138
|
+
...baseNonBorderClasses,
|
|
139
|
+
...hoverTransform(hoverNonBorderClasses),
|
|
140
|
+
...baseBorderClasses,
|
|
141
|
+
...hoverTransform(hoverBorderClasses),
|
|
142
|
+
borderedVariants.includes(variant) && "spiffy-tw-border-[1px] spiffy-tw-border-solid"
|
|
143
|
+
].filter(Boolean).join(" ");
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
//#endregion
|
|
147
|
+
exports.borderedVariants = borderedVariants;
|
|
148
|
+
exports.getSuggestionButtonVariantClasses = getSuggestionButtonVariantClasses;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SuggestionButtonVariant } from "./types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/components/SuggestionButton/variantClasses.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Background/border/text/icon classes for a suggestion button variant plus its hover
|
|
7
|
+
* variant. Exported so companion controls (e.g. the suggestion bar pause toggle) can
|
|
8
|
+
* match the merchant's button styling.
|
|
9
|
+
*/
|
|
10
|
+
declare const getSuggestionButtonVariantClasses: (variant: SuggestionButtonVariant, hoverVariant: SuggestionButtonVariant) => string;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getSuggestionButtonVariantClasses };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SuggestionButtonVariant } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/components/SuggestionButton/variantClasses.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Background/border/text/icon classes for a suggestion button variant plus its hover
|
|
7
|
+
* variant. Exported so companion controls (e.g. the suggestion bar pause toggle) can
|
|
8
|
+
* match the merchant's button styling.
|
|
9
|
+
*/
|
|
10
|
+
declare const getSuggestionButtonVariantClasses: (variant: SuggestionButtonVariant, hoverVariant: SuggestionButtonVariant) => string;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getSuggestionButtonVariantClasses };
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
//#region src/components/SuggestionButton/variantClasses.ts
|
|
2
|
+
const BORDER_CLASS = "spiffy-tw-border";
|
|
3
|
+
const TEXT_LINK_CLASSES = [
|
|
4
|
+
"spiffy-tw-text-[--spiffy-colors-text-link]",
|
|
5
|
+
"spiffy-tw-fill-[--spiffy-colors-text-link]",
|
|
6
|
+
"spiffy-tw-stroke-[--spiffy-colors-text-link]"
|
|
7
|
+
];
|
|
8
|
+
const TEXT_LIGHT_CLASSES = [
|
|
9
|
+
"spiffy-tw-text-[--spiffy-colors-text-light]",
|
|
10
|
+
"spiffy-tw-fill-[--spiffy-colors-text-light]",
|
|
11
|
+
"spiffy-tw-stroke-[--spiffy-colors-text-light]"
|
|
12
|
+
];
|
|
13
|
+
const TEXT_PRIMARY_CLASSES = [
|
|
14
|
+
"spiffy-tw-text-[--spiffy-colors-text-primary]",
|
|
15
|
+
"spiffy-tw-fill-[--spiffy-colors-text-primary]",
|
|
16
|
+
"spiffy-tw-stroke-[--spiffy-colors-text-primary]"
|
|
17
|
+
];
|
|
18
|
+
const ACCENT_PRIMARY_CLASSES = ["spiffy-tw-fill-[--spiffy-colors-accent-primary]", "spiffy-tw-stroke-[--spiffy-colors-accent-primary]"];
|
|
19
|
+
const DARK_BACKGROUND_CLASSES = ["spiffy-tw-bg-[--spiffy-colors-background-dark]", "spiffy-tw-border-[--spiffy-colors-background-dark]"];
|
|
20
|
+
const SECONDARY_DARK_BACKGROUND_CLASSES = ["spiffy-tw-bg-[--spiffy-colors-background-secondary-dark]", "spiffy-tw-border-[--spiffy-colors-background-secondary-dark]"];
|
|
21
|
+
const variantClassMap = new Map([
|
|
22
|
+
["outlined", ["spiffy-tw-border-[--spiffy-colors-border-outline]", ...TEXT_LINK_CLASSES]],
|
|
23
|
+
["outlinedLight", [
|
|
24
|
+
"spiffy-tw-border-[--spiffy-colors-border-outline]",
|
|
25
|
+
"spiffy-tw-bg-[--spiffy-colors-background-light]",
|
|
26
|
+
...TEXT_LINK_CLASSES,
|
|
27
|
+
BORDER_CLASS
|
|
28
|
+
]],
|
|
29
|
+
["primary", [
|
|
30
|
+
"spiffy-tw-bg-[--spiffy-colors-background-primary]",
|
|
31
|
+
"spiffy-tw-border-[--spiffy-colors-background-primary]",
|
|
32
|
+
...TEXT_LIGHT_CLASSES,
|
|
33
|
+
BORDER_CLASS
|
|
34
|
+
]],
|
|
35
|
+
["secondary", [
|
|
36
|
+
"spiffy-tw-bg-[--spiffy-colors-background-secondary]",
|
|
37
|
+
"spiffy-tw-text-[--spiffy-colors-text-link]",
|
|
38
|
+
"spiffy-tw-border-[--spiffy-colors-background-secondary]",
|
|
39
|
+
...ACCENT_PRIMARY_CLASSES,
|
|
40
|
+
BORDER_CLASS
|
|
41
|
+
]],
|
|
42
|
+
["tertiary", [
|
|
43
|
+
"spiffy-tw-bg-[--spiffy-colors-background-tertiary]",
|
|
44
|
+
"spiffy-tw-border-[--spiffy-colors-background-tertiary]",
|
|
45
|
+
...TEXT_LINK_CLASSES,
|
|
46
|
+
BORDER_CLASS
|
|
47
|
+
]],
|
|
48
|
+
["dark", [
|
|
49
|
+
...DARK_BACKGROUND_CLASSES,
|
|
50
|
+
...TEXT_LIGHT_CLASSES,
|
|
51
|
+
BORDER_CLASS
|
|
52
|
+
]],
|
|
53
|
+
["darkPrimary", [
|
|
54
|
+
...DARK_BACKGROUND_CLASSES,
|
|
55
|
+
"spiffy-tw-text-[--spiffy-colors-text-light]",
|
|
56
|
+
...ACCENT_PRIMARY_CLASSES,
|
|
57
|
+
BORDER_CLASS
|
|
58
|
+
]],
|
|
59
|
+
["darkAccent", [
|
|
60
|
+
...DARK_BACKGROUND_CLASSES,
|
|
61
|
+
"spiffy-tw-text-[--spiffy-colors-text-light]",
|
|
62
|
+
"spiffy-tw-fill-[--spiffy-colors-text-accent]",
|
|
63
|
+
"spiffy-tw-stroke-[--spiffy-colors-text-accent]",
|
|
64
|
+
BORDER_CLASS
|
|
65
|
+
]],
|
|
66
|
+
["darkAccentContrast", [
|
|
67
|
+
...DARK_BACKGROUND_CLASSES,
|
|
68
|
+
"spiffy-tw-text-[--spiffy-colors-text-light]",
|
|
69
|
+
"spiffy-tw-fill-[--spiffy-colors-accent-primary]",
|
|
70
|
+
"spiffy-tw-stroke-[--spiffy-colors-accent-primary]",
|
|
71
|
+
BORDER_CLASS
|
|
72
|
+
]],
|
|
73
|
+
["transparent", [
|
|
74
|
+
"spiffy-tw-bg-transparent",
|
|
75
|
+
"spiffy-tw-border-[--spiffy-colors-background-light]",
|
|
76
|
+
"spiffy-tw-text-[--spiffy-colors-text-light]",
|
|
77
|
+
"spiffy-tw-fill-transparent",
|
|
78
|
+
"spiffy-tw-stroke-[--spiffy-colors-text-light]",
|
|
79
|
+
BORDER_CLASS
|
|
80
|
+
]],
|
|
81
|
+
["transparentDark", [
|
|
82
|
+
"spiffy-tw-bg-transparent",
|
|
83
|
+
"spiffy-tw-border-[--spiffy-colors-border-light]",
|
|
84
|
+
"spiffy-tw-text-[--spiffy-colors-text-primary]",
|
|
85
|
+
"spiffy-tw-fill-transparent",
|
|
86
|
+
"spiffy-tw-stroke-[--spiffy-colors-text-primary]",
|
|
87
|
+
BORDER_CLASS
|
|
88
|
+
]],
|
|
89
|
+
["secondaryDark", [
|
|
90
|
+
...SECONDARY_DARK_BACKGROUND_CLASSES,
|
|
91
|
+
...TEXT_LINK_CLASSES,
|
|
92
|
+
BORDER_CLASS
|
|
93
|
+
]],
|
|
94
|
+
["secondaryAccent", [
|
|
95
|
+
...SECONDARY_DARK_BACKGROUND_CLASSES,
|
|
96
|
+
"spiffy-tw-text-[--spiffy-colors-text-link]",
|
|
97
|
+
...ACCENT_PRIMARY_CLASSES,
|
|
98
|
+
BORDER_CLASS
|
|
99
|
+
]],
|
|
100
|
+
["lightDark", [
|
|
101
|
+
"spiffy-tw-bg-[--spiffy-colors-background-light]",
|
|
102
|
+
"spiffy-tw-border-[--spiffy-colors-background-dark]",
|
|
103
|
+
...TEXT_PRIMARY_CLASSES,
|
|
104
|
+
BORDER_CLASS
|
|
105
|
+
]]
|
|
106
|
+
]);
|
|
107
|
+
const borderedVariants = [
|
|
108
|
+
"outlined",
|
|
109
|
+
"outlinedLight",
|
|
110
|
+
"primary",
|
|
111
|
+
"secondary",
|
|
112
|
+
"tertiary",
|
|
113
|
+
"dark",
|
|
114
|
+
"darkAccent",
|
|
115
|
+
"darkAccentContrast",
|
|
116
|
+
"darkPrimary",
|
|
117
|
+
"transparent",
|
|
118
|
+
"transparentDark",
|
|
119
|
+
"secondaryDark",
|
|
120
|
+
"secondaryAccent",
|
|
121
|
+
"lightDark"
|
|
122
|
+
];
|
|
123
|
+
const hoverTransform = (variantClass) => variantClass?.map((className) => `hover:${className}`);
|
|
124
|
+
/**
|
|
125
|
+
* Background/border/text/icon classes for a suggestion button variant plus its hover
|
|
126
|
+
* variant. Exported so companion controls (e.g. the suggestion bar pause toggle) can
|
|
127
|
+
* match the merchant's button styling.
|
|
128
|
+
*/
|
|
129
|
+
const getSuggestionButtonVariantClasses = (variant, hoverVariant) => {
|
|
130
|
+
const baseClasses = variantClassMap.get(variant) ?? [];
|
|
131
|
+
const hoverClasses = variantClassMap.get(hoverVariant) ?? [];
|
|
132
|
+
const baseBorderClasses = baseClasses.filter((cls) => cls.includes("border"));
|
|
133
|
+
const baseNonBorderClasses = baseClasses.filter((cls) => !cls.includes("border"));
|
|
134
|
+
const hoverBorderClasses = hoverClasses.filter((cls) => cls.includes("border"));
|
|
135
|
+
const hoverNonBorderClasses = hoverClasses.filter((cls) => !cls.includes("border"));
|
|
136
|
+
return [
|
|
137
|
+
...baseNonBorderClasses,
|
|
138
|
+
...hoverTransform(hoverNonBorderClasses),
|
|
139
|
+
...baseBorderClasses,
|
|
140
|
+
...hoverTransform(hoverBorderClasses),
|
|
141
|
+
borderedVariants.includes(variant) && "spiffy-tw-border-[1px] spiffy-tw-border-solid"
|
|
142
|
+
].filter(Boolean).join(" ");
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
//#endregion
|
|
146
|
+
export { borderedVariants, getSuggestionButtonVariantClasses };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/components/ToggleButton/ToggleButton.d.ts
|
|
4
4
|
type ToggleButtonProps = {
|
|
@@ -25,6 +25,6 @@ declare const ToggleButton: ({
|
|
|
25
25
|
icon,
|
|
26
26
|
iconClassName,
|
|
27
27
|
variant
|
|
28
|
-
}: ToggleButtonProps) =>
|
|
28
|
+
}: ToggleButtonProps) => react_jsx_runtime0.JSX.Element;
|
|
29
29
|
//#endregion
|
|
30
30
|
export { ToggleButton, ToggleButtonProps, ToggleButtonVariant };
|
package/package.json
CHANGED
|
@@ -14,6 +14,8 @@ export const ButtonBase = ({
|
|
|
14
14
|
dataTestId,
|
|
15
15
|
onClick,
|
|
16
16
|
disablePadding = false,
|
|
17
|
+
ariaHidden,
|
|
18
|
+
tabIndex,
|
|
17
19
|
}: ButtonBaseProps) => {
|
|
18
20
|
const RenderedIcon = () => icon;
|
|
19
21
|
const buttonRef = useRef<HTMLButtonElement | null>(null);
|
|
@@ -59,6 +61,8 @@ export const ButtonBase = ({
|
|
|
59
61
|
className={buttonClassName}
|
|
60
62
|
disabled={isDisabled}
|
|
61
63
|
data-testid={dataTestId}
|
|
64
|
+
aria-hidden={ariaHidden}
|
|
65
|
+
tabIndex={tabIndex}
|
|
62
66
|
onClick={onClick}
|
|
63
67
|
>
|
|
64
68
|
{icon && <RenderedIcon />}
|
|
@@ -17,6 +17,10 @@ export interface ButtonBaseProps {
|
|
|
17
17
|
onClick?: () => void;
|
|
18
18
|
disablePadding?: boolean;
|
|
19
19
|
dataTestId?: string;
|
|
20
|
+
/** Hides the button from assistive technology (e.g. decorative looping copies). */
|
|
21
|
+
ariaHidden?: boolean;
|
|
22
|
+
/** Pass `-1` to remove the button from the keyboard tab order. */
|
|
23
|
+
tabIndex?: number;
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
export enum ButtonBaseOverrides {
|