@@ -4,7 +4,7 @@ import Button, { ButtonProps } from '@mui/material/Button';
4
4
import CircularProgress from '@mui/material/CircularProgress' ;
5
5
import Snackbar from '@mui/material/Snackbar' ;
6
6
import Alert from '@mui/material/Alert' ;
7
- import SvgMuiLogomark from 'docs/src/icons/SvgMuiLogomark ' ;
7
+ import PageContext from 'docs/src/modules/components/PageContext ' ;
8
8
import { createMuiChat } from '../sandbox/MuiChat' ;
9
9
import { DemoData } from '../sandbox/types' ;
10
10
@@ -22,45 +22,48 @@ const rainbow = keyframes`
22
22
` ;
23
23
24
24
const RainbowButton = styled ( Button ) ( ( { theme } ) => ( {
25
- '--color-1' : '0 100% 63 %' ,
26
- '--color-2' : '270 100% 63 %' ,
27
- '--color-3' : '210 100% 63 %' ,
28
- '--color-4' : '195 100% 63 %' ,
29
- '--color-5' : '90 100% 63 %' ,
25
+ '--color-1' : '0 100% 50 %' ,
26
+ '--color-2' : '270 100% 50 %' ,
27
+ '--color-3' : '210 100% 50 %' ,
28
+ '--color-4' : '195 100% 50 %' ,
29
+ '--color-5' : '90 100% 50 %' ,
30
30
position : 'relative' ,
31
31
display : 'inline-flex' ,
32
32
height : 26 ,
33
33
padding : '7px 8px 8px 8px' , // 7px for optical alignment
34
34
flexShrink : 0 ,
35
- borderRadius : '6px' ,
35
+ borderRadius : 999 ,
36
36
border : '1px solid transparent' ,
37
- borderBottomWidth : '3px' ,
38
- borderBottomColor : 'transparent' ,
39
- boxShadow : '0 -1px 4px 0px rgba(255, 255, 255, 0.32)' ,
37
+ borderBottomWidth : '2.5px' ,
38
+ borderColor : alpha ( theme . palette . grey [ 200 ] , 0.8 ) ,
40
39
'&.MuiButton-loading' : {
41
- boxShadow : '0 -1px 4px 0px rgba(255, 255, 255, 0.32)' ,
40
+ '& > svg' : {
41
+ transform : 'translateX(36px)' ,
42
+ } ,
42
43
} ,
43
- color : '#fff' ,
44
44
fontSize : theme . typography . pxToRem ( 13 ) ,
45
45
fontWeight : theme . typography . fontWeightMedium ,
46
46
backgroundSize : '200%' ,
47
47
backgroundClip : 'padding-box, border-box, border-box' ,
48
48
backgroundOrigin : 'border-box' ,
49
49
animation : `${ rainbow } 2s linear infinite` ,
50
- '--bg-color-raw' : '16, 18, 20 ' ,
50
+ '--bg-color-raw' : '255,255,255 ' ,
51
51
'--bg-color' : 'rgb(var(--bg-color-raw))' ,
52
- backgroundImage : `linear-gradient(var(--bg-color), var(--bg-color)), linear-gradient(var(--bg-color) 50%, rgba(var(--bg-color-raw), 0.6) 80%, rgba(var(--bg-color-raw), 0)), linear-gradient(90deg, hsl(var(--color-1)), hsl(var(--color-5)), hsl(var(--color-3)), hsl(var(--color-4)), hsl(var(--color-2)))` ,
52
+ backgroundImage : `linear-gradient(var(--bg-color), var(--bg-color)), linear-gradient(var(--bg-color) 50%, rgba(var(--bg-color-raw)) 80%, rgba(var(--bg-color-raw), 0)), linear-gradient(90deg, hsl(var(--color-1)), hsl(var(--color-5)), hsl(var(--color-3)), hsl(var(--color-4)), hsl(var(--color-2)))` ,
53
+ '&:hover' : {
54
+ '--bg-color-raw' : '235,245,255' ,
55
+ } ,
53
56
...theme . applyDarkStyles ( {
57
+ '--bg-color-raw' : '16, 18, 20' ,
54
58
borderColor : alpha ( theme . palette . primary [ 300 ] , 0.2 ) ,
59
+ '&:hover' : {
60
+ '--bg-color-raw' : '13, 38, 63' ,
61
+ } ,
55
62
} ) ,
56
- '&:hover' : {
57
- boxShadow : '0 -1px 4px 0px rgba(255, 255, 255, 0.56)' ,
58
- animationPlayState : 'paused' ,
59
- } ,
60
63
'&::before' : {
61
64
content : '""' ,
62
65
position : 'absolute' ,
63
- bottom : '-20 %' ,
66
+ bottom : '-25 %' ,
64
67
left : '50%' ,
65
68
zIndex : 0 ,
66
69
height : '20%' ,
@@ -69,23 +72,29 @@ const RainbowButton = styled(Button)(({ theme }) => ({
69
72
animation : `${ rainbow } 3s linear infinite` ,
70
73
background :
71
74
'linear-gradient(90deg, hsl(var(--color-1)), hsl(var(--color-5)), hsl(var(--color-3)), hsl(var(--color-4)), hsl(var(--color-2)))' ,
72
- filter : 'blur(0.8rem)' ,
75
+ filter : 'blur(1.2rem)' ,
76
+ ...theme . applyDarkStyles ( {
77
+ width : '90%' ,
78
+ filter : 'blur(0.5rem)' ,
79
+ } ) ,
73
80
} ,
74
81
'& > svg' : {
75
- height : 12 ,
76
- width : 12 ,
77
- margin : '1px 4px 0 4px' ,
78
- } ,
79
- '& > svg > path' : {
82
+ height : 18 ,
83
+ width : 18 ,
84
+ margin : '0 4px 0 0' ,
85
+ stroke : ( theme . vars || theme ) . palette . primary . main ,
80
86
fill : ( theme . vars || theme ) . palette . primary . main ,
87
+ transition : 'transform 0.4s' ,
81
88
} ,
82
89
} ) ) ;
83
90
84
91
const OpenInMUIChatButton = React . forwardRef < HTMLButtonElement , OpenInMUIChatButtonProps > (
85
92
function OpenInMUIChatButton ( { demoData, ...props } , ref ) {
93
+ const { productId } = React . useContext ( PageContext ) ;
86
94
const [ loading , setLoading ] = React . useState ( false ) ;
87
95
const [ error , setError ] = React . useState < Error | null > ( null ) ;
88
- const baseUrl = process . env . NEXT_PUBLIC_MUI_CHAT_API_BASE_URL ;
96
+ const baseUrl = process . env . MUI_CHAT_API_BASE_URL ;
97
+ const scopes = process . env . MUI_CHAT_SCOPES ;
89
98
90
99
const handleClick = async ( ) => {
91
100
setLoading ( true ) ;
@@ -101,7 +110,7 @@ const OpenInMUIChatButton = React.forwardRef<HTMLButtonElement, OpenInMUIChatBut
101
110
} ;
102
111
103
112
// If the base URL is not set, we can't render the button
104
- if ( ! baseUrl ) {
113
+ if ( ! baseUrl || ! scopes || ! scopes . split ( ',' ) . includes ( productId ) ) {
105
114
return null ;
106
115
}
107
116
@@ -116,7 +125,20 @@ const OpenInMUIChatButton = React.forwardRef<HTMLButtonElement, OpenInMUIChatBut
116
125
onClick = { handleClick }
117
126
{ ...props }
118
127
>
119
- Edit in < SvgMuiLogomark /> Chat
128
+ < svg
129
+ xmlns = "http://www.w3.org/2000/svg"
130
+ fill = "none"
131
+ viewBox = "0 0 24 24"
132
+ strokeWidth = "1.5"
133
+ stroke = "currentColor"
134
+ >
135
+ < path
136
+ strokeLinecap = "round"
137
+ strokeLinejoin = "round"
138
+ d = "M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09ZM18.259 8.715 18 9.75l-.259-1.035a3.375 3.375 0 0 0-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 0 0 2.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 0 0 2.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 0 0-2.456 2.456ZM16.894 20.567 16.5 21.75l-.394-1.183a2.25 2.25 0 0 0-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 0 0 1.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 0 0 1.423 1.423l1.183.394-1.183.394a2.25 2.25 0 0 0-1.423 1.423Z"
139
+ />
140
+ </ svg > { ' ' }
141
+ Edit in Chat
120
142
</ RainbowButton >
121
143
< Snackbar
122
144
open = { ! ! error }
0 commit comments