Files
vue-flow/docs/examples/layout/ProcessNode.vue
2024-02-06 23:58:02 +01:00

81 lines
1.5 KiB
Vue

<script setup>
import { toRef } from 'vue'
import { Handle } from '@vue-flow/core'
const props = defineProps({
data: {
type: Object,
required: true,
},
sourcePosition: {
type: String,
},
targetPosition: {
type: String,
},
})
const bgColor = toRef(() => {
if (props.data.hasError) {
return '#f87171'
}
if (props.data.isFinished) {
return '#10b981'
}
if (props.data.isCancelled) {
return '#fbbf24'
}
return '#4b5563'
})
</script>
<template>
<div class="process-node" :style="{ backgroundColor: bgColor }">
<Handle type="target" :position="targetPosition" />
<Handle type="source" :position="sourcePosition" />
<div v-if="data.isRunning" class="spinner" />
<span v-else-if="data.hasError">&#x274C;</span>
<span v-else-if="data.isSkipped">&#x1F6A7;</span>
<span v-else-if="data.isFinished"> &#x1F60E;</span>
<span v-else-if="data.isCancelled"> &#x1F6AB;</span>
<span v-else> &#x1F4E6;</span>
</div>
</template>
<style scoped>
.process-node {
padding: 10px;
color: white;
border-radius: 99px;
font-size: 12px;
width: 18px;
height: 18px;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}
.spinner {
border: 3px solid #f3f3f3;
border-top: 3px solid #10b981;
border-radius: 50%;
width: 10px;
height: 10px;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>