@constructor-io/constructorio-ui-quizzes 1.9.10 → 1.10.1
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/constructorio-ui-quizzes-bundled.js +14 -14
- package/lib/cjs/components/CioQuiz/actions.js +1 -0
- package/lib/cjs/components/CioQuiz/index.js +10 -6
- package/lib/cjs/components/CioQuiz/quizApiReducer.js +4 -1
- package/lib/cjs/components/ResultContainer/ResultContainer.js +25 -19
- package/lib/cjs/components/ShareButton/ShareButton.js +17 -0
- package/lib/cjs/components/ShareButton/ShareSVG.js +11 -0
- package/lib/cjs/components/ShareResultsModal/AlertCircleSVG.js +11 -0
- package/lib/cjs/components/ShareResultsModal/CheckMarkCircleSVG.js +10 -0
- package/lib/cjs/components/ShareResultsModal/CloseSVG.js +10 -0
- package/lib/cjs/components/ShareResultsModal/EmailField.js +50 -0
- package/lib/cjs/components/ShareResultsModal/LinkField.js +30 -0
- package/lib/cjs/components/ShareResultsModal/ShareResultsModal.js +24 -0
- package/lib/cjs/constants.js +3 -42
- package/lib/cjs/hooks/useConsoleErrors.js +4 -8
- package/lib/cjs/hooks/usePropsGetters/index.js +2 -0
- package/lib/cjs/hooks/useQueryParams.js +31 -0
- package/lib/cjs/hooks/useQuiz.js +3 -3
- package/lib/cjs/hooks/useQuizEvents/index.js +10 -5
- package/lib/cjs/hooks/useQuizEvents/useQuizResetClick.js +15 -2
- package/lib/cjs/hooks/useQuizState/useQuizApiState.js +27 -2
- package/lib/cjs/hooks/useShareResultsLink.js +18 -0
- package/lib/cjs/index.js +3 -1
- package/lib/cjs/services/index.js +3 -1
- package/lib/cjs/stories/Quiz/argTypes.js +258 -7
- package/lib/cjs/utils.js +1 -0
- package/lib/cjs/version.js +1 -1
- package/lib/mjs/components/CioQuiz/actions.js +1 -0
- package/lib/mjs/components/CioQuiz/index.js +10 -6
- package/lib/mjs/components/CioQuiz/quizApiReducer.js +9 -0
- package/lib/mjs/components/ResultContainer/ResultContainer.js +25 -19
- package/lib/mjs/components/ShareButton/ShareButton.js +14 -0
- package/lib/mjs/components/ShareButton/ShareSVG.js +7 -0
- package/lib/mjs/components/ShareResultsModal/AlertCircleSVG.js +7 -0
- package/lib/mjs/components/ShareResultsModal/CheckMarkCircleSVG.js +6 -0
- package/lib/mjs/components/ShareResultsModal/CloseSVG.js +6 -0
- package/lib/mjs/components/ShareResultsModal/EmailField.js +46 -0
- package/lib/mjs/components/ShareResultsModal/LinkField.js +26 -0
- package/lib/mjs/components/ShareResultsModal/ShareResultsModal.js +20 -0
- package/lib/mjs/constants.js +2 -41
- package/lib/mjs/hooks/useConsoleErrors.js +4 -8
- package/lib/mjs/hooks/usePropsGetters/index.js +2 -0
- package/lib/mjs/hooks/useQueryParams.js +29 -0
- package/lib/mjs/hooks/useQuiz.js +3 -3
- package/lib/mjs/hooks/useQuizEvents/index.js +10 -5
- package/lib/mjs/hooks/useQuizEvents/useQuizResetClick.js +14 -2
- package/lib/mjs/hooks/useQuizState/useQuizApiState.js +28 -3
- package/lib/mjs/hooks/useShareResultsLink.js +14 -0
- package/lib/mjs/index.js +1 -0
- package/lib/mjs/services/index.js +1 -0
- package/lib/mjs/stories/Quiz/argTypes.js +257 -6
- package/lib/mjs/utils.js +1 -0
- package/lib/mjs/version.js +1 -1
- package/lib/styles.css +192 -3
- package/lib/types/components/CioQuiz/actions.d.ts +7 -3
- package/lib/types/components/CioQuiz/context.d.ts +2 -1
- package/lib/types/components/CioQuiz/quizApiReducer.d.ts +2 -2
- package/lib/types/components/ResultCard/ResultCard.d.ts +2 -2
- package/lib/types/components/ResultContainer/ResultContainer.d.ts +5 -3
- package/lib/types/components/Results/Results.d.ts +2 -2
- package/lib/types/components/ShareButton/ShareButton.d.ts +7 -0
- package/lib/types/components/ShareButton/ShareSVG.d.ts +2 -0
- package/lib/types/components/ShareResultsModal/AlertCircleSVG.d.ts +2 -0
- package/lib/types/components/ShareResultsModal/CheckMarkCircleSVG.d.ts +2 -0
- package/lib/types/components/ShareResultsModal/CloseSVG.d.ts +2 -0
- package/lib/types/components/ShareResultsModal/EmailField.d.ts +6 -0
- package/lib/types/components/ShareResultsModal/LinkField.d.ts +6 -0
- package/lib/types/components/ShareResultsModal/ShareResultsModal.d.ts +9 -0
- package/lib/types/constants.d.ts +1 -5
- package/lib/types/hooks/usePropsGetters/index.d.ts +2 -1
- package/lib/types/hooks/useQueryParams.d.ts +7 -0
- package/lib/types/hooks/useQuizEvents/useQuizNextClick.d.ts +2 -2
- package/lib/types/hooks/useQuizEvents/useQuizResetClick.d.ts +9 -2
- package/lib/types/hooks/useQuizEvents/useQuizSkipClick.d.ts +2 -2
- package/lib/types/hooks/useShareResultsLink.d.ts +2 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/services/index.d.ts +6 -5
- package/lib/types/stories/Quiz/argTypes.d.ts +253 -6
- package/lib/types/types.d.ts +32 -14
- package/lib/types/utils.d.ts +2 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +2 -2
- package/lib/cjs/stories/Quiz/tests/mocks.js +0 -170
- package/lib/mjs/stories/Quiz/tests/mocks.js +0 -198
- package/lib/types/stories/Quiz/tests/mocks.d.ts +0 -44
package/lib/mjs/utils.js
CHANGED
|
@@ -51,6 +51,7 @@ export const functionStrings = {
|
|
|
51
51
|
onQuizResultsLoaded: `(results) => console.dir(results)`,
|
|
52
52
|
onQuizNextQuestion: `(question) => console.dir(question)`,
|
|
53
53
|
onQuizSkipQuestion: `(question) => console.dir(question)`,
|
|
54
|
+
onEmailResults: `(data) => console.dir(data)`,
|
|
54
55
|
cioJsClient: `cioJsClient`,
|
|
55
56
|
};
|
|
56
57
|
export const stringifyWithDefaults = (obj) => {
|
package/lib/mjs/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '1.
|
|
1
|
+
export default '1.10.1';
|
package/lib/styles.css
CHANGED
|
@@ -99,6 +99,7 @@
|
|
|
99
99
|
width: 100%;
|
|
100
100
|
position: absolute;
|
|
101
101
|
z-index: -1;
|
|
102
|
+
overflow: hidden;
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
/* Session Prompt Modal */
|
|
@@ -172,6 +173,7 @@
|
|
|
172
173
|
width: 100%;
|
|
173
174
|
height: 100%;
|
|
174
175
|
object-fit: cover;
|
|
176
|
+
aspect-ratio: 1/1;
|
|
175
177
|
}
|
|
176
178
|
.cio-quiz .cio-question-image-container {
|
|
177
179
|
box-sizing: border-box;
|
|
@@ -181,6 +183,7 @@
|
|
|
181
183
|
height: var(--container-image-small-height); /* Fixed height for layout shifts */
|
|
182
184
|
display: flex;
|
|
183
185
|
align-self: stretch;
|
|
186
|
+
overflow: hidden;
|
|
184
187
|
}
|
|
185
188
|
|
|
186
189
|
/* Input */
|
|
@@ -399,7 +402,6 @@
|
|
|
399
402
|
border-radius: 4px;
|
|
400
403
|
object-fit: cover;
|
|
401
404
|
margin-bottom: 16px;
|
|
402
|
-
aspect-ratio: 1/1;
|
|
403
405
|
}
|
|
404
406
|
|
|
405
407
|
/* Select Option Value */
|
|
@@ -678,6 +680,21 @@
|
|
|
678
680
|
margin-top: 1px;
|
|
679
681
|
}
|
|
680
682
|
|
|
683
|
+
/* Share results Button Component */
|
|
684
|
+
.cio-quiz .cio-question-share-results-button {
|
|
685
|
+
background: none;
|
|
686
|
+
border: none;
|
|
687
|
+
display: flex;
|
|
688
|
+
gap: 0.5rem;
|
|
689
|
+
align-items: center;
|
|
690
|
+
}
|
|
691
|
+
.cio-quiz .cio-question-share-results-button:hover {
|
|
692
|
+
text-decoration: underline;
|
|
693
|
+
}
|
|
694
|
+
.cio-quiz .cio-question-share-results-button span {
|
|
695
|
+
margin-top: 1px;
|
|
696
|
+
}
|
|
697
|
+
|
|
681
698
|
/* Container Queries */
|
|
682
699
|
|
|
683
700
|
/* Small Tablet */
|
|
@@ -696,7 +713,7 @@
|
|
|
696
713
|
align-self: normal;
|
|
697
714
|
}
|
|
698
715
|
|
|
699
|
-
/* Image */
|
|
716
|
+
/* Image Container */
|
|
700
717
|
.cio-quiz .cio-question-image-container {
|
|
701
718
|
flex-basis: 50%;
|
|
702
719
|
flex-shrink: 0;
|
|
@@ -721,7 +738,7 @@
|
|
|
721
738
|
.cio-quiz .cio-results-container {
|
|
722
739
|
padding: 3rem 4rem;
|
|
723
740
|
}
|
|
724
|
-
.cio-quiz .cio-results-
|
|
741
|
+
.cio-quiz .cio-results-button-group {
|
|
725
742
|
display: flex;
|
|
726
743
|
justify-content: space-between;
|
|
727
744
|
align-items: end;
|
|
@@ -897,3 +914,175 @@
|
|
|
897
914
|
transform: rotate(360deg);
|
|
898
915
|
}
|
|
899
916
|
}
|
|
917
|
+
|
|
918
|
+
/* Share results modal */
|
|
919
|
+
.cio-quiz .cio-share-results-modal {
|
|
920
|
+
position: absolute;
|
|
921
|
+
display: flex;
|
|
922
|
+
z-index: 100;
|
|
923
|
+
width: 100%;
|
|
924
|
+
height: 100%;
|
|
925
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
926
|
+
justify-content: space-between;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
.cio-quiz .cio-share-results-container {
|
|
930
|
+
max-width: 600px;
|
|
931
|
+
width: 100%;
|
|
932
|
+
margin: auto;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
.cio-quiz .cio-share-results-content {
|
|
936
|
+
display: flex;
|
|
937
|
+
flex-direction: column;
|
|
938
|
+
gap: 24px;
|
|
939
|
+
background: #ffffff;
|
|
940
|
+
line-height: 1.5;
|
|
941
|
+
padding: 40px;
|
|
942
|
+
padding-bottom: 80px;
|
|
943
|
+
border-radius: 8px;
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
.cio-quiz .cio-share-results-header {
|
|
947
|
+
display: flex;
|
|
948
|
+
flex-direction: row;
|
|
949
|
+
justify-content: space-between;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
.cio-quiz .cio-share-results-description {
|
|
953
|
+
font-size: 1rem;
|
|
954
|
+
font-weight: 700;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
.cio-quiz .cio-share-results-title {
|
|
958
|
+
font-weight: 700;
|
|
959
|
+
font-size: 24px;
|
|
960
|
+
text-transform: capitalize;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
.cio-quiz .cio-modal-close-button {
|
|
964
|
+
background: none;
|
|
965
|
+
border: none;
|
|
966
|
+
display: flex;
|
|
967
|
+
gap: 0.5rem;
|
|
968
|
+
align-items: center;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
.cio-quiz .cio-share-results-button-group {
|
|
972
|
+
display: flex;
|
|
973
|
+
flex-direction: row;
|
|
974
|
+
gap: 1rem;
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
.cio-quiz .cio-share-results-feature-group {
|
|
978
|
+
display: flex;
|
|
979
|
+
flex-direction: column;
|
|
980
|
+
gap: 1rem;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
.cio-quiz .cio-results-redo-and-share-button-group {
|
|
984
|
+
display: flex;
|
|
985
|
+
gap: 8px;
|
|
986
|
+
align-items: end;
|
|
987
|
+
justify-content: space-between;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
.cio-quiz .cio-share-results-share-button {
|
|
991
|
+
background: #d3e5fb;
|
|
992
|
+
color: var(--primary-color);
|
|
993
|
+
border: 2px solid #d3e5fb;
|
|
994
|
+
border-radius: 4px;
|
|
995
|
+
height: 3rem;
|
|
996
|
+
font-size: 1rem;
|
|
997
|
+
flex-grow: 1;
|
|
998
|
+
width: 100%;
|
|
999
|
+
padding: 12px 32px;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
.cio-quiz .cio-share-results-share-button:hover {
|
|
1003
|
+
background: var(--primary-color-variant-500);
|
|
1004
|
+
border: 2px solid var(--primary-color-variant-600);
|
|
1005
|
+
color: white;
|
|
1006
|
+
}
|
|
1007
|
+
.cio-quiz .cio-share-results-share-button:active {
|
|
1008
|
+
background: var(--primary-color-variant-700);
|
|
1009
|
+
border: 2px solid var(--primary-color-variant-800);
|
|
1010
|
+
color: white;
|
|
1011
|
+
}
|
|
1012
|
+
.cio-quiz .cio-share-results-share-button:focus {
|
|
1013
|
+
outline: 3px solid var(--primary-color-variant-100);
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
.cio-quiz .cio-share-results-notification {
|
|
1017
|
+
width: 100%;
|
|
1018
|
+
padding: 20px;
|
|
1019
|
+
border-radius: 8px;
|
|
1020
|
+
border: 1px;
|
|
1021
|
+
font-weight: 500;
|
|
1022
|
+
border: 1px solid #c8daee;
|
|
1023
|
+
box-shadow: 0px 4px 10px 0px rgba(93, 124, 232, 0.15);
|
|
1024
|
+
display: flex;
|
|
1025
|
+
flex-direction: row;
|
|
1026
|
+
gap: 12px;
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
.cio-quiz .cio-share-results-link-input {
|
|
1030
|
+
font-size: 1rem;
|
|
1031
|
+
padding: 12px 20px;
|
|
1032
|
+
border-radius: 4px;
|
|
1033
|
+
border: 1px solid #c8daee;
|
|
1034
|
+
color: var(--gray-dust-100);
|
|
1035
|
+
width: '100%';
|
|
1036
|
+
flex-grow: 1;
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
.cio-quiz .cio-share-results-email-input-group {
|
|
1040
|
+
display: flex;
|
|
1041
|
+
flex-direction: column;
|
|
1042
|
+
gap: 4px;
|
|
1043
|
+
flex-grow: 1;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
.cio-quiz .cio-share-results-email-input-error-message {
|
|
1047
|
+
color: #e0182d;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
.cio-quiz .cio-share-results-email-input {
|
|
1051
|
+
padding: 0.5rem;
|
|
1052
|
+
border: 0;
|
|
1053
|
+
border-bottom: 1px solid var(--gray-dust-100);
|
|
1054
|
+
color: var(--primary-color-variant-500);
|
|
1055
|
+
padding: 0.8rem;
|
|
1056
|
+
outline: none;
|
|
1057
|
+
font-size: 1rem;
|
|
1058
|
+
width: 100%;
|
|
1059
|
+
flex-grow: 1;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
.cio-quiz .cio-share-results-email-input--error {
|
|
1063
|
+
border-bottom: 1px solid #e0182d;
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
@container (max-width: 500px) {
|
|
1067
|
+
.cio-quiz .cio-share-results-button-group {
|
|
1068
|
+
display: flex;
|
|
1069
|
+
flex-direction: column;
|
|
1070
|
+
gap: 1rem;
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
.cio-quiz .cio-share-results-share-button {
|
|
1074
|
+
max-width: 100%;
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
@container (min-width: 500px) {
|
|
1079
|
+
.cio-quiz .cio-share-results-button-group {
|
|
1080
|
+
display: flex;
|
|
1081
|
+
flex-direction: row;
|
|
1082
|
+
gap: 1rem;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
.cio-quiz .cio-share-results-share-button {
|
|
1086
|
+
max-width: 138px;
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CurrentQuestion, NextQuestionResponse, QuestionOption, QuizResultsResponse } from '../../types';
|
|
1
|
+
import { CurrentQuestion, NextQuestionResponse, QuestionOption, QuizResultsResponse, QuizSharedResultsData } from '../../types';
|
|
2
2
|
import type { QuizLocalReducerState } from './quizLocalReducer';
|
|
3
3
|
export declare enum QuestionTypes {
|
|
4
4
|
OpenText = "open",
|
|
@@ -30,18 +30,22 @@ export declare enum QuizAPIActionTypes {
|
|
|
30
30
|
SET_IS_ERROR = 1,
|
|
31
31
|
SET_QUIZ_RESULTS = 2,
|
|
32
32
|
SET_CURRENT_QUESTION = 3,
|
|
33
|
-
RESET_QUIZ = 4
|
|
33
|
+
RESET_QUIZ = 4,
|
|
34
|
+
SET_QUIZ_SHARED_RESULTS = 5
|
|
34
35
|
}
|
|
35
36
|
export type ActionSetIsLoading = Action<QuizAPIActionTypes.SET_IS_LOADING>;
|
|
36
37
|
export type ActionSetIsError = Action<QuizAPIActionTypes.SET_IS_ERROR>;
|
|
37
38
|
export type ActionSetQuizResults = Action<QuizAPIActionTypes.SET_QUIZ_RESULTS, {
|
|
38
39
|
quizResults: QuizResultsResponse;
|
|
39
40
|
}>;
|
|
41
|
+
export type ActionSetQuizSharedResults = Action<QuizAPIActionTypes.SET_QUIZ_SHARED_RESULTS, {
|
|
42
|
+
quizResults: QuizSharedResultsData;
|
|
43
|
+
}>;
|
|
40
44
|
export type ActionSetCurrentQuestion = Action<QuizAPIActionTypes.SET_CURRENT_QUESTION, {
|
|
41
45
|
quizCurrentQuestion: NextQuestionResponse;
|
|
42
46
|
quizSessionId?: string;
|
|
43
47
|
quizVersionId?: string;
|
|
44
48
|
}>;
|
|
45
49
|
export type ActionResetQuiz = Action<QuizAPIActionTypes.RESET_QUIZ>;
|
|
46
|
-
export type ActionQuizAPI = ActionSetIsLoading | ActionSetIsError | ActionSetQuizResults | ActionSetCurrentQuestion | ActionResetQuiz;
|
|
50
|
+
export type ActionQuizAPI = ActionSetIsLoading | ActionSetIsError | ActionSetQuizResults | ActionSetCurrentQuestion | ActionResetQuiz | ActionSetQuizSharedResults;
|
|
47
51
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ConstructorIOClient from '@constructor-io/constructorio-client-javascript';
|
|
3
|
-
import { GetAddToCartButtonProps, GetAddToFavoritesButtonProps, GetCoverQuestionProps, GetHydrateQuizButtonProps, GetNextQuestionButtonProps, GetSkipQuestionButtonProps, GetOpenTextInputProps, GetPreviousQuestionButtonProps, GetQuizImageProps, GetQuizResultButtonProps, GetQuizResultLinkProps, GetResetQuizButtonProps, GetSelectInputProps, PrimaryColorStyles, QuizReturnState } from '../../types';
|
|
3
|
+
import { GetAddToCartButtonProps, GetAddToFavoritesButtonProps, GetCoverQuestionProps, GetHydrateQuizButtonProps, GetNextQuestionButtonProps, GetSkipQuestionButtonProps, GetOpenTextInputProps, GetPreviousQuestionButtonProps, GetQuizImageProps, GetQuizResultButtonProps, GetQuizResultLinkProps, GetResetQuizButtonProps, GetSelectInputProps, PrimaryColorStyles, QuizReturnState, GetShareResultsButtonProps } from '../../types';
|
|
4
4
|
export interface QuizContextValue {
|
|
5
5
|
cioClient?: ConstructorIOClient;
|
|
6
6
|
state?: QuizReturnState;
|
|
@@ -12,6 +12,7 @@ export interface QuizContextValue {
|
|
|
12
12
|
getSelectInputProps: GetSelectInputProps;
|
|
13
13
|
getCoverQuestionProps: GetCoverQuestionProps;
|
|
14
14
|
getResetQuizButtonProps: GetResetQuizButtonProps;
|
|
15
|
+
getShareResultsButtonProps: GetShareResultsButtonProps;
|
|
15
16
|
getHydrateQuizButtonProps: GetHydrateQuizButtonProps;
|
|
16
17
|
getAddToCartButtonProps: GetAddToCartButtonProps;
|
|
17
18
|
getAddToFavoritesButtonProps: GetAddToFavoritesButtonProps;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { RequestStates } from '../../constants';
|
|
2
|
-
import { CurrentQuestion, NextQuestionResponse, QuizResultsResponse } from '../../types';
|
|
2
|
+
import { CurrentQuestion, NextQuestionResponse, QuizResultsResponse, QuizSharedResultsData } from '../../types';
|
|
3
3
|
import { ActionQuizAPI } from './actions';
|
|
4
4
|
export type QuizAPIReducerState = {
|
|
5
5
|
quizRequestState: RequestStates;
|
|
6
6
|
quizCurrentQuestion?: CurrentQuestion;
|
|
7
7
|
quizFirstQuestion?: NextQuestionResponse;
|
|
8
|
-
quizResults?: QuizResultsResponse;
|
|
8
|
+
quizResults?: QuizResultsResponse | QuizSharedResultsData;
|
|
9
9
|
selectedOptionsWithAttributes?: string[];
|
|
10
10
|
};
|
|
11
11
|
export declare const initialState: QuizAPIReducerState;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { QuizResultDataPartial } from '../../types';
|
|
3
|
-
interface
|
|
3
|
+
interface ResultCardOptions {
|
|
4
4
|
result: QuizResultDataPartial;
|
|
5
5
|
salePriceKey?: string;
|
|
6
6
|
regularPriceKey?: string;
|
|
@@ -9,5 +9,5 @@ interface ResultCardProps {
|
|
|
9
9
|
resultPosition: number;
|
|
10
10
|
renderResultCardPriceDetails?: (result: QuizResultDataPartial) => JSX.Element;
|
|
11
11
|
}
|
|
12
|
-
export default function ResultCard(props:
|
|
12
|
+
export default function ResultCard(props: ResultCardOptions): JSX.Element;
|
|
13
13
|
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { ResultCardOptions, ResultsPageOptions } from '../../types';
|
|
3
3
|
export interface IResultContainerProps {
|
|
4
|
-
|
|
4
|
+
resultCardOptions?: ResultCardOptions;
|
|
5
|
+
resultsPageOptions?: ResultsPageOptions;
|
|
6
|
+
onShare: () => void;
|
|
5
7
|
}
|
|
6
|
-
export default function ResultContainer(props: IResultContainerProps): JSX.Element;
|
|
8
|
+
export default function ResultContainer(props: IResultContainerProps): JSX.Element | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
interface ResultsProps extends
|
|
2
|
+
import { ResultCardOptions } from '../../types';
|
|
3
|
+
interface ResultsProps extends ResultCardOptions {
|
|
4
4
|
}
|
|
5
5
|
declare function Results(props: ResultsProps): JSX.Element;
|
|
6
6
|
export default Results;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { QuizResultsEventsProps, QuizReturnState } from '../../types';
|
|
3
|
+
interface ShareResultsModalProps {
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
quizState: QuizReturnState['quiz'];
|
|
6
|
+
onEmailResults?: QuizResultsEventsProps.OnEmailResults;
|
|
7
|
+
}
|
|
8
|
+
export default function ShareResultsModal({ onClose, quizState, onEmailResults, }: ShareResultsModalProps): JSX.Element;
|
|
9
|
+
export {};
|
package/lib/types/constants.d.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
export declare const apiKey = "key_wJSdZSiesX5hiVLt";
|
|
2
2
|
export declare const quizId = "coffee-quiz";
|
|
3
3
|
export declare const quizSessionStateKey = "constructorIOQuizState";
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const hookDescription = "- import `useCioQuiz` and call this custom hook in a functional component.\n- This hook leaves rendering logic up to you, while handling:\n - state management\n - data fetching\n - keyboard navigation\n - mouse interactions\n - focus and submit event handling\n- Since the markup is controlled by you, the default styles might not be applied if you have a different DOM structure\n- To use this hook, an `apiKey` and `quizId` are required, and `resultsPageOptions` must be passed to the `useCioQuiz` hook to configure behavior. All other values are optional.\n- use the <a href=\"https://kentcdodds.com/blog/how-to-give-rendering-control-to-users-with-prop-getters\" target=\"__blank\">prop getters</a> and other variables returned by this hook (below) to leverage the functionality described above with jsx elements in your react component definitions\n\nCalling the `useCioQuiz` hook returns an object with the following keys:\n\n```jsx\nconst {\n // must be used for a hooks integrations\n state: QuizReturnState, // Quiz state\n events: [{...}], // array of quiz events\n getAddToCartButtonProps: () => ({...})), // prop getter for jsx add to cart button for quiz result,\n getAddToFavoritesButtonProps: () => ({...})), // prop getter for jsx add to favorites button for quiz result,\n getCoverQuestionProps: () => ({...})), // prop getter for jsx quiz cover question,\n getHydrateQuizButtonProps: () => ({...})), // prop getter for jsx hydrate quiz button,\n getNextQuestionButtonProps: () => ({...})), // prop getter for jsx next button to traverse the quiz,\n getSkipQuestionButtonProps: () => ({...})), // prop getter for jsx skip button to traverse the quiz,\n getPreviousQuestionButtonProps: () => ({...})), // prop getter for jsx back button to traverse the quiz, \n getOpenTextInputProps: () => ({...})), // prop getter for jsx open text input,\n getSelectInputProps: () => ({...})), // prop getter for jsx select input for select type questions,\n getQuizImageProps: () => ({...})), // prop getter for jsx quiz image,\n getQuizResultButtonProps: () => ({...})), // prop getter for jsx result card click as a button,\n getQuizResultLinkProps: () => ({...})), // prop getter for jsx result card click as a link. Should be spread into <a> tags,\n getResetQuizButtonProps: () => ({...})), // prop getter for jsx reset quiz button,\n cioClient, // instance of constructorio-client-javascript\n } = useCioQuiz(args);\n```\n\n> Note: when we say `cioClient`, we are referring to an instance of the [constructorio-client-javascript](https://www.npmjs.com/package/@constructor-io/constructorio-client-javascript)\n";
|
|
4
|
+
export declare const hookDescription = "- Import `useCioQuiz` and call this custom hook in a functional component.\n- This hook leaves rendering logic up to you, while handling:\n - state management\n - data fetching\n - keyboard navigation\n - mouse interactions\n - focus and submit event handling\n- Since the markup is controlled by you, the default styles might not be applied if you have a different DOM structure\n- To use this hook, an `apiKey` and `quizId` are required, and `resultsPageOptions` must be passed to the `useCioQuiz` hook to configure behavior. All other values are optional.\n- Use the <a href=\"https://kentcdodds.com/blog/how-to-give-rendering-control-to-users-with-prop-getters\" target=\"__blank\">prop getters</a> and other variables returned by this hook (below) to leverage the functionality described above with jsx elements in your react component definitions\n\nCalling the `useCioQuiz` hook returns an object with the following keys:\n\n```jsx\nconst {\n // must be used for a hooks integrations\n state: QuizReturnState, // Quiz state\n events: [{...}], // array of quiz events\n getAddToCartButtonProps: () => ({...})), // prop getter for jsx add to cart button for quiz result,\n getAddToFavoritesButtonProps: () => ({...})), // prop getter for jsx add to favorites button for quiz result,\n getCoverQuestionProps: () => ({...})), // prop getter for jsx quiz cover question,\n getHydrateQuizButtonProps: () => ({...})), // prop getter for jsx hydrate quiz button,\n getNextQuestionButtonProps: () => ({...})), // prop getter for jsx next button to traverse the quiz,\n getSkipQuestionButtonProps: () => ({...})), // prop getter for jsx skip button to traverse the quiz,\n getPreviousQuestionButtonProps: () => ({...})), // prop getter for jsx back button to traverse the quiz, \n getOpenTextInputProps: () => ({...})), // prop getter for jsx open text input,\n getSelectInputProps: () => ({...})), // prop getter for jsx select input for select type questions,\n getQuizImageProps: () => ({...})), // prop getter for jsx quiz image,\n getQuizResultButtonProps: () => ({...})), // prop getter for jsx result card click as a button,\n getQuizResultLinkProps: () => ({...})), // prop getter for jsx result card click as a link. Should be spread into <a> tags,\n getResetQuizButtonProps: () => ({...})), // prop getter for jsx reset quiz button,\n cioClient, // instance of constructorio-client-javascript\n } = useCioQuiz(args);\n```\n\n> Note: when we say `cioClient`, we are referring to an instance of the [constructorio-client-javascript](https://www.npmjs.com/package/@constructor-io/constructorio-client-javascript)\n";
|
|
6
5
|
export declare const basicDescription = "Pass an `apiKey` and a `quizId` to request questions and quiz results from Constructor's servers";
|
|
7
|
-
export declare const cioJsClientDescription = "If you are already using an instance of the `ConstructorIOClient`, you can pass a `cioJsClient` instead of an `apiKey` to request results from Constructor's servers\n\n> Note: `cioJsClient` refers to an instance of the [constructorio-client-javascript](https://www.npmjs.com/package/@constructor-io/constructorio-client-javascript)";
|
|
8
6
|
export declare const smallContainerDescription = "If you are using the provided styles, CioQuiz component will respect the height and width of its parent container and use responsive styles based on the parent container's dimensions";
|
|
9
7
|
export declare const changePrimaryColorDescription = "\nIf you would like to use a different primary color, pass a `primaryColor` string in RGB format ('R, G, B').\n\nAccent colors for borders and different states (hover, focus, active) will be calculated automatically based on the primary color you provided.\n\nBy default, the primary color has a value of \"35, 71, 199\" (Constructor Blue).\n\nIn the example below, the `primaryColor` prop has been used to override this color to \"255, 82, 48\" (Orange).\n\n> Advanced Option: Instead of passing a primaryColor prop, you can also override `--primary-color-h`, `--primary-color-s`, and `--primary-color-l` CSS variables within a `.cio-quiz` container element. If explicitly given a value in your CSS, then the values of these variables will be used as the HSL values for your quiz.\n";
|
|
10
|
-
export declare const callbacksDescription = "Pass an `apiKey`, a `quizId`, and `callbacks`";
|
|
11
|
-
export declare const favoritesDescription = "\nAdd `const [favorites, setFavorites] = useState([]);` or equivalent to manage the favorite items' state.\n\nPass favorites as an array to `favoriteItems` in `resultsPageOptions` as a prop to CioQuiz.\n\nPass a callback function to `onAddToFavoritesClick` in `resultsPageOptions` as a prop to CioQuiz to handle favorites state changes to update `favorites` array. \n";
|
|
12
8
|
export declare enum RequestStates {
|
|
13
9
|
Stale = "STALE",
|
|
14
10
|
Loading = "LOADING",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GetResetQuizButtonProps, GetCoverQuestionProps, GetNextQuestionButtonProps, GetOpenTextInputProps, GetPreviousQuestionButtonProps, GetQuizImageProps, GetSelectInputProps, QuizEventsReturn, GetHydrateQuizButtonProps, GetAddToCartButtonProps, GetQuizResultButtonProps, GetQuizResultLinkProps, GetSelectQuestionImageProps, GetAddToFavoritesButtonProps, GetSkipQuestionButtonProps } from '../../types';
|
|
1
|
+
import { GetResetQuizButtonProps, GetCoverQuestionProps, GetNextQuestionButtonProps, GetOpenTextInputProps, GetPreviousQuestionButtonProps, GetQuizImageProps, GetSelectInputProps, QuizEventsReturn, GetHydrateQuizButtonProps, GetAddToCartButtonProps, GetQuizResultButtonProps, GetQuizResultLinkProps, GetSelectQuestionImageProps, GetAddToFavoritesButtonProps, GetSkipQuestionButtonProps, GetShareResultsButtonProps } from '../../types';
|
|
2
2
|
import { QuizAPIReducerState } from '../../components/CioQuiz/quizApiReducer';
|
|
3
3
|
import { QuizLocalReducerState } from '../../components/CioQuiz/quizLocalReducer';
|
|
4
4
|
declare const usePropsGetters: (quizEvents: QuizEventsReturn, quizApiState: QuizAPIReducerState, quizLocalState: QuizLocalReducerState, favoriteItems?: string[]) => {
|
|
@@ -10,6 +10,7 @@ declare const usePropsGetters: (quizEvents: QuizEventsReturn, quizApiState: Quiz
|
|
|
10
10
|
getSelectInputProps: GetSelectInputProps;
|
|
11
11
|
getCoverQuestionProps: GetCoverQuestionProps;
|
|
12
12
|
getResetQuizButtonProps: GetResetQuizButtonProps;
|
|
13
|
+
getShareResultsButtonProps: GetShareResultsButtonProps;
|
|
13
14
|
getHydrateQuizButtonProps: GetHydrateQuizButtonProps;
|
|
14
15
|
getAddToCartButtonProps: GetAddToCartButtonProps;
|
|
15
16
|
getAddToFavoritesButtonProps: GetAddToFavoritesButtonProps;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ActionAnswerQuestion } from '../../components/CioQuiz/actions';
|
|
2
2
|
import { QuizAPIReducerState } from '../../components/CioQuiz/quizApiReducer';
|
|
3
3
|
import { QuizLocalReducerState } from '../../components/CioQuiz/quizLocalReducer';
|
|
4
|
-
import { QuizEventsReturn,
|
|
5
|
-
declare const useQuizNextClick: (quizApiState: QuizAPIReducerState, quizLocalState: QuizLocalReducerState, dispatchLocalState: React.Dispatch<ActionAnswerQuestion>, onQuizNextQuestion?: OnQuizNextQuestion) => QuizEventsReturn.NextQuestion;
|
|
4
|
+
import { QuizEventsReturn, QuizResultsEventsProps } from '../../types';
|
|
5
|
+
declare const useQuizNextClick: (quizApiState: QuizAPIReducerState, quizLocalState: QuizLocalReducerState, dispatchLocalState: React.Dispatch<ActionAnswerQuestion>, onQuizNextQuestion?: QuizResultsEventsProps.OnQuizNextQuestion) => QuizEventsReturn.NextQuestion;
|
|
6
6
|
export default useQuizNextClick;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { ActionAnswerQuestion, ActionQuizAPI } from '../../components/CioQuiz/actions';
|
|
2
|
-
import { QuizEventsReturn, QuizResultsResponse } from '../../types';
|
|
3
|
-
|
|
3
|
+
import { QuizEventsReturn, QuizResultsResponse, QuizSharedResultsData } from '../../types';
|
|
4
|
+
type IUseQuizResetClickProps = {
|
|
5
|
+
resetQuizSessionStorageState: () => void;
|
|
6
|
+
dispatchLocalState: React.Dispatch<ActionAnswerQuestion>;
|
|
7
|
+
dispatchApiState: React.Dispatch<ActionQuizAPI>;
|
|
8
|
+
quizResults?: QuizResultsResponse | QuizSharedResultsData;
|
|
9
|
+
};
|
|
10
|
+
declare const useQuizResetClick: (props: IUseQuizResetClickProps) => QuizEventsReturn.NextQuestion;
|
|
4
11
|
export default useQuizResetClick;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ActionAnswerQuestion } from '../../components/CioQuiz/actions';
|
|
2
2
|
import { QuizAPIReducerState } from '../../components/CioQuiz/quizApiReducer';
|
|
3
3
|
import { QuizLocalReducerState } from '../../components/CioQuiz/quizLocalReducer';
|
|
4
|
-
import { QuizEventsReturn,
|
|
5
|
-
declare const useQuizSkipClick: (quizApiState: QuizAPIReducerState, quizLocalState: QuizLocalReducerState, dispatchLocalState: React.Dispatch<ActionAnswerQuestion>, onQuizSkipQuestion?: OnQuizSkipQuestion) => QuizEventsReturn.NextQuestion;
|
|
4
|
+
import { QuizEventsReturn, QuizResultsEventsProps } from '../../types';
|
|
5
|
+
declare const useQuizSkipClick: (quizApiState: QuizAPIReducerState, quizLocalState: QuizLocalReducerState, dispatchLocalState: React.Dispatch<ActionAnswerQuestion>, onQuizSkipQuestion?: QuizResultsEventsProps.OnQuizSkipQuestion) => QuizEventsReturn.NextQuestion;
|
|
6
6
|
export default useQuizSkipClick;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import CioQuiz from './components/CioQuiz';
|
|
2
2
|
export { default as useCioQuiz } from './hooks/useQuiz';
|
|
3
|
+
export { default as useShareResultsLink } from './hooks/useShareResultsLink';
|
|
3
4
|
export { default as QuizQuestions } from './components/QuizQuestions/index';
|
|
4
5
|
export { default as OpenTextQuestion } from './components/OpenTextTypeQuestion/OpenTextTypeQuestion';
|
|
5
6
|
export { default as CoverQuestion } from './components/CoverTypeQuestion/CoverTypeQuestion';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import ConstructorIOClient from '@constructor-io/constructorio-client-javascript';
|
|
2
|
-
import { QuizzesParameters, QuizzesResultsParameters, NextQuestionResponse, QuizResultsResponse, QuizResultDataPartial } from '../types';
|
|
1
|
+
import ConstructorIOClient, { type GetBrowseResultsForItemIdsResponse } from '@constructor-io/constructorio-client-javascript';
|
|
2
|
+
import { QuizzesParameters, QuizzesResultsParameters, NextQuestionResponse, QuizResultsResponse, QuizResultDataPartial, QuizSharedResultsData } from '../types';
|
|
3
3
|
export declare const getCioClient: (apiKey?: string) => ConstructorIOClient | undefined;
|
|
4
4
|
export declare const getNextQuestion: (cioClient: ConstructorIOClient, quizId: string, parameters: QuizzesParameters) => Promise<NextQuestionResponse>;
|
|
5
5
|
export declare const getQuizResults: (cioClient: ConstructorIOClient, quizId: string, parameters: QuizzesResultsParameters) => Promise<QuizResultsResponse>;
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
6
|
+
export declare const getBrowseResultsForItemIds: (cioClient: ConstructorIOClient, itemIds: string[]) => Promise<GetBrowseResultsForItemIdsResponse>;
|
|
7
|
+
export declare const trackQuizResultsLoaded: (cioClient: ConstructorIOClient, quizResults: QuizResultsResponse | QuizSharedResultsData) => void;
|
|
8
|
+
export declare const trackQuizResultClick: (cioClient: ConstructorIOClient, quizResults: QuizResultsResponse | QuizSharedResultsData, result: QuizResultDataPartial, position: number) => void;
|
|
9
|
+
export declare const trackQuizConversion: (cioClient: ConstructorIOClient, quizResults: QuizResultsResponse | QuizSharedResultsData, result: QuizResultDataPartial, price?: number, type?: string) => void;
|