11<template >
22 <div class =" result" >
33 <template v-if =" isResultNexting " >
4- <MainLoader :size =" sizeType.s" :theme =" themeType.secondary" class =" result__display" />
4+ <MainLoader
5+ :size =" sizeType.s"
6+ :theme =" themeType.secondary"
7+ class =" result__display"
8+ />
59 <p class =" result__text" >
6- Nesting</p >
10+ Nesting
11+ </p >
712 </template >
813 <template v-else >
914 <div v-if =" isResultFailed" class =" result__placeholder" >
1015 Err
1116 </div >
1217 <template v-else >
13- <div class =" result__svg-row" >
14- <SvgDisplay v-for =" (svg, idx) in result.svgs" :key =" svg + idx" :size =" sizeType.s" :src =" svg"
15- class =" result__display" />
18+ <div
19+ :class =" svgRowClasses"
20+ class =" result__svg-row"
21+ >
22+ <SvgDisplay
23+ v-for =" (svg, svgIndex) in result.svgs"
24+ :key =" `svg-${svgIndex}`"
25+ :src =" svg"
26+ :size =" sizeType.s"
27+ class =" result__display"
28+ />
1629 </div >
1730 </template >
1831 <p class =" result__name" >
1932 {{ result.slug }}.dxf
2033 </p >
2134 <div class =" result__controls controls" >
22- <MainButton v-if =" isResultCompleted" :href =" downloadUrl" :label =" downloadButtonText" tag =" a"
23- :size =" sizeType.s" :theme =" themeType.primary" class =" controls__download" @click =" onDownload" />
35+ <MainButton
36+ v-if =" isResultCompleted"
37+ :href =" downloadUrl"
38+ :label =" downloadButtonText"
39+ tag =" a"
40+ :size =" sizeType.s"
41+ :theme =" themeType.primary"
42+ class =" controls__download"
43+ @click =" onDownload"
44+ />
2445 </div >
25- <button @click =" openModal()" class =" result__area" />
46+ <button
47+ type =" button"
48+ @click =" openModal"
49+ class =" result__area"
50+ aria-label =" Open result details"
51+ />
2652 </template >
2753 </div >
2854</template >
55+
2956<script setup>
3057import { sizeType } from ' ~~/constants/size.constants' ;
3158import { themeType } from ' ~~/constants/theme.constants' ;
3259import { statusType } from " ~~/constants/status.constants" ;
3360import { trackEvent } from ' ~~/utils/track' ;
34- import { computed , unref } from " vue" ;
61+ import { computed } from " vue" ;
3562
36- const { result } = defineProps ({
63+ const props = defineProps ({
3764 result: {
3865 type: Object ,
3966 required: true
4067 }
41- })
68+ });
4269
4370const emit = defineEmits ([" openModal" ]);
4471
4572const isMultiSheet = computed (() => {
46- return unref ( result) .isMultiSheet
47- })
73+ return props . result ? .isMultiSheet ?? false ;
74+ });
4875
4976const downloadUrl = computed (() => {
50- return unref ( result) .downloadUrl
51- })
77+ return props . result ? .downloadUrl ?? ' ' ;
78+ });
5279
5380const downloadButtonText = computed (() => {
54- if (isMultiSheet .value ) {
55- return ' Download All'
56- }
57- return ' Download'
58- })
81+ return isMultiSheet .value ? ' Download All' : ' Download' ;
82+ });
83+
84+ const hasMultipleSvgs = computed (() => {
85+ return (props .result ? .svgs ? .length ?? 0 ) > 1 ;
86+ });
87+
88+ const svgRowClasses = computed (() => {
89+ return [' result__svg-row' , { ' result__svg-row--multi' : hasMultipleSvgs .value }];
90+ });
5991
6092const isResultNexting = computed (() => {
61- return [statusType .unfinished , statusType .pending ].includes (unref (result).status )
62- })
93+ const status = props .result ? .status ;
94+ return status === statusType .unfinished || status === statusType .pending ;
95+ });
96+
6397const isResultFailed = computed (() => {
64- return unref (result).status === statusType .failed
65- })
98+ return props .result ? .status === statusType .failed ;
99+ });
100+
66101const isResultCompleted = computed (() => {
67- return unref (result).status === statusType .completed || unref (result).status === statusType .done
68- })
102+ const status = props .result ? .status ;
103+ return status === statusType .completed || status === statusType .done ;
104+ });
105+
69106const openModal = () => {
70- emit (' openModal' )
71- }
107+ emit (' openModal' );
108+ };
72109
73110const onDownload = () => {
74111 trackEvent (' click_download_button' , {
75- slug: unref ( result) .slug ,
112+ slug: props . result ? .slug ,
76113 isMultiSheet: isMultiSheet .value
77- })
78- }
114+ });
115+ };
79116< / script>
80117< style lang= " scss" scoped>
81118.result {
@@ -90,15 +127,21 @@ const onDownload = () => {
90127 & __svg- row {
91128 max- width: 128px ;
92129 display: grid;
93- grid-template-columns : repeat ( 3 , 1fr ) ;
130+ grid- template- columns: 1fr ;
94131 gap: 4px ;
95132 margin- bottom: 8px ;
133+
134+ & -- multi {
135+ grid- template- columns: repeat (3 , 1fr );
136+ }
96137 }
97138
98139 & __display,
99140 & __placeholder {
100141 width: 40px ;
101142 height: 40px ;
143+ min- height: 40px ;
144+ overflow: hidden;
102145 }
103146
104147 & __placeholder {
@@ -138,6 +181,9 @@ const onDownload = () => {
138181 bottom: 0 ;
139182 left: 0 ;
140183 cursor: pointer;
184+ border: none;
185+ background: transparent;
186+ padding: 0 ;
141187 }
142188
143189 & __controls {
0 commit comments