1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6+ < title > Test Shell custom element</ title >
7+ < style >
8+ * {
9+ box-sizing : border-box;
10+ }
11+ body {
12+ margin : 0 ;
13+ }
14+ test-shell {
15+ display : grid;
16+ grid-template-rows : min-content auto;
17+
18+ # webchat {
19+ height : 640px ;
20+ width : 380px ;
21+ transition : width 0.2s 0.2s ease-out;
22+ }
23+
24+ .fui-FluentProvider {
25+ display : contents;
26+ }
27+
28+ .webchat__surface {
29+ overflow : hidden;
30+ }
31+ }
32+
33+ test-shell : has (.theme .variant-copilot ) > # webchat {
34+ width : 680px ;
35+ }
36+ </ style >
37+ </ head >
38+ < body >
39+ < template >
40+ < style type ="text/css ">
41+ * {
42+ box-sizing : border-box;
43+ }
44+
45+ : host ([data-theme = "light" ]) {
46+ --body-background : linear-gradient (135deg , # e0f7ff 0% , # ffe5f0 100% );
47+ --webchat-container-background : linear-gradient (160deg , # ffffff22 0% , # f8f9facc 100% );
48+ --notice-color : # 495057 ;
49+ --notice-background : # f8f9fa77 ;
50+ --notice-border : 1px solid # dee2e6 ;
51+ }
52+
53+ : host ([data-theme = "dark" ]) {
54+ --body-background : linear-gradient (135deg , # 0b1a2b 0% , # 2c001e 100% );
55+ --webchat-container-background : linear-gradient (160deg , # 1a1a1acc 0% , # 222222cc 100% );
56+ --notice-color : # f8f9fa ;
57+ --notice-background : # 49505777 ;
58+ --notice-border : 1px solid # 666666 ;
59+ }
60+
61+ : host {
62+ margin: 0;
63+ min- height: 100vh;
64+ padding: 30px;
65+ font- family: - apple-system, BlinkMacSystemFont, 'Segoe UI' , Roboto ,
66+ Oxygen , Ubuntu , Cantarell , sans-serif ;
67+ background: var(- - body- background);
68+ dis play: grid;
69+ gap: 20px;
70+
71+ opacity: 0;
72+ transition: opacity 0.3s 0.7s ease- in- out;
73+ }
74+
75+ : host ([data-theme = "dark" ]), : host ([data-theme = "light" ]) {
76+ opacity : 1 ;
77+ }
78+
79+ .webchat-container {
80+ border-radius : 16px ;
81+ box-shadow : 0 8px 24px rgba (0 , 0 , 0 , 0.08 );
82+ background : var (--webchat-container-background );
83+ position : relative;
84+ display : grid;
85+ place-self : center;
86+
87+ .loader-notice {
88+ opacity : 0.33 ;
89+ place-self : center;
90+ }
91+ }
92+
93+ .notice {
94+ background : var (--notice-background );
95+ border : var (--notice-border );
96+ color : var (--notice-color );
97+ padding : 15px ;
98+ border-radius : 8px ;
99+ max-width : 440px ;
100+ font-size : 14px ;
101+ place-self : start center;
102+
103+ & ::after {
104+ content : ' (theme=' attr (data-theme)')' ' (variant=' attr (data-variant)')' ;
105+ opacity : 0.75 ;
106+ }
107+ }
108+ </ style >
109+ < div class ="notice ">
110+ </ div >
111+ < div class ="webchat-container ">
112+ < slot >
113+ < div class ="loader-notice ">
114+ Web Chat root element is not provided.
115+ </ div >
116+ </ slot >
117+ </ div >
118+ </ template >
119+ < script type ="module ">
120+ import { customElement } from '/assets/custom-element/custom-element.js' ;
121+
122+ customElement ( 'test-shell' , currentDocument =>
123+ class TestShellElement extends HTMLElement {
124+ constructor ( ) {
125+ super ( ) ;
126+ const template = currentDocument . querySelector ( 'template' ) ;
127+ const fragment = template . content . cloneNode ( true ) ;
128+
129+ this . notice = fragment . querySelector ( '.notice' ) ;
130+
131+ this . initDataset ( ) ;
132+ this . initNotice ( ) ;
133+
134+ const shadowRoot = this . attachShadow ( { mode : 'open' } ) ;
135+ shadowRoot . appendChild ( fragment ) ;
136+ }
137+
138+ initNotice ( ) {
139+ this . notice . textContent = document . title ;
140+
141+ Object . assign ( this . notice . dataset , this . dataset ) ;
142+ }
143+
144+ initDataset ( ) {
145+ const params = new URLSearchParams ( location . search )
146+ this . dataset . theme = params . get ( 'fluent-theme' ) || 'light' ;
147+ this . dataset . fluentTheme = this . dataset . theme ;
148+ this . dataset . variant = params . get ( 'variant' ) ;
149+ }
150+ }
151+ ) ;
152+ </ script >
153+ </ body >
154+ </ html >
0 commit comments