@@ -5,92 +5,92 @@ import Menu from "../components/Menu";
55import { sheet , classes } from "../css/styles" ;
66
77export default class Header extends BaseElement {
8- constructor ( { id, className, parent, element, args } = { } ) {
9- super ( { id, className, parent, element, args } ) ;
10- this . element = element ;
11- this . parent = parent ;
8+ constructor ( { id, className, parent, element, args } = { } ) {
9+ super ( { id, className, parent, element, args } ) ;
10+ this . element = element ;
11+ this . parent = parent ;
1212
13- this . settingItems = [
14- {
15- 'label' : 'Device settings' ,
16- 'callback' : ( ) => { this . sendToParent ( 'show_settings' ) }
17- } ,
18- {
19- 'label' : 'Sign out' ,
20- 'callback' : ( ) => {
21- SendBirdCall . deauthenticate ( ) ;
22- this . sendToParent ( 'deauthenticate' ) ;
23- }
24- }
25- ] ;
13+ this . settingItems = [
14+ {
15+ 'label' : 'Device settings' ,
16+ 'callback' : ( ) => { this . sendToParent ( 'show_settings' ) }
17+ } ,
18+ {
19+ 'label' : 'Sign out' ,
20+ 'callback' : ( ) => {
21+ SendBirdCall . deauthenticate ( ) ;
22+ this . sendToParent ( 'deauthenticate' ) ;
23+ }
24+ }
25+ ] ;
2626
27- this . args = args ;
28- this . parent = parent ;
29- }
27+ this . args = args ;
28+ this . parent = parent ;
29+ }
3030
31- build ( ) {
32- const userDiv = createDiv ( {
33- id : 'header_user_div' ,
34- className : `${ classes [ 'userDiv' ] } ${ classes [ 'center' ] } `
35- } ) ;
31+ build ( ) {
32+ const userDiv = createDiv ( {
33+ id : 'header_user_div' ,
34+ className : `${ classes [ 'userDiv' ] } ${ classes [ 'center' ] } `
35+ } ) ;
3636
37- let profileImg ;
38- if ( this . args . user && this . args . user . profileUrl ) {
39- sheet . update ( { profileUrl : this . args . user . profileUrl } ) ;
40- profileImg = createDiv ( { id : 'header_profile_img' , className : classes [ 'profileSmall' ] } ) ;
41- } else {
42- profileImg = createDiv ( { id : 'header_avatar' , className : `${ classes [ 'avatar' ] } ` } ) ;
43- }
37+ let profileImg ;
38+ if ( this . args . user && this . args . user . profileUrl ) {
39+ sheet . update ( { profileUrl : this . args . user . profileUrl } ) ;
40+ profileImg = createDiv ( { id : 'header_profile_img' , className : classes [ 'profileSmall' ] } ) ;
41+ } else {
42+ profileImg = createDiv ( { id : 'header_avatar' , className : `${ classes [ 'avatar' ] } ` } ) ;
43+ }
4444
45- const headerInfo = createDiv ( { id : 'header_info' , className : `${ classes [ 'headerInfo' ] } ` } ) ;
46- const userId = createDiv ( {
47- id : 'header_user_id' ,
48- className : `${ classes [ 'headerUserId' ] } ${ classes [ 'fontNormal' ] } ${ classes [ 'fontHeavy' ] } ` ,
49- innerText : this . args . user . userId || ''
50- } ) ;
51- const nickname = createDiv ( {
52- id : 'header_nickname' ,
53- className : `${ classes [ 'headerNickname' ] } ${ classes [ 'fontSmall' ] } ` ,
54- innerText : this . args . user . nickname || 'no nickname'
55- } ) ;
56- headerInfo . appendChild ( userId ) ;
57- headerInfo . appendChild ( nickname ) ;
45+ const headerInfo = createDiv ( { id : 'header_info' , className : `${ classes [ 'headerInfo' ] } ` } ) ;
46+ const userId = createDiv ( {
47+ id : 'header_user_id' ,
48+ className : `${ classes [ 'headerUserId' ] } ${ classes [ 'fontNormal' ] } ${ classes [ 'fontHeavy' ] } ` ,
49+ innerText : this . args . user . userId || ''
50+ } ) ;
51+ const nickname = createDiv ( {
52+ id : 'header_nickname' ,
53+ className : `${ classes [ 'headerNickname' ] } ${ classes [ 'fontSmall' ] } ` ,
54+ innerText : this . args . user . nickname || 'no nickname'
55+ } ) ;
56+ headerInfo . appendChild ( userId ) ;
57+ headerInfo . appendChild ( nickname ) ;
5858
59- userDiv . appendChild ( profileImg ) ;
60- userDiv . appendChild ( headerInfo ) ;
59+ userDiv . appendChild ( profileImg ) ;
60+ userDiv . appendChild ( headerInfo ) ;
6161
62- const headerButtons = createDiv ( {
63- id : 'header_buttons' ,
64- className : `${ classes [ 'headerButtons' ] } ${ classes [ 'row' ] } ${ classes [ 'center' ] } `
65- } ) ;
66- const settingsButton = new Menu ( {
67- id : 'settings_button' ,
68- element : createDiv ( { className : `${ classes [ 'settingsButton' ] } ` } ) ,
69- items : this . settingItems
70- } ) ;
62+ const headerButtons = createDiv ( {
63+ id : 'header_buttons' ,
64+ className : `${ classes [ 'headerButtons' ] } ${ classes [ 'row' ] } ${ classes [ 'center' ] } `
65+ } ) ;
66+ const settingsButton = new Menu ( {
67+ id : 'settings_button' ,
68+ element : createDiv ( { className : `${ classes [ 'settingsButton' ] } ` } ) ,
69+ items : this . settingItems
70+ } ) ;
7171
72- const closeButton = createDiv ( {
73- id : 'close_button' ,
74- className : `${ classes [ 'closeButton' ] } `
75- } ) ;
76- closeButton . onclick = ( ) => {
77- this . parent . sendToParent ( 'widgetclose' ) ;
78- } ;
79- settingsButton . appendToHTML ( headerButtons ) ;
80- headerButtons . appendChild ( closeButton ) ;
72+ const closeButton = createDiv ( {
73+ id : 'close_button' ,
74+ className : `${ classes [ 'closeButton' ] } `
75+ } ) ;
76+ closeButton . onclick = ( ) => {
77+ this . parent . sendToParent ( 'widgetclose' ) ;
78+ } ;
79+ settingsButton . appendToHTML ( headerButtons ) ;
80+ headerButtons . appendChild ( closeButton ) ;
8181
82- const divider = createDiv ( {
83- id : 'header_divider' ,
84- className : classes [ 'headerDivider' ]
85- } ) ;
82+ const divider = createDiv ( {
83+ id : 'header_divider' ,
84+ className : classes [ 'headerDivider' ]
85+ } ) ;
8686
87- this . element . appendChild ( userDiv ) ;
88- this . element . appendChild ( divider ) ;
89- this . element . appendChild ( headerButtons ) ;
87+ this . element . appendChild ( userDiv ) ;
88+ this . element . appendChild ( divider ) ;
89+ this . element . appendChild ( headerButtons ) ;
9090
91- if ( ! this . args . isWidget ) {
92- const headerLogo = createDiv ( { id : 'header_logo' , className : `${ classes [ 'headerLogo' ] } ` } ) ;
93- this . element . appendChild ( headerLogo ) ;
94- }
91+ if ( ! this . args . isWidget ) {
92+ const headerLogo = createDiv ( { id : 'header_logo' , className : `${ classes [ 'headerLogo' ] } ` } ) ;
93+ this . element . appendChild ( headerLogo ) ;
9594 }
95+ }
9696}
0 commit comments