11<template >
22 <div class =" " >
3- <div class =" flex mb-6" >
4- <button
5- class =" w-40 bg-gray-200 hover:bg-gray-400 py-2 px-4 text-sm rounded-tl rounded-bl border border-gray-400 focus:outline-none"
6- :class =" {'bg-gray-400': selectedProp === 'p'}"
7- @click =" selectedProp = 'p'" >Padding</button >
8- <button
9- class =" w-40 bg-gray-200 hover:bg-gray-400 py-2 px-4 text-sm border-t border-b border-gray-400 focus:outline-none"
10- :class =" {'bg-gray-400': selectedProp === 'm'}"
11- @click =" selectedProp = 'm'" >Margin</button >
12- <button
13- class =" w-40 bg-gray-200 hover:bg-gray-400 py-2 px-4 text-sm rounded-tr rounded-br border border-gray-400 focus:outline-none"
14- :class =" {'bg-gray-400': selectedProp === '-m'}"
15- @click =" selectedProp = '-m'" >Negative Margin</button >
16- <select
17- class =" ml-2 bg-gray-200 border border-gray-400 rounded w-40"
18- v-model =" dimensionProp" >
19- <option value =" " >All</option >
20- <option value =" t" >Top</option >
21- <option value =" r" >Right</option >
22- <option value =" b" >Bottom</option >
23- <option value =" l" >Left</option >
24- <option value =" x" >Horizontal</option >
25- <option value =" y" >Vertical</option >
26- </select >
3+ <div class =" lg:flex mb-6" >
4+ <div class =" flex w-full lg:w-auto mb-2 lg:mb-0" >
5+ <button
6+ class =" w-full lg:w-40 hover:bg-gray-300 py-2 px-4 text-sm rounded-tl rounded-bl border border-gray-400 focus:outline-none"
7+ :class =" {'bg-gray-300': selectedProp === 'p'}"
8+ @click =" selectedProp = 'p'" >Padding</button >
9+ <button
10+ class =" w-full lg:w-40 hover:bg-gray-300 py-2 px-4 text-sm border-t border-b border-gray-400 focus:outline-none"
11+ :class =" {'bg-gray-300': selectedProp === 'm'}"
12+ @click =" selectedProp = 'm'" >Margin</button >
13+ <button
14+ class =" w-full lg:w-40 hover:bg-gray-300 py-2 px-4 text-sm rounded-tr rounded-br border border-gray-400 focus:outline-none"
15+ :class =" {'bg-gray-300': selectedProp === '-m'}"
16+ @click =" selectedProp = '-m'" >Negative Margin</button >
17+ </div >
18+ <div class =" relative w-full lg:w-40 lg:ml-2" >
19+ <svg
20+ class =" absolute pointer-events-none"
21+ style =" right : 10px ; top : calc (50% - 6px );"
22+ width =" 11" height =" 11" viewBox =" 0 0 9 9" fill =" none" xmlns =" http://www.w3.org/2000/svg" ><path d =" M4.657 4.243h3.76a.2.2 0 0 1 .141.341l-3.76 3.76a.2.2 0 0 1-.283 0l-3.76-3.76a.2.2 0 0 1 .142-.341h3.76z" fill =" #B8C2CC" ></path ></svg >
23+ <select
24+ class =" h-full w-full px-4 py-2 border bg-white border-gray-400 rounded text-sm appearance-none"
25+ v-model =" dimensionProp" >
26+ <option value =" " >All</option >
27+ <option value =" t" >Top</option >
28+ <option value =" r" >Right</option >
29+ <option value =" b" >Bottom</option >
30+ <option value =" l" >Left</option >
31+ <option value =" x" >Horizontal</option >
32+ <option value =" y" >Vertical</option >
33+ </select >
34+ </div >
2735 </div >
2836 <div >
2937 <div
30- v-for =" (value, prop) in data "
38+ v-for =" ({ value, prop} ) in spacing "
3139 :key =" prop"
32- class =" mb-6x py-3 border-t "
40+ class =" mb-6x py-3 border-b "
3341 >
3442 <div
3543 class =" mb-2 bg-gray-400"
4856</template >
4957
5058<script >
59+ import { remToPx } from ' @/utils'
5160import CanvasBlockLabel from ' ../CanvasBlockLabel'
5261
5362export default {
@@ -67,6 +76,25 @@ export default {
6776 selectedProp: ' p' ,
6877 dimensionProp: ' '
6978 }
79+ },
80+
81+ computed: {
82+ spacing () {
83+ return Object
84+ .keys (this .data )
85+ .sort ((keyA , keyB ) => {
86+ const aInPx = this .data [keyA].indexOf (' rem' ) !== - 1 ? remToPx (this .data [keyA]) : parseFloat (this .data [keyA])
87+ const bInPx = this .data [keyB].indexOf (' rem' ) !== - 1 ? remToPx (this .data [keyB]) : parseFloat (this .data [keyB])
88+ console .log (this .data [keyA], aInPx, bInPx)
89+ return aInPx - bInPx
90+ })
91+ .map (key => {
92+ return {
93+ prop: key,
94+ value: this .data [key]
95+ }
96+ })
97+ }
7098 }
7199}
72100 </script >
0 commit comments