11import { h } from 'preact' ;
2+ import { useState } from 'preact/hooks'
23import { Button } from './common' ;
34import { ProductVersionLabel } from '../zenuml/components/MainHeader/ProductVersionLabel/ProductVersionLabel' ;
45import featureToggle from '../services/feature_toggle' ;
@@ -7,16 +8,40 @@ const DEFAULT_PROFILE_IMG =
78 "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='#ccc' d='M12,19.2C9.5,19.2 7.29,17.92 6,16C6.03,14 10,12.9 12,12.9C14,12.9 17.97,14 18,16C16.71,17.92 14.5,19.2 12,19.2M12,5A3,3 0 0,1 15,8A3,3 0 0,1 12,11A3,3 0 0,1 9,8A3,3 0 0,1 12,5M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12C22,6.47 17.5,2 12,2Z' /%3E%3C/svg%3E" ;
89
910export function MainHeader ( props ) {
11+ const [ isEditing , setEditing ] = useState ( false ) ;
12+
13+ const entryEditing = ( ) => {
14+ setEditing ( true ) ;
15+ }
16+
17+ const exitEditing = ( ) => {
18+ setEditing ( false ) ;
19+ }
20+
21+ const onBlur = ( e ) => {
22+ exitEditing ( ) ;
23+ props . titleInputBlurHandler ( e ) ;
24+ }
25+
1026 return (
1127 < div className = "main-header" >
12- < input
28+ < div className = "header-logo" >
29+ < img src = "assets/zenuml-icon.png" alt = "zenuml logo" />
30+ </ div >
31+ {
32+ isEditing ? ( < input
33+ autoFocus
1334 type = "text"
1435 id = "titleInput"
1536 title = "Click to edit"
1637 className = "item-title-input"
1738 value = { props . title }
18- onBlur = { props . titleInputBlurHandler }
19- />
39+ onBlur = { onBlur }
40+ /> ) : ( < div className = "title" onClick = { ( ) => entryEditing ( ) } >
41+ < span > { props . title || 'Untitled' } </ span >
42+ < span class = "material-symbols-outlined" > border_color</ span >
43+ </ div > )
44+ }
2045 < div className = "main-header__btn-wrap flex flex-v-center" >
2146 < button
2247 id = "runBtn"
@@ -45,70 +70,50 @@ export function MainHeader(props) {
4570 </ span >
4671 </ Button >
4772 < button
48- className = "btn--dark flex flex-v-center hint--rounded hint--bottom-left button button-editor-solid"
73+ className = "btn--dark flex flex-v-center hint--rounded hint--bottom-left button icon-button button-editor-solid"
4974 aria-label = "Start a new creation"
5075 onClick = { props . newBtnHandler }
5176 >
52- < svg
53- style = "vertical-align:middle;width:14px;height:14px"
54- viewBox = "0 0 24 24"
55- >
56- < path d = "M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z" />
57- </ svg > New
77+ < span class = "material-symbols-outlined" > add</ span >
78+ < span > New</ span >
5879 </ button >
5980 < button
6081 id = "saveBtn"
61- className = { `btn--dark flex flex-v-center hint--rounded hint--bottom-left button button-editor-solid ${
82+ className = { `btn--dark flex flex-v-center hint--rounded hint--bottom-left button icon- button button-editor-solid ${
6283 props . isSaving ? 'is-loading' : ''
6384 } ${ props . unsavedEditCount ? 'is-marked' : 0 } `}
6485 aria-label = "Save current creation (Ctrl/⌘ + S)"
6586 onClick = { props . saveBtnHandler }
6687 >
67- < svg
68- style = "vertical-align:middle;width:14px;height:14px"
69- viewBox = "0 0 24 24"
70- >
71- < path d = "M15,9H5V5H15M12,19A3,3 0 0,1 9,16A3,3 0 0,1 12,13A3,3 0 0,1 15,16A3,3 0 0,1 12,19M17,3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V7L17,3Z" />
72- </ svg >
73- < svg className = "btn-loader" width = "14" height = "14" stroke = "#fff" >
74- < use xlinkHref = "#loader-icon" />
75- </ svg >
76- Save
88+ < span class = "material-symbols-outlined" > save</ span >
89+ < span > Save</ span >
7790 </ button >
7891 < button
7992 id = "openItemsBtn"
80- className = { `btn--dark flex flex-v-center hint--rounded hint--bottom-left button button-editor-solid ${
93+ className = { `btn--dark flex flex-v-center hint--rounded hint--bottom-left button icon-button button-editor-solid ${
8194 props . isFetchingItems ? 'is-loading' : ''
8295 } `}
8396 aria-label = "Open a saved creation (Ctrl/⌘ + O)"
8497 onClick = { props . openBtnHandler }
8598 >
86- < svg
87- style = "width:14px;height:14px;vertical-align:middle;"
88- viewBox = "0 0 24 24"
89- >
90- < path d = "M13,9V3.5L18.5,9M6,2C4.89,2 4,2.89 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2H6Z" />
91- </ svg >
92- < svg className = "btn-loader" width = "14" height = "14" stroke = "#fff" >
93- < use xlinkHref = "#loader-icon" />
94- </ svg >
95- Open
99+ < span class = "material-symbols-outlined" > open_in_new</ span >
100+ < span > Open</ span >
96101 </ button >
97102 < Button
98103 onClick = { props . loginBtnHandler }
99104 data-event-category = "ui"
100105 data-event-action = "loginButtonClick"
101- className = "hide-on-login btn--dark flex flex-v-center hint--rounded hint--bottom-left button button-editor-solid"
102- aria-label = "Login/Signup "
106+ className = "hide-on-login btn--dark flex flex-v-center hint--rounded hint--bottom-left button icon-button button-editor-solid"
107+ aria-label = "Signin "
103108 >
104- Login/Signup
109+ < span class = "material-symbols-outlined" > login </ span > Sign in
105110 </ Button >
106111 < Button
107112 onClick = { props . profileBtnHandler }
108113 data-event-category = "ui"
109114 data-event-action = "headerAvatarClick"
110115 aria-label = "See profile or Logout"
111- className = "hide-on-logout btn--dark hint--rounded hint--bottom-left button button-editor-solid"
116+ className = "hide-on-logout btn--dark hint--rounded hint--bottom-left button button-editor-solid"
112117 >
113118 < img
114119 id = "headerAvatarImg"
0 commit comments