2121 :width =" meshWidth"
2222 xmlns =" http://www.w3.org/2000/svg"
2323 >
24+ <defs >
25+ <clipPath id =" hex-clip" >
26+ <polygon :points =" hexPath" />
27+ </clipPath >
28+ </defs >
2429 <template v-for =" row in rows " >
2530 <g
2631 v-for =" col in cols + (row % 2 ? 0 : -1)"
4752 </div >
4853</template >
4954
50- <script lang="ts" >
51- import { PropType , ref } from ' vue' ;
55+ <script >
56+ import { ref } from ' vue' ;
5257
5358import onResize from ' @/directives/on-resize' ;
54- import Instance from ' @/services/instance' ;
5559import { calcLayout } from ' @/views/wallboard/utils' ;
5660
57- type InstancesListItem = {
58- name: string ;
59- statusKey? : string ;
60- status? : string ;
61- instances: Instance [];
62- };
63-
6461export default {
6562 directives: { onResize },
6663 props: {
6764 items: {
68- type: Object as PropType < InstancesListItem []> ,
65+ type: Array ,
6966 default : () => [],
7067 },
7168 classForItem: {
72- type: Object as PropType < Function > ,
73- default : () => () => void 0 ,
69+ type: Function ,
70+ default : () => void 0 ,
7471 },
7572 },
7673 emits: [' click' ],
7774 setup () {
78- const root = ref < HTMLElement | null > (null );
75+ const root = ref (null );
7976
8077 return {
8178 root,
@@ -110,36 +107,34 @@ export default {
110107 },
111108 watch: {
112109 sideLength (newVal ) {
113- if (this .root ) {
114- this .root .style .fontSize = ` ${newVal / 9.5 }px ` ;
115- }
110+ this .root .style [' font-size' ] = ` ${ newVal / 9.5 } px` ;
116111 },
117112 itemCount: {
118113 handler: ' updateLayout' ,
119114 immediate: true ,
120115 },
121116 },
122117 methods: {
123- translate(col : number , row : number ) {
118+ translate (col , row ) {
124119 const x = (col - 1 ) * this .hexWidth + (row % 2 ? 0 : this .hexWidth / 2 );
125120 const y = (row - 1 ) * this .sideLength * 1.5 ;
126121 return ` translate(${ x} ,${ y} )` ;
127122 },
128- item(col : number , row : number ) : InstancesListItem {
123+ item (col , row ) {
129124 const rowOffset =
130125 (row - 1 ) * this .cols - Math .max (Math .floor ((row - 1 ) / 2 ), 0 );
131126 const index = rowOffset + col - 1 ;
132127 return this .items [index];
133128 },
134- point(i : number ) : string {
129+ point (i ) {
135130 const innerSideLength = this .sideLength * 0.95 ;
136131 const marginTop = this .hexHeight / 2 ;
137132 const marginLeft = this .hexWidth / 2 ;
138133 return ` ${
139134 marginLeft + innerSideLength * Math .cos (((1 + i * 2 ) * Math .PI ) / 6 )
140135 } ,${ marginTop + innerSideLength * Math .sin (((1 + i * 2 ) * Math .PI ) / 6 )} ` ;
141136 },
142- click(event : MouseEvent , col : number , row : number ) {
137+ click (event , col , row ) {
143138 const item = this .item (col, row);
144139 if (item) {
145140 this .$emit (' click' , item, event );
@@ -158,9 +153,9 @@ export default {
158153 this .sideLength = layout .sideLength ;
159154 }
160155 },
161- onResize(entries : Event [] ) {
156+ onResize (entries ) {
162157 for (let e of entries) {
163- if (( e .target as HTMLElement ) === this .root ) {
158+ if (e .target === this .root ) {
164159 this .updateLayout ();
165160 }
166161 }
@@ -187,8 +182,7 @@ export default {
187182}
188183
189184.hex polygon {
190- fill : var (--color , transparent );
191- stroke : var (--color , transparent );
185+ fill : transparent ;
192186 transition : all ease-out 250ms ;
193187}
194188
0 commit comments