@@ -4,7 +4,7 @@ import HTML
44import Vue
55
66struct HeaderView : HTML {
7- @ Dependency ( \ . envVars ) var envVars
7+ let selected : Vue . Expression
88
99 var body : some HTML {
1010 header {
@@ -16,9 +16,8 @@ struct HeaderView: HTML {
1616 . inlineStyle ( " font-weight " , " bold " )
1717 }
1818 . inlineStyle ( " text-decoration " , " none " )
19- // TODO: Add buttons to allow switching between code styling or plain text
2019
21- CodeSelector ( )
20+ CodeSelector ( selected : selected )
2221 }
2322 . containerStyling ( )
2423 . inlineStyle ( " display " , " flex " )
@@ -31,12 +30,15 @@ struct HeaderView: HTML {
3130 }
3231}
3332
34- private struct CodeSelector : VueComponent {
35- @ Reactive let visible = false
33+ private struct CodeSelector : HTML {
34+ let selected : Vue . Expression
3635
3736 var body : some HTML {
38- div {
39- button ( . v. on ( . click, Expression ( rawValue: " \( $visible) = \( !$visible) " ) ) ) {
37+ #VueScope( false ) { ( visible: Vue . Expression ) in
38+ button (
39+ . v. on ( . click, visible. assign ( !visible) ) ,
40+ . v. bind ( attrOrProp: " style " , Expression ( rawValue: " \( visible) ? { background: '#8A8A8A', color: '#080808' } : null " ) )
41+ ) {
4042 code { " </> " }
4143 }
4244 . inlineStyle ( " font-weight " , " bold " )
@@ -46,19 +48,26 @@ private struct CodeSelector: VueComponent {
4648 . inlineStyle ( " border-radius " , " 0.3rem " )
4749 . inlineStyle ( " padding " , " 0.28rem 0.4rem " )
4850 . inlineStyle ( " color " , " #AAA " )
51+ . inlineStyle ( " pointer " , " cursor " )
4952
50- ul ( . v . show ( $ visible) ) {
53+ ul ( . hidden , . v . bind ( attrOrProp : " hidden " , ! visible) ) {
5154 for code in CodeLang . allCases {
5255 li {
53- button ( . v. on ( . click, Expression ( rawValue: " \( $visible) = null " ) ) ) {
56+ button (
57+ . v. on ( . click, selected. assign ( Expression ( code) ) ) ,
58+ . v. on ( . click, modifiers: . prevent, visible. assign ( !visible) )
59+ ) {
5460 code. title
5561 }
5662 . inlineStyle ( " all " , " unset " )
5763 . inlineStyle ( " display " , " inline-block " )
5864 . inlineStyle ( " width " , " 100% " )
5965 . inlineStyle ( " padding " , " 0.5rem " )
6066 . inlineStyle ( " cursor " , " pointer " )
67+ // TODO: Add background highlight
68+ // .inlineStyle("background", "#2A2A2A", pseudo: .hover)
6169 }
70+ . inlineStyle ( " overflow " , " hidden " )
6271 }
6372 }
6473 . inlineStyle ( " position " , " absolute " )
0 commit comments