206 lines
3.8 KiB
Vue
206 lines
3.8 KiB
Vue
<script setup lang="ts">
|
|
import { computed } from 'vue';
|
|
import UiIcon from '@/components/UiIcon.vue';
|
|
import { isAutomationCondition, type AutomationStep } from '@mento/shared';
|
|
|
|
const props = defineProps<{
|
|
step: AutomationStep;
|
|
title: string;
|
|
hint: string;
|
|
selected: boolean;
|
|
removable: boolean;
|
|
}>();
|
|
|
|
const emit = defineEmits<{ select: []; remove: [] }>();
|
|
|
|
const isCondition = computed(() => isAutomationCondition(props.step));
|
|
|
|
const icon = computed(() => {
|
|
if (isCondition.value) return 'filter';
|
|
if (props.step.action === 'create_notification') return 'bell';
|
|
if (props.step.action === 'add_loyalty_points') return 'gift';
|
|
return 'flag';
|
|
});
|
|
|
|
const kindClass = computed(() =>
|
|
isCondition.value ? 'condition' : props.step.action ?? 'create_activity',
|
|
);
|
|
</script>
|
|
|
|
<template>
|
|
<div class="node-wrap">
|
|
<button
|
|
class="node"
|
|
type="button"
|
|
:class="[kindClass, { on: selected }]"
|
|
@click="emit('select')"
|
|
>
|
|
<span class="icon">
|
|
<UiIcon :name="icon" :size="18" />
|
|
</span>
|
|
<span class="copy">
|
|
<span class="kind">{{ isCondition ? 'شرط' : 'آنگاه' }}</span>
|
|
<strong>{{ title }}</strong>
|
|
<em>{{ hint }}</em>
|
|
</span>
|
|
</button>
|
|
<button
|
|
v-if="removable"
|
|
class="trash"
|
|
type="button"
|
|
title="حذف"
|
|
@click.stop="emit('remove')"
|
|
>
|
|
<UiIcon name="trash" :size="14" />
|
|
</button>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.node-wrap {
|
|
position: relative;
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
.node {
|
|
width: 13.6rem;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.7rem;
|
|
text-align: start;
|
|
padding: 0.72rem 0.8rem;
|
|
border-radius: var(--radius);
|
|
border: 1px solid #d5ddd8;
|
|
border-inline-start-width: 5px;
|
|
background: #fff;
|
|
box-shadow: 0 10px 24px rgba(23, 33, 28, 0.06);
|
|
cursor: pointer;
|
|
color: inherit;
|
|
font: inherit;
|
|
}
|
|
|
|
.node.create_activity {
|
|
border-inline-start-color: #14b8a6;
|
|
}
|
|
|
|
.node.create_notification {
|
|
border-inline-start-color: #2563eb;
|
|
}
|
|
|
|
.node.add_loyalty_points {
|
|
border-inline-start-color: #7c3aed;
|
|
}
|
|
|
|
.node.condition {
|
|
width: 15.1rem;
|
|
min-height: 4.6rem;
|
|
padding-inline: 1.15rem;
|
|
border: 0;
|
|
border-radius: 0;
|
|
background: #fffbeb;
|
|
box-shadow: none;
|
|
clip-path: polygon(12% 0%, 88% 0%, 100% 50%, 88% 100%, 12% 100%, 0% 50%);
|
|
filter: drop-shadow(0 8px 14px rgba(180, 83, 9, 0.14));
|
|
}
|
|
|
|
.node.on {
|
|
border-color: #14b8a6;
|
|
box-shadow:
|
|
0 0 0 3px rgba(20, 184, 166, 0.18),
|
|
0 12px 24px rgba(15, 23, 42, 0.08);
|
|
}
|
|
|
|
.node.condition.on {
|
|
background: #fde68a;
|
|
box-shadow: none;
|
|
}
|
|
|
|
.icon {
|
|
width: 2.35rem;
|
|
height: 2.35rem;
|
|
border-radius: var(--radius);
|
|
display: grid;
|
|
place-items: center;
|
|
flex-shrink: 0;
|
|
color: #0f766e;
|
|
background: #ecfdf8;
|
|
}
|
|
|
|
.node.create_notification .icon {
|
|
color: #1d4ed8;
|
|
background: #eff6ff;
|
|
}
|
|
|
|
.node.add_loyalty_points .icon {
|
|
color: #7c3aed;
|
|
background: #f5f3ff;
|
|
}
|
|
|
|
.node.condition .icon {
|
|
color: #b45309;
|
|
background: #ffedd5;
|
|
}
|
|
|
|
.copy {
|
|
display: grid;
|
|
gap: 0.08rem;
|
|
min-width: 0;
|
|
}
|
|
|
|
.kind {
|
|
font-size: 0.7rem;
|
|
font-weight: 700;
|
|
color: #94a3b8;
|
|
}
|
|
|
|
strong {
|
|
font-size: 0.88rem;
|
|
font-weight: 600;
|
|
color: #0f172a;
|
|
}
|
|
|
|
em {
|
|
font-style: normal;
|
|
font-size: 0.72rem;
|
|
color: #64748b;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.trash {
|
|
position: absolute;
|
|
top: -0.45rem;
|
|
inset-inline-end: -0.45rem;
|
|
width: 1.55rem;
|
|
height: 1.55rem;
|
|
border-radius: 999px;
|
|
border: 1px solid #fecaca;
|
|
background: #fff;
|
|
color: #b91c1c;
|
|
display: grid;
|
|
place-items: center;
|
|
cursor: pointer;
|
|
opacity: 0;
|
|
pointer-events: none;
|
|
}
|
|
|
|
.node-wrap:hover .trash,
|
|
.node-wrap:focus-within .trash,
|
|
.node.on ~ .trash {
|
|
opacity: 1;
|
|
pointer-events: auto;
|
|
}
|
|
|
|
@media (max-width: 700px) {
|
|
.node {
|
|
width: 12.4rem;
|
|
}
|
|
|
|
.node.condition {
|
|
width: 14rem;
|
|
}
|
|
}
|
|
</style>
|