Skip to content

Commit

Permalink
Updated z-index on button.
Browse files Browse the repository at this point in the history
  • Loading branch information
michielvandergeest committed Sep 26, 2024
1 parent 2467425 commit 666d300
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
4 changes: 0 additions & 4 deletions src/components/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export default Blits.Component('Button', {
:effects="[$shader('radius', {radius: 20})]"
:alpha.transition="$alpha"
:scale.transition="$scale"
:z="$zIndex"
:rotation="$rotate"
>
</Element>
Expand All @@ -36,7 +35,6 @@ export default Blits.Component('Button', {
return {
alpha: 0.4,
scale: 1,
zIndex: 1,
rotate: 0,
}
},
Expand All @@ -45,13 +43,11 @@ export default Blits.Component('Button', {
this.$log.info(`Button with color ${this.color} received focus`)
this.alpha = 1
this.scale = this.scale === 1 ? 1.2 : 1
this.zIndex = 100
},
unfocus() {
this.$log.info(`Button with color ${this.color} lost focus`)
this.alpha = 0.4
this.scale = 1
this.zIndex = 1
this.rotate = 0
},
},
Expand Down
24 changes: 15 additions & 9 deletions src/pages/FocusHandling.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ export default Blits.Component('FocusHandling', {
template: `
<Element>
<Element x="300" y="150">
<Button color="#ef4444" x="0" ref="button1" />
<Button color="#f97316" x="320" ref="button2" />
<Button color="#84cc16" x="640" ref="button3" />
<Button color="#10b981" x="0" y="100" ref="button4" />
<Button color="#06b6d4" y="100" x="320" ref="button5" />
<Button color="#3b82f6" y="100" x="640" ref="button6" />
<Button color="#8b5cf6" y="200" x="0" ref="button7" />
<Button color="#d946ef" y="200" x="320" ref="button8" />
<Button color="#f43f5e" y="200" x="640" ref="button9" />
<Button color="#ef4444" x="0" ref="button1" :z="$focused === 1 ? 1 : 0" />
<Button color="#f97316" x="320" ref="button2" :z="$focused === 2 ? 1 : 0" />
<Button color="#84cc16" x="640" ref="button3" :z="$focused === 3 ? 1 : 0" />
<Button color="#10b981" x="0" y="100" ref="button4" :z="$focused === 4 ? 1 : 0" />
<Button color="#06b6d4" y="100" x="320" ref="button5" :z="$focused === 5 ? 1 : 0" />
<Button color="#3b82f6" y="100" x="640" ref="button6" :z="$focused === 6 ? 1 : 0" />
<Button color="#8b5cf6" y="200" x="0" ref="button7" :z="$focused === 7 ? 1 : 0" />
<Button color="#d946ef" y="200" x="320" ref="button8" :z="$focused === 8 ? 1 : 0" />
<Button color="#f43f5e" y="200" x="640" ref="button9" :z="$focused === 9 ? 1 : 0" />
</Element>
<Menu ref="menu" />
</Element>
Expand Down Expand Up @@ -74,4 +74,10 @@ export default Blits.Component('FocusHandling', {
if (menu && menu.$focus) menu.$focus()
},
},
methods: {
zIndex(index) {
console.log(index)
return this.focused === index ? 1 : 0
},
},
})

0 comments on commit 666d300

Please sign in to comment.