@@ -14,6 +14,10 @@ export default class Header extends Component {
1414 this . onChangeIntent = this . onChangeIntent . bind ( this ) ;
1515 this . handleHeaderClick = this . handleHeaderClick . bind ( this ) ;
1616 this . handleHeaderMouseDown = this . handleHeaderMouseDown . bind ( this ) ;
17+ this . handleHamburgerMenuClick = this . handleHamburgerMenuClick . bind ( this ) ;
18+ this . handleMaximizeClick = this . handleMaximizeClick . bind ( this ) ;
19+ this . handleMinimizeClick = this . handleMinimizeClick . bind ( this ) ;
20+ this . handleCloseClick = this . handleCloseClick . bind ( this ) ;
1721 }
1822
1923 onChangeIntent ( active ) {
@@ -68,6 +72,27 @@ export default class Header extends Component {
6872 }
6973 }
7074
75+ handleHamburgerMenuClick ( event ) {
76+ const { right : x , bottom : y } = event . currentTarget . getBoundingClientRect ( ) ;
77+ this . props . openHamburgerMenu ( { x, y} ) ;
78+ }
79+
80+ handleMaximizeClick ( ) {
81+ if ( this . props . maximized ) {
82+ this . props . unmaximize ( ) ;
83+ } else {
84+ this . props . maximize ( ) ;
85+ }
86+ }
87+
88+ handleMinimizeClick ( ) {
89+ this . props . minimize ( ) ;
90+ }
91+
92+ handleCloseClick ( ) {
93+ this . props . close ( ) ;
94+ }
95+
7196 componentWillUnmount ( ) {
7297 delete this . clicks ;
7398 clearTimeout ( this . clickTimer ) ;
@@ -81,11 +106,49 @@ export default class Header extends Component {
81106 onClose : this . props . onCloseTab ,
82107 onChange : this . onChangeIntent
83108 } ) ;
109+ const { borderColor} = props ;
110+ let title = 'Hyper' ;
111+ if ( props . tabs . length === 1 && props . tabs [ 0 ] . title ) {
112+ // if there's only one tab we use its title as the window title
113+ title = props . tabs [ 0 ] . title ;
114+ }
84115 return ( < header
85116 className = { css ( 'header' , isMac && 'headerRounded' ) }
86117 onClick = { this . handleHeaderClick }
87118 onMouseDown = { this . handleHeaderMouseDown }
88119 >
120+ {
121+ ! isMac && < div
122+ className = { css ( 'windowHeader' , props . tabs . length > 1 && 'windowHeaderWithBorder' ) }
123+ style = { { borderColor} }
124+ >
125+ < svg
126+ className = { css ( 'shape' , 'hamburgerMenu' ) }
127+ onClick = { this . handleHamburgerMenuClick }
128+ >
129+ < use xlinkHref = "./dist/assets/icons.svg#hamburger-menu" />
130+ </ svg >
131+ < span className = { css ( 'appTitle' ) } > { title } </ span >
132+ < svg
133+ className = { css ( 'shape' , 'minimizeWindow' ) }
134+ onClick = { this . handleMinimizeClick }
135+ >
136+ < use xlinkHref = "./dist/assets/icons.svg#minimize-window" />
137+ </ svg >
138+ < svg
139+ className = { css ( 'shape' , 'maximizeWindow' ) }
140+ onClick = { this . handleMaximizeClick }
141+ >
142+ < use xlinkHref = "./dist/assets/icons.svg#maximize-window" />
143+ </ svg >
144+ < svg
145+ className = { css ( 'shape' , 'closeWindow' ) }
146+ onClick = { this . handleCloseClick }
147+ >
148+ < use xlinkHref = "./dist/assets/icons.svg#close-window" />
149+ </ svg >
150+ </ div >
151+ }
89152 { this . props . customChildrenBefore }
90153 < Tabs { ...props } />
91154 { this . props . customChildren }
@@ -105,6 +168,61 @@ export default class Header extends Component {
105168 headerRounded : {
106169 borderTopLeftRadius : '4px' ,
107170 borderTopRightRadius : '4px'
171+ } ,
172+
173+ windowHeader : {
174+ height : '34px' ,
175+ width : '100%' ,
176+ position : 'fixed' ,
177+ top : '1px' ,
178+ left : '1px' ,
179+ right : '1px' ,
180+ WebkitAppRegion : 'drag' ,
181+ display : 'flex' ,
182+ justifyContent : 'center' ,
183+ alignItems : 'center'
184+ } ,
185+
186+ windowHeaderWithBorder : {
187+ borderColor : '#ccc' ,
188+ borderBottomStyle : 'solid' ,
189+ borderBottomWidth : '1px'
190+ } ,
191+
192+ appTitle : {
193+ fontSize : '12px' ,
194+ fontFamily : `-apple-system, BlinkMacSystemFont,
195+ "Segoe UI", "Roboto", "Oxygen",
196+ "Ubuntu", "Cantarell", "Fira Sans",
197+ "Droid Sans", "Helvetica Neue", sans-serif`
198+ } ,
199+
200+ shape : {
201+ width : '10px' ,
202+ height : '10px' ,
203+ position : 'fixed' ,
204+ WebkitAppRegion : 'no-drag' ,
205+ fill : 'currentColor'
206+ } ,
207+
208+ hamburgerMenu : {
209+ height : '9px' , // TODO fix the SVG
210+ top : '10px' ,
211+ left : '10px'
212+ } ,
213+
214+ closeWindow : {
215+ right : '10px' ,
216+ stroke : 'currentColor'
217+ } ,
218+
219+ maximizeWindow : {
220+ right : '35px' ,
221+ stroke : 'currentColor'
222+ } ,
223+
224+ minimizeWindow : {
225+ right : '60px'
108226 }
109227 } ;
110228 }
0 commit comments