@skyscanner/backpack-web 42.7.0 → 42.8.0
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/bpk-component-ai-blurb/index.d.ts +3 -0
- package/bpk-component-ai-blurb/index.js +20 -0
- package/bpk-component-ai-blurb/src/BpkAiBlurb.d.ts +29 -0
- package/bpk-component-ai-blurb/src/BpkAiBlurb.js +57 -0
- package/bpk-component-ai-blurb/src/BpkAiBlurb.module.css +18 -0
- package/bpk-component-ai-blurb/src/BpkAiBlurbEllipsis.d.ts +2 -0
- package/bpk-component-ai-blurb/src/BpkAiBlurbEllipsis.js +40 -0
- package/bpk-component-ai-blurb/src/BpkAiBlurbFeedback.d.ts +3 -0
- package/bpk-component-ai-blurb/src/BpkAiBlurbFeedback.js +74 -0
- package/bpk-component-ai-blurb/src/BpkAiBlurbHeader.d.ts +3 -0
- package/bpk-component-ai-blurb/src/BpkAiBlurbHeader.js +41 -0
- package/bpk-component-ai-blurb/src/BpkAiBlurbRoot.d.ts +3 -0
- package/bpk-component-ai-blurb/src/BpkAiBlurbRoot.js +30 -0
- package/bpk-component-ai-blurb/src/BpkAiBlurbSummary.d.ts +3 -0
- package/bpk-component-ai-blurb/src/BpkAiBlurbSummary.js +54 -0
- package/bpk-component-ai-blurb/src/common-types.d.ts +66 -0
- package/bpk-component-ai-blurb/src/common-types.js +1 -0
- package/bpk-mixins/_focus-indicator-v2.scss +85 -0
- package/bpk-mixins/_index.scss +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import BpkAiBlurb from "./src/BpkAiBlurb";
|
|
20
|
+
export default BpkAiBlurb;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { BpkAiBlurbNamespace } from './common-types';
|
|
2
|
+
/**
|
|
3
|
+
* BpkAiBlurb is a composable component for displaying AI-generated summaries.
|
|
4
|
+
*
|
|
5
|
+
* Compose subcomponents to build each state:
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // Loading state
|
|
9
|
+
* <BpkAiBlurb.Root>
|
|
10
|
+
* <BpkAiBlurb.Header title="Summarized by AI" />
|
|
11
|
+
* <BpkAiBlurb.Summary state="thinking" thinkingText="Comparing your shortlist" />
|
|
12
|
+
* </BpkAiBlurb.Root>
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Success state with feedback
|
|
16
|
+
* <BpkAiBlurb.Root>
|
|
17
|
+
* <BpkAiBlurb.Header title="Summarized by AI" />
|
|
18
|
+
* <BpkAiBlurb.Summary state="aiResponse" aiResponseText={llmText} />
|
|
19
|
+
* <BpkAiBlurb.Feedback
|
|
20
|
+
* feedbackText="Was this helpful?"
|
|
21
|
+
* thankYouText="Thanks for your feedback!"
|
|
22
|
+
* thumbsUpLabel="Thumbs up"
|
|
23
|
+
* thumbsDownLabel="Thumbs down"
|
|
24
|
+
* onFeedback={(positive) => trackEvent(positive ? 'thumb_up' : 'thumb_down')}
|
|
25
|
+
* />
|
|
26
|
+
* </BpkAiBlurb.Root>
|
|
27
|
+
*/
|
|
28
|
+
declare const BpkAiBlurb: BpkAiBlurbNamespace;
|
|
29
|
+
export default BpkAiBlurb;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import BpkAiBlurbEllipsis from "./BpkAiBlurbEllipsis";
|
|
20
|
+
import BpkAiBlurbFeedback from "./BpkAiBlurbFeedback";
|
|
21
|
+
import BpkAiBlurbHeader from "./BpkAiBlurbHeader";
|
|
22
|
+
import BpkAiBlurbRoot from "./BpkAiBlurbRoot";
|
|
23
|
+
import BpkAiBlurbSummary from "./BpkAiBlurbSummary";
|
|
24
|
+
/**
|
|
25
|
+
* BpkAiBlurb is a composable component for displaying AI-generated summaries.
|
|
26
|
+
*
|
|
27
|
+
* Compose subcomponents to build each state:
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Loading state
|
|
31
|
+
* <BpkAiBlurb.Root>
|
|
32
|
+
* <BpkAiBlurb.Header title="Summarized by AI" />
|
|
33
|
+
* <BpkAiBlurb.Summary state="thinking" thinkingText="Comparing your shortlist" />
|
|
34
|
+
* </BpkAiBlurb.Root>
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // Success state with feedback
|
|
38
|
+
* <BpkAiBlurb.Root>
|
|
39
|
+
* <BpkAiBlurb.Header title="Summarized by AI" />
|
|
40
|
+
* <BpkAiBlurb.Summary state="aiResponse" aiResponseText={llmText} />
|
|
41
|
+
* <BpkAiBlurb.Feedback
|
|
42
|
+
* feedbackText="Was this helpful?"
|
|
43
|
+
* thankYouText="Thanks for your feedback!"
|
|
44
|
+
* thumbsUpLabel="Thumbs up"
|
|
45
|
+
* thumbsDownLabel="Thumbs down"
|
|
46
|
+
* onFeedback={(positive) => trackEvent(positive ? 'thumb_up' : 'thumb_down')}
|
|
47
|
+
* />
|
|
48
|
+
* </BpkAiBlurb.Root>
|
|
49
|
+
*/
|
|
50
|
+
const BpkAiBlurb = {
|
|
51
|
+
Root: BpkAiBlurbRoot,
|
|
52
|
+
Header: BpkAiBlurbHeader,
|
|
53
|
+
Summary: BpkAiBlurbSummary,
|
|
54
|
+
Ellipsis: BpkAiBlurbEllipsis,
|
|
55
|
+
Feedback: BpkAiBlurbFeedback
|
|
56
|
+
};
|
|
57
|
+
export default BpkAiBlurb;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
.bpk-ai-blurb{display:flex;flex-direction:column;gap:.5rem}.bpk-ai-blurb__header{color:#626971}.bpk-ai-blurb__header svg{fill:currentcolor}.bpk-ai-blurb__summary{display:block}.bpk-ai-blurb__error{display:flex;margin:0;flex-wrap:wrap;align-items:baseline;gap:0 .25rem;font-size:.75rem;line-height:1rem;font-weight:400}.bpk-ai-blurb__feedback-thumb{display:inline-flex;padding:0;align-items:center;border:none;background:none;color:#161616;cursor:pointer;font-size:.75rem;line-height:1rem;font-weight:400}.bpk-ai-blurb__feedback-thumb svg{fill:currentcolor}.bpk-ai-blurb__feedback-thumb:hover{color:#626971}.bpk-ai-blurb__feedback-thumb:focus-visible{outline:.125rem solid #0062e3;outline-offset:.125rem}.bpk-ai-blurb__ellipsis{display:inline;vertical-align:baseline;margin-inline-start:.25rem}.bpk-ai-blurb__ellipsis-dot{display:inline;opacity:0;vertical-align:baseline;animation:bpk-ai-blurb-ellipsis-dot-1 1.2s infinite step-end}@media(prefers-reduced-motion: reduce){.bpk-ai-blurb__ellipsis-dot{opacity:1;animation:none}}.bpk-ai-blurb__ellipsis-dot--2{animation-name:bpk-ai-blurb-ellipsis-dot-2}.bpk-ai-blurb__ellipsis-dot--3{animation-name:bpk-ai-blurb-ellipsis-dot-3}@keyframes bpk-ai-blurb-ellipsis-dot-1{0%{opacity:1}75%{opacity:0}100%{opacity:0}}@keyframes bpk-ai-blurb-ellipsis-dot-2{0%{opacity:0}25%{opacity:1}75%{opacity:0}100%{opacity:0}}@keyframes bpk-ai-blurb-ellipsis-dot-3{0%{opacity:0}50%{opacity:1}75%{opacity:0}100%{opacity:0}}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { cssModules } from "../../bpk-react-utils";
|
|
20
|
+
import STYLES from "./BpkAiBlurb.module.css";
|
|
21
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
+
const getClassName = cssModules(STYLES);
|
|
23
|
+
|
|
24
|
+
// Animated three-dot ellipsis for inline use at the end of loading text.
|
|
25
|
+
// Hidden from assistive technology — ensure surrounding text provides context.
|
|
26
|
+
const BpkAiBlurbEllipsis = () => /*#__PURE__*/_jsxs("span", {
|
|
27
|
+
className: getClassName('bpk-ai-blurb__ellipsis'),
|
|
28
|
+
"aria-hidden": "true",
|
|
29
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
30
|
+
className: getClassName('bpk-ai-blurb__ellipsis-dot'),
|
|
31
|
+
children: "."
|
|
32
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
33
|
+
className: getClassName('bpk-ai-blurb__ellipsis-dot', 'bpk-ai-blurb__ellipsis-dot--2'),
|
|
34
|
+
children: "."
|
|
35
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
36
|
+
className: getClassName('bpk-ai-blurb__ellipsis-dot', 'bpk-ai-blurb__ellipsis-dot--3'),
|
|
37
|
+
children: "."
|
|
38
|
+
})]
|
|
39
|
+
});
|
|
40
|
+
export default BpkAiBlurbEllipsis;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { BpkAiBlurbFeedbackProps } from './common-types';
|
|
2
|
+
declare const BpkAiBlurbFeedback: ({ feedbackText, onFeedback, thankYouText, thumbsDownLabel, thumbsUpLabel, }: BpkAiBlurbFeedbackProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export default BpkAiBlurbFeedback;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { useState } from 'react';
|
|
20
|
+
import BpkAriaLive from "../../bpk-component-aria-live";
|
|
21
|
+
import BpkSmallThumbsDownIcon from "../../bpk-component-icon/sm/thumbs-down";
|
|
22
|
+
import BpkSmallThumbsUpIcon from "../../bpk-component-icon/sm/thumbs-up";
|
|
23
|
+
import { BpkFlex, BpkSpacing } from "../../bpk-component-layout";
|
|
24
|
+
import BpkText, { TEXT_STYLES } from "../../bpk-component-text";
|
|
25
|
+
import { cssModules } from "../../bpk-react-utils";
|
|
26
|
+
import STYLES from "./BpkAiBlurb.module.css";
|
|
27
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
|
+
const getClassName = cssModules(STYLES);
|
|
29
|
+
const BpkAiBlurbFeedback = ({
|
|
30
|
+
feedbackText,
|
|
31
|
+
onFeedback,
|
|
32
|
+
thankYouText,
|
|
33
|
+
thumbsDownLabel,
|
|
34
|
+
thumbsUpLabel
|
|
35
|
+
}) => {
|
|
36
|
+
const [hasVoted, setHasVoted] = useState(false);
|
|
37
|
+
const handleVote = positive => {
|
|
38
|
+
setHasVoted(true);
|
|
39
|
+
onFeedback?.(positive);
|
|
40
|
+
};
|
|
41
|
+
return /*#__PURE__*/_jsxs(BpkFlex, {
|
|
42
|
+
align: "center",
|
|
43
|
+
gap: BpkSpacing.SM,
|
|
44
|
+
children: [!hasVoted && /*#__PURE__*/_jsxs(_Fragment, {
|
|
45
|
+
children: [/*#__PURE__*/_jsx(BpkText, {
|
|
46
|
+
textStyle: TEXT_STYLES.caption,
|
|
47
|
+
children: feedbackText
|
|
48
|
+
}), /*#__PURE__*/_jsx("button", {
|
|
49
|
+
type: "button",
|
|
50
|
+
className: getClassName('bpk-ai-blurb__feedback-thumb'),
|
|
51
|
+
onClick: () => handleVote(true),
|
|
52
|
+
"aria-label": thumbsUpLabel,
|
|
53
|
+
children: /*#__PURE__*/_jsx(BpkSmallThumbsUpIcon, {
|
|
54
|
+
"aria-hidden": true
|
|
55
|
+
})
|
|
56
|
+
}), /*#__PURE__*/_jsx("button", {
|
|
57
|
+
type: "button",
|
|
58
|
+
className: getClassName('bpk-ai-blurb__feedback-thumb'),
|
|
59
|
+
onClick: () => handleVote(false),
|
|
60
|
+
"aria-label": thumbsDownLabel,
|
|
61
|
+
children: /*#__PURE__*/_jsx(BpkSmallThumbsDownIcon, {
|
|
62
|
+
"aria-hidden": true
|
|
63
|
+
})
|
|
64
|
+
})]
|
|
65
|
+
}), /*#__PURE__*/_jsx(BpkAriaLive, {
|
|
66
|
+
visible: hasVoted,
|
|
67
|
+
children: hasVoted ? /*#__PURE__*/_jsx(BpkText, {
|
|
68
|
+
textStyle: TEXT_STYLES.caption,
|
|
69
|
+
children: thankYouText
|
|
70
|
+
}) : ''
|
|
71
|
+
})]
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
export default BpkAiBlurbFeedback;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import AiIcon from "../../bpk-component-icon/sm/ai";
|
|
20
|
+
import { BpkFlex, BpkSpacing } from "../../bpk-component-layout";
|
|
21
|
+
import BpkText, { TEXT_STYLES } from "../../bpk-component-text";
|
|
22
|
+
import { cssModules } from "../../bpk-react-utils";
|
|
23
|
+
import STYLES from "./BpkAiBlurb.module.css";
|
|
24
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
|
+
const getClassName = cssModules(STYLES);
|
|
26
|
+
const BpkAiBlurbHeader = ({
|
|
27
|
+
title
|
|
28
|
+
}) => /*#__PURE__*/_jsx("div", {
|
|
29
|
+
className: getClassName('bpk-ai-blurb__header'),
|
|
30
|
+
children: /*#__PURE__*/_jsxs(BpkFlex, {
|
|
31
|
+
align: "center",
|
|
32
|
+
gap: BpkSpacing.SM,
|
|
33
|
+
children: [/*#__PURE__*/_jsx(AiIcon, {
|
|
34
|
+
"aria-hidden": true
|
|
35
|
+
}), /*#__PURE__*/_jsx(BpkText, {
|
|
36
|
+
textStyle: TEXT_STYLES.caption,
|
|
37
|
+
children: title
|
|
38
|
+
})]
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
export default BpkAiBlurbHeader;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
|
|
20
|
+
import STYLES from "./BpkAiBlurb.module.css";
|
|
21
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
+
const getClassName = cssModules(STYLES);
|
|
23
|
+
const BpkAiBlurbRoot = ({
|
|
24
|
+
children
|
|
25
|
+
}) => /*#__PURE__*/_jsx("div", {
|
|
26
|
+
className: getClassName('bpk-ai-blurb'),
|
|
27
|
+
...getDataComponentAttribute('AiBlurb'),
|
|
28
|
+
children: children
|
|
29
|
+
});
|
|
30
|
+
export default BpkAiBlurbRoot;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import BpkLink from "../../bpk-component-link";
|
|
20
|
+
import BpkText, { TEXT_STYLES } from "../../bpk-component-text";
|
|
21
|
+
import { cssModules } from "../../bpk-react-utils";
|
|
22
|
+
import BpkAiBlurbEllipsis from "./BpkAiBlurbEllipsis";
|
|
23
|
+
import STYLES from "./BpkAiBlurb.module.css";
|
|
24
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
|
+
const getClassName = cssModules(STYLES);
|
|
26
|
+
const BpkAiBlurbSummary = props => {
|
|
27
|
+
let content;
|
|
28
|
+
if (props.state === 'aiResponse') {
|
|
29
|
+
content = props.aiResponseText;
|
|
30
|
+
} else if (props.state === 'thinking') {
|
|
31
|
+
content = /*#__PURE__*/_jsxs(BpkText, {
|
|
32
|
+
tagName: "p",
|
|
33
|
+
textStyle: TEXT_STYLES.caption,
|
|
34
|
+
children: [props.thinkingText, /*#__PURE__*/_jsx(BpkAiBlurbEllipsis, {})]
|
|
35
|
+
});
|
|
36
|
+
} else {
|
|
37
|
+
content = /*#__PURE__*/_jsxs("div", {
|
|
38
|
+
className: getClassName('bpk-ai-blurb__error'),
|
|
39
|
+
children: [/*#__PURE__*/_jsx(BpkText, {
|
|
40
|
+
tagName: "span",
|
|
41
|
+
textStyle: TEXT_STYLES.caption,
|
|
42
|
+
children: props.errorText
|
|
43
|
+
}), /*#__PURE__*/_jsx(BpkLink, {
|
|
44
|
+
href: props.errorLinkHref,
|
|
45
|
+
children: props.errorLinkText
|
|
46
|
+
})]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return /*#__PURE__*/_jsx("div", {
|
|
50
|
+
className: getClassName('bpk-ai-blurb__summary'),
|
|
51
|
+
children: content
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
export default BpkAiBlurbSummary;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export type BpkAiBlurbRootProps = {
|
|
3
|
+
/** Content to render inside the AI summary container */
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
};
|
|
6
|
+
export type BpkAiBlurbHeaderProps = {
|
|
7
|
+
/** Title string displayed next to the AI spark icon. Not translated by Backpack. */
|
|
8
|
+
title: string;
|
|
9
|
+
};
|
|
10
|
+
export type BpkAiBlurbSummaryProps = {
|
|
11
|
+
/** Controls which content is displayed. */
|
|
12
|
+
state: 'aiResponse';
|
|
13
|
+
/** AI response content. Consumer controls formatting. */
|
|
14
|
+
aiResponseText: ReactNode;
|
|
15
|
+
} | {
|
|
16
|
+
/** Controls which content is displayed. */
|
|
17
|
+
state: 'thinking';
|
|
18
|
+
/** Text displayed followed by an animated ellipsis. */
|
|
19
|
+
thinkingText: string;
|
|
20
|
+
} | {
|
|
21
|
+
/** Controls which content is displayed. */
|
|
22
|
+
state: 'error';
|
|
23
|
+
/** Text displayed before the error link. */
|
|
24
|
+
errorText: string;
|
|
25
|
+
/** Text for the inline error link. */
|
|
26
|
+
errorLinkText: string;
|
|
27
|
+
/** href for the inline error link. */
|
|
28
|
+
errorLinkHref: string;
|
|
29
|
+
};
|
|
30
|
+
export type BpkAiBlurbFeedbackProps = {
|
|
31
|
+
/** Text displayed before a vote is cast. e.g. "Was this helpful?" — not translated by Backpack. */
|
|
32
|
+
feedbackText: string;
|
|
33
|
+
/** Text displayed after a vote is cast. e.g. "Thanks for your feedback!" — not translated by Backpack. */
|
|
34
|
+
thankYouText: string;
|
|
35
|
+
/** Accessible label for the thumbs-up button. Not translated by Backpack. */
|
|
36
|
+
thumbsUpLabel: string;
|
|
37
|
+
/** Accessible label for the thumbs-down button. Not translated by Backpack. */
|
|
38
|
+
thumbsDownLabel: string;
|
|
39
|
+
/**
|
|
40
|
+
* Called when either thumb button is pressed.
|
|
41
|
+
* `positive` is `true` for thumbs-up, `false` for thumbs-down.
|
|
42
|
+
*/
|
|
43
|
+
onFeedback?: (positive: boolean) => void;
|
|
44
|
+
};
|
|
45
|
+
export type BpkAiBlurbNamespace = {
|
|
46
|
+
Root: {
|
|
47
|
+
(props: BpkAiBlurbRootProps): ReactNode;
|
|
48
|
+
displayName?: string;
|
|
49
|
+
};
|
|
50
|
+
Header: {
|
|
51
|
+
(props: BpkAiBlurbHeaderProps): ReactNode;
|
|
52
|
+
displayName?: string;
|
|
53
|
+
};
|
|
54
|
+
Summary: {
|
|
55
|
+
(props: BpkAiBlurbSummaryProps): ReactNode;
|
|
56
|
+
displayName?: string;
|
|
57
|
+
};
|
|
58
|
+
Ellipsis: {
|
|
59
|
+
(): ReactNode;
|
|
60
|
+
displayName?: string;
|
|
61
|
+
};
|
|
62
|
+
Feedback: {
|
|
63
|
+
(props: BpkAiBlurbFeedbackProps): ReactNode;
|
|
64
|
+
displayName?: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
@use 'tokens';
|
|
20
|
+
|
|
21
|
+
////
|
|
22
|
+
/// @group focus-indicator-v2
|
|
23
|
+
////
|
|
24
|
+
|
|
25
|
+
/// V2 focus indicator — base/mobile style.
|
|
26
|
+
/// Applies an accent-coloured outline suitable for inputs, buttons and calendar elements.
|
|
27
|
+
///
|
|
28
|
+
/// @example scss
|
|
29
|
+
/// .selector {
|
|
30
|
+
/// &:focus-visible {
|
|
31
|
+
/// @include bpk-focus-indicator-v2();
|
|
32
|
+
/// }
|
|
33
|
+
/// }
|
|
34
|
+
|
|
35
|
+
@mixin bpk-focus-indicator-v2 {
|
|
36
|
+
border-color: tokens.$bpk-core-accent-day;
|
|
37
|
+
outline-color: tokens.$bpk-core-accent-day;
|
|
38
|
+
outline-style: auto;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/// V2 focus indicator — desktop enhanced style.
|
|
42
|
+
/// Applies an inset focus ring with a canvas-coloured box-shadow gap for higher
|
|
43
|
+
/// visibility on desktop viewports. Typically combined with `bpk-focus-indicator-v2`.
|
|
44
|
+
///
|
|
45
|
+
/// @example scss
|
|
46
|
+
/// .selector {
|
|
47
|
+
/// &:focus-visible {
|
|
48
|
+
/// @include bpk-focus-indicator-v2();
|
|
49
|
+
///
|
|
50
|
+
/// @include breakpoints.bpk-breakpoint-above-mobile {
|
|
51
|
+
/// @include bpk-focus-indicator-v2-desktop();
|
|
52
|
+
/// }
|
|
53
|
+
/// }
|
|
54
|
+
/// }
|
|
55
|
+
|
|
56
|
+
@mixin bpk-focus-indicator-v2-desktop {
|
|
57
|
+
outline-color: tokens.$bpk-core-accent-day;
|
|
58
|
+
outline-offset: calc(-1 * tokens.bpk-spacing-sm() * 0.75);
|
|
59
|
+
outline-style: solid;
|
|
60
|
+
outline-width: tokens.bpk-spacing-sm();
|
|
61
|
+
box-shadow: 0 0 0 calc(tokens.$bpk-one-pixel-rem * 2) tokens.$bpk-canvas-day;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/// V2 focus indicator — desktop reset.
|
|
65
|
+
/// Resets the desktop inset focus styles so that the base/mobile indicator is
|
|
66
|
+
/// restored. Useful inside mobile-specific breakpoint overrides.
|
|
67
|
+
///
|
|
68
|
+
/// @example scss
|
|
69
|
+
/// .selector {
|
|
70
|
+
/// &:focus-visible {
|
|
71
|
+
/// @include bpk-focus-indicator-v2();
|
|
72
|
+
/// @include bpk-focus-indicator-v2-desktop();
|
|
73
|
+
///
|
|
74
|
+
/// @include breakpoints.bpk-breakpoint-mobile {
|
|
75
|
+
/// @include bpk-focus-indicator-v2-desktop-reset();
|
|
76
|
+
/// }
|
|
77
|
+
/// }
|
|
78
|
+
/// }
|
|
79
|
+
|
|
80
|
+
@mixin bpk-focus-indicator-v2-desktop-reset {
|
|
81
|
+
outline-offset: 0;
|
|
82
|
+
outline-style: auto;
|
|
83
|
+
outline-width: initial;
|
|
84
|
+
box-shadow: none;
|
|
85
|
+
}
|
package/bpk-mixins/_index.scss
CHANGED