File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed
Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -108,3 +108,7 @@ limitations under the License.
108108 font-size : 1.78em ;
109109 margin-right : 0.15em ;
110110}
111+
112+ .TracePageHeader--zoomControls {
113+ margin-right : 0.5em ;
114+ }
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ import { getTraceLinks } from '../../../model/link-patterns';
3838
3939import './TracePageHeader.css' ;
4040import ExternalLinks from '../../common/ExternalLinks' ;
41+ import ZoomControls from './ZoomControls' ;
4142
4243type TracePageHeaderEmbedProps = {
4344 canCollapse : boolean ;
@@ -209,6 +210,7 @@ export function TracePageHeaderFn(props: TracePageHeaderEmbedProps & { forwarded
209210 < NewWindowIcon isLarge />
210211 </ Link >
211212 ) }
213+ < ZoomControls className = "TracePageHeader--zoomControls" />
212214 </ div >
213215 { summaryItems && < LabeledList className = "TracePageHeader--overviewItems" items = { summaryItems } /> }
214216 { ! hideMap && ! slimView && (
Original file line number Diff line number Diff line change 1+ import { Button } from 'antd' ;
2+ import React , { useEffect , useState } from 'react' ;
3+ import ButtonGroup from 'antd/lib/button/button-group' ;
4+
5+ const MIN_ZOOM_LEVEL = 0.7 ;
6+ const MAX_ZOOM_LEVEL = 1.5 ;
7+ const ZOOM_FACTOR = 0.1 ;
8+
9+ type ZoomControlsProps = {
10+ className ?: string ;
11+ } ;
12+
13+ const ZoomControls = ( props : ZoomControlsProps ) => {
14+ const [ zoom , setZoom ] = useState ( document . body . style . zoom || 1 ) ;
15+
16+ useEffect ( ( ) => {
17+ document . body . style . zoom = zoom ;
18+ } , [ zoom ] ) ;
19+
20+ return (
21+ < ButtonGroup className = { props . className } >
22+ < Button
23+ onClick = { ( ) => {
24+ setZoom ( Math . min ( zoom + ZOOM_FACTOR , MAX_ZOOM_LEVEL ) ) ;
25+ } }
26+ htmlType = "button"
27+ icon = "zoom-in"
28+ />
29+ < Button
30+ onClick = { ( ) => {
31+ setZoom ( Math . max ( zoom - ZOOM_FACTOR , MIN_ZOOM_LEVEL ) ) ;
32+ } }
33+ htmlType = "button"
34+ icon = "zoom-out"
35+ />
36+ </ ButtonGroup >
37+ ) ;
38+ } ;
39+
40+ export default ZoomControls ;
You can’t perform that action at this time.
0 commit comments