11import { createElement } from "../utils.js" ;
22import { state } from "../stateController.js" ;
3+ import { getSvg } from "../svgManager.js" ;
34
4- let shareButton ;
5+ let shareButtonLabel ;
56
67export const topbar = createElement ( 'div' )
78 . setAttribute ( 'id' , 'topbar' )
@@ -16,16 +17,34 @@ export const topbar = createElement('div')
1617 const lng = state . mapcenter ?. lng
1718 if ( z && lat && lng ) window . open ( `https://www.openstreetmap.org/edit#map=${ Math . round ( z ) + 1 } /${ lat } /${ lng } ` , '_blank' ) ;
1819 } )
19- . append ( 'Edit' ) ,
20+ . append (
21+ createElement ( 'div' )
22+ . setAttribute ( 'class' , 'icon' )
23+ . setAttribute ( 'style' , "width:12px;height:12px;" )
24+ . append (
25+ new DOMParser ( ) . parseFromString ( ( await getSvg ( { file : 'pencil-square' , fill : 'currentColor' } ) ) . string , "image/svg+xml" ) . documentElement
26+ ) ,
27+ createElement ( 'span' )
28+ . append ( 'Edit' )
29+ ) ,
2030 createElement ( 'button' )
2131 . addEventListener ( 'click' , _ => {
2232 window . open ( 'https://osm411.org' + window . location . hash , '_blank' ) ;
2333 } )
24- . append ( 'Open In…' )
34+ . append (
35+ createElement ( 'div' )
36+ . setAttribute ( 'class' , 'icon' )
37+ . setAttribute ( 'style' , "width:12px;height:12px;" )
38+ . append (
39+ new DOMParser ( ) . parseFromString ( ( await getSvg ( { file : 'arrow_top_right-square' , fill : 'currentColor' } ) ) . string , "image/svg+xml" ) . documentElement
40+ ) ,
41+ createElement ( 'span' )
42+ . append ( 'Open In…' )
43+ )
2544 ) ,
2645 createElement ( 'div' )
2746 . setAttribute ( 'class' , 'spacer' ) ,
28- shareButton = createElement ( 'button' )
47+ createElement ( 'button' )
2948 . addEventListener ( 'click' , _ => {
3049 const z = state . mapcenter ?. z ;
3150 const lat = state . mapcenter ?. lat ;
@@ -46,12 +65,21 @@ export const topbar = createElement('div')
4665 } else if ( navigator . clipboard ?. write ) {
4766 navigator . clipboard . writeText ( urlString )
4867 . then ( _ => {
49- shareButton . replaceChildren ( 'Link Copied!' ) ;
68+ shareButtonLabel . replaceChildren ( 'Link Copied!' ) ;
5069 window . setTimeout ( _ => {
51- shareButton . replaceChildren ( 'Share' ) ;
70+ shareButtonLabel . replaceChildren ( 'Share' ) ;
5271 } , 3000 )
5372 } ) ;
5473 }
5574 } )
56- . append ( 'Share' )
75+ . append (
76+ createElement ( 'div' )
77+ . setAttribute ( 'class' , 'icon' )
78+ . setAttribute ( 'style' , "width:12px;height:12px;" )
79+ . append (
80+ new DOMParser ( ) . parseFromString ( ( await getSvg ( { file : 'arrow_up-rect' , fill : 'currentColor' } ) ) . string , "image/svg+xml" ) . documentElement
81+ ) ,
82+ shareButtonLabel = createElement ( 'span' )
83+ . append ( 'Share' )
84+ )
5785 ) ;
0 commit comments