11<script setup lang="ts">
2- import { Menu } from ' floating-vue'
2+ import { Dropdown } from ' floating-vue'
3+ import { ref } from ' vue'
34import { useDrawings } from ' ../composables/useDrawings'
45import Draggable from ' ./Draggable.vue'
56import IconButton from ' ./IconButton.vue'
@@ -18,6 +19,23 @@ const {
1819 brushColors,
1920} = useDrawings ()
2021
22+ const strokeWidthDropdownShown = ref (false )
23+
24+ function showStrokeWidthDropdown(event : Event ) {
25+ event .preventDefault ()
26+ event .stopPropagation ()
27+ requestAnimationFrame (() => {
28+ requestAnimationFrame (() => {
29+ strokeWidthDropdownShown .value = true
30+ })
31+ })
32+ }
33+
34+ function showStrokeWidthDropdownForPointer(event : PointerEvent ) {
35+ if (event .pointerType !== ' mouse' )
36+ showStrokeWidthDropdown (event )
37+ }
38+
2139function undo() {
2240 drauu .undo ()
2341}
@@ -71,8 +89,8 @@ function setBrushColor(color: string) {
7189
7290 <VerticalDivider />
7391
74- <Menu >
75- <IconButton title="Adjust stroke width" :class =" { shallow: drawingMode === ' eraseLine' } " >
92+ <Dropdown v-model : shown = " strokeWidthDropdownShown " : triggers = " [] " >
93+ <IconButton title="Adjust stroke width" :class =" { shallow: drawingMode === ' eraseLine' } " @ click = " showStrokeWidthDropdown " @ pointerdown = " showStrokeWidthDropdownForPointer " @ pointerup = " showStrokeWidthDropdownForPointer " @ touchend = " showStrokeWidthDropdown " >
7694 <svg viewBox =" 0 0 32 32" width =" 1.2em" height =" 1.2em" >
7795 <line x1 =" 2" y1 =" 15" x2 =" 22" y2 =" 4" stroke =" currentColor" stroke-width =" 1" stroke-linecap =" round" />
7896 <line x1 =" 2" y1 =" 24" x2 =" 28" y2 =" 10" stroke =" currentColor" stroke-width =" 2" stroke-linecap =" round" />
@@ -89,7 +107,7 @@ function setBrushColor(color: string) {
89107 </div >
90108 </div >
91109 </template >
92- </Menu >
110+ </Dropdown >
93111 <IconButton
94112 v-for =" color of brushColors "
95113 :key =" color "
@@ -134,7 +152,7 @@ function setBrushColor(color: string) {
134152</template >
135153
136154<style >
137- .v-popper--theme-menu .v-popper__arrow-inner {
155+ .v-popper--theme-dropdown .v-popper__arrow-inner {
138156 --uno : border-main;
139157}
140158 </style >
0 commit comments