|
| 1 | +import { tcls } from '@/lib/tailwind'; |
| 2 | +import { Icon } from '@gitbook/icons'; |
1 | 3 | import type React from 'react';
|
2 | 4 |
|
3 | 5 | interface AIChatIconProps extends React.SVGProps<SVGSVGElement> {
|
4 | 6 | className?: string;
|
5 | 7 | size?: number;
|
6 |
| - state?: 'thinking' | 'default'; |
| 8 | + state?: 'default' | 'intro' | 'thinking' | 'working' | 'done' | 'error'; |
| 9 | + trademark?: boolean; |
7 | 10 | }
|
8 | 11 |
|
9 | 12 | const AIChatIcon = ({
|
10 | 13 | className = 'size-4',
|
11 | 14 | size,
|
| 15 | + trademark = true, |
12 | 16 | state = 'default',
|
13 | 17 | ...props
|
14 | 18 | }: AIChatIconProps) => {
|
| 19 | + if (!trademark) { |
| 20 | + return ( |
| 21 | + <Icon |
| 22 | + icon="sparkle" |
| 23 | + className={tcls( |
| 24 | + className, |
| 25 | + state === 'thinking' || state === 'working' |
| 26 | + ? 'animate-[spin_2s_infinite_forwards_cubic-bezier(0.16,1,0.3,1)]' |
| 27 | + : '' |
| 28 | + )} |
| 29 | + /> |
| 30 | + ); |
| 31 | + } |
| 32 | + |
15 | 33 | return (
|
16 | 34 | <svg
|
17 | 35 | width="16"
|
18 | 36 | height="16"
|
19 | 37 | viewBox="0 0 16 16"
|
20 |
| - fill="none" |
21 |
| - xmlns="http://www.w3.org/2000/svg" |
| 38 | + preserveAspectRatio="xMaxYMid meet" |
22 | 39 | className={className}
|
23 |
| - {...(size && { width: size, height: size })} |
| 40 | + aria-busy={state === 'thinking'} |
24 | 41 | {...props}
|
| 42 | + fill="none" |
| 43 | + xmlns="http://www.w3.org/2000/svg" |
25 | 44 | >
|
26 |
| - <title>Docs Assistant</title> |
| 45 | + <title>GitBook Assistant</title> |
| 46 | + |
| 47 | + {/* Sparkle */} |
27 | 48 | <path
|
28 | 49 | d="M12.8916 1.06265C12.921 0.979101 13.0392 0.979127 13.0685 1.06267C13.239 1.5478 13.3439 1.84646 13.516 2.1032C13.6683 2.33042 13.8578 2.53033 14.0766 2.6945C14.3239 2.88 14.6165 3.00068 15.0919 3.19671C15.1761 3.23142 15.1761 3.3506 15.0919 3.38531C14.6165 3.58134 14.3239 3.70203 14.0766 3.88752C13.8578 4.05169 13.6683 4.2516 13.516 4.47882C13.3439 4.73556 13.239 5.03423 13.0685 5.51937C13.0392 5.60291 12.921 5.60292 12.8916 5.51938C12.7212 5.03423 12.6162 4.73557 12.4442 4.47882C12.2919 4.2516 12.1023 4.05169 11.8835 3.88752C11.6363 3.70202 11.3436 3.58134 10.8682 3.38531C10.7841 3.3506 10.7841 3.23141 10.8683 3.1967C11.3436 3.00067 11.6363 2.87999 11.8835 2.6945C12.1023 2.53033 12.2919 2.33042 12.4442 2.1032C12.6162 1.84646 12.7212 1.54779 12.8916 1.06265Z"
|
29 | 50 | stroke="currentColor"
|
30 | 51 | strokeWidth="1.2"
|
31 | 52 | strokeLinejoin="round"
|
32 |
| - className={state === 'thinking' ? 'animate-spin' : ''} |
| 53 | + className={tcls( |
| 54 | + state === 'intro' && |
| 55 | + 'animate-[fadeIn_.5s_.7s_both,spin_2s_1s_forwards_cubic-bezier(.43,1.54,.64,1)]', |
| 56 | + (state === 'working' || state === 'thinking') && |
| 57 | + 'animate-[fadeIn_.5s_.3s_both,spin_2s_infinite_forwards_cubic-bezier(0.16,1,0.3,1)]', |
| 58 | + state === 'done' && 'animate-[fadeOut_.5s_both]', |
| 59 | + state === 'default' && 'animate-[fadeIn_0s_both]', |
| 60 | + state === 'error' && 'hidden' |
| 61 | + )} |
33 | 62 | style={{ transformOrigin: '13px 3.5px' }}
|
34 | 63 | />
|
| 64 | + |
| 65 | + {/* Error */} |
| 66 | + <g |
| 67 | + clipPath="url(#clip0_153_2034)" |
| 68 | + className={tcls(state === 'error' ? 'animate-[fadeIn_.5s_.3s_both]' : 'hidden')} |
| 69 | + > |
| 70 | + <path |
| 71 | + d="M13.0312 1.42059L13.0312 3.95184" |
| 72 | + stroke="currentColor" |
| 73 | + strokeWidth="1.2" |
| 74 | + strokeLinecap="round" |
| 75 | + /> |
| 76 | + <path |
| 77 | + d="M13.0312 6.00253V6.00263" |
| 78 | + stroke="currentColor" |
| 79 | + strokeWidth="1.2" |
| 80 | + strokeLinecap="round" |
| 81 | + /> |
| 82 | + </g> |
| 83 | + |
| 84 | + {/* Check */} |
35 | 85 | <path
|
36 |
| - d="M9.479 10.2734C9.479 11.2369 8.6115 11.2578 7.54138 11.2578C6.47126 11.2578 5.60376 11.2369 5.60376 10.2734" |
37 |
| - stroke="currentColor" |
38 |
| - strokeWidth="1.2" |
39 |
| - strokeLinecap="round" |
40 |
| - /> |
41 |
| - <path |
42 |
| - d="M9.47913 6.77344L9.47913 7.77344" |
43 |
| - stroke="currentColor" |
44 |
| - strokeWidth="1.2" |
45 |
| - strokeLinecap="round" |
46 |
| - /> |
47 |
| - <path |
48 |
| - d="M5.60388 6.77344L5.60388 7.77344" |
| 86 | + d="M10.8051 3.71161L12.2401 5.27411L14.823 2.14911" |
49 | 87 | stroke="currentColor"
|
50 | 88 | strokeWidth="1.2"
|
51 | 89 | strokeLinecap="round"
|
| 90 | + strokeLinejoin="round" |
| 91 | + className={tcls( |
| 92 | + state === 'done' |
| 93 | + ? 'animate-[fadeIn_.5s_.3s_both]' |
| 94 | + : 'animate-[fadeOut_.5s_both]' |
| 95 | + )} |
52 | 96 | />
|
| 97 | + |
| 98 | + {/* Background */} |
53 | 99 | <path
|
54 |
| - d="M13.2813 8.875L13.2813 10.125C13.2813 12.3341 11.4904 14.125 9.28125 14.125L1.80165 14.125L1.80165 6.78125C1.80165 4.57211 3.59251 2.78125 5.80165 2.78125L7.67889 2.78125" |
| 100 | + d="M3.5625 8.78512L7.26347 10.9219C7.88227 11.2791 8.64467 11.2791 9.26347 10.9219L14.25 8.0429C14.5833 7.85045 15 8.09101 15 8.47591V10.2777C15 10.4563 14.9047 10.6214 14.75 10.7107L9.26347 13.8784C8.64467 14.2356 7.88228 14.2356 7.26347 13.8784L3.5625 11.7416C2.70833 11.2978 1 9.93199 1 8.01949M1 8.01949C1 6.6448 1.84765 5.98698 2.62903 5.71701C3.15426 5.53555 3.71577 5.70568 4.19701 5.98353L7.26347 7.75395C7.88228 8.11122 8.64467 8.11122 9.26347 7.75395L10.9095 6.80362M1 8.01949C1 6.4945 2.03973 5.30731 2.5596 4.90434L7.37937 2.12165C7.79013 1.88449 8.26417 1.80476 8.71747 1.88245" |
55 | 101 | stroke="currentColor"
|
| 102 | + strokeOpacity="0.25" |
56 | 103 | strokeWidth="1.2"
|
57 | 104 | strokeLinecap="round"
|
58 | 105 | strokeLinejoin="round"
|
| 106 | + className={tcls(state === 'intro' && 'animate-[fadeIn_2s_forwards]')} |
59 | 107 | />
|
| 108 | + |
| 109 | + {/* Logo */} |
| 110 | + <mask |
| 111 | + id="mask0_220_25" |
| 112 | + style={{ maskType: 'alpha' }} |
| 113 | + maskUnits="userSpaceOnUse" |
| 114 | + x="0" |
| 115 | + y="1" |
| 116 | + width="16" |
| 117 | + height="14" |
| 118 | + > |
| 119 | + <path |
| 120 | + d="M3.5625 8.78512L7.26347 10.9219C7.88227 11.2791 8.64467 11.2791 9.26347 10.9219L14.25 8.0429C14.5833 7.85045 15 8.09101 15 8.47591V10.2777C15 10.4563 14.9047 10.6214 14.75 10.7107L9.26347 13.8784C8.64467 14.2356 7.88228 14.2356 7.26347 13.8784L3.5625 11.7416C2.70833 11.2978 1 9.93199 1 8.01949M1 8.01949C1 6.6448 1.84765 5.98698 2.62903 5.71701C3.15426 5.53555 3.71577 5.70568 4.19701 5.98353L7.26347 7.75395C7.88228 8.11122 8.64467 8.11122 9.26347 7.75395L10.9095 6.80362M1 8.01949C1 6.4945 2.03973 5.30731 2.5596 4.90434L7.37937 2.12165C7.79013 1.88449 8.26417 1.80476 8.71747 1.88245" |
| 121 | + stroke="currentColor" |
| 122 | + pathLength="100" |
| 123 | + strokeWidth="1.2" |
| 124 | + strokeLinecap="round" |
| 125 | + strokeLinejoin="round" |
| 126 | + /> |
| 127 | + </mask> |
| 128 | + <g mask="url(#mask0_220_25)"> |
| 129 | + <path |
| 130 | + d="M3.5625 8.78512L7.26347 10.9219C7.88227 11.2791 8.64467 11.2791 9.26347 10.9219L14.25 8.0429C14.5833 7.85045 15 8.09101 15 8.47591V10.2777C15 10.4563 14.9047 10.6214 14.75 10.7107L9.26347 13.8784C8.64467 14.2356 7.88228 14.2356 7.26347 13.8784L3.5625 11.7416C2.70833 11.2978 1 9.93199 1 8.01949C1 6.6448 1.84765 5.98698 2.62903 5.71701C3.15426 5.53555 3.71577 5.70568 4.19701 5.98353L7.26347 7.75395C7.88228 8.11122 8.64467 8.11122 9.26347 7.75395L14.1991 4.90434L9.37937 2.12165C8.76057 1.76438 7.99907 1.76386 7.38027 2.12113C5.89314 2.97972 3.20298 4.53289 2.5596 4.90434C1.77376 5.35804 1 6.11597 1.00148 7.9207" |
| 131 | + stroke="currentColor" |
| 132 | + pathLength="100" |
| 133 | + strokeWidth="1.2" |
| 134 | + strokeLinecap="round" |
| 135 | + strokeLinejoin="round" |
| 136 | + className={tcls( |
| 137 | + (state === 'thinking' || state === 'working') && |
| 138 | + 'animate-[pathLoading_2s_infinite_forwards]', |
| 139 | + state === 'intro' && 'animate-[pathEnter_2s_forwards]', |
| 140 | + state === 'done' && 'animate-[pathEnter_1s_forwards_ease]' |
| 141 | + )} |
| 142 | + /> |
| 143 | + </g> |
60 | 144 | </svg>
|
61 | 145 | );
|
62 | 146 | };
|
|
0 commit comments