2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
|
|
|
<div class="cpjygsrt" :class="{ error: error != null, warn: warn != null }">
|
|
|
|
<header>
|
|
|
|
<div class="title"><slot name="header"></slot></div>
|
|
|
|
<div class="buttons">
|
|
|
|
<slot name="func"></slot>
|
|
|
|
<button v-if="removable" @click="remove()" class="_button">
|
2020-10-17 13:12:00 +02:00
|
|
|
<Fa :icon="faTrashAlt"/>
|
2020-01-29 20:37:25 +01:00
|
|
|
</button>
|
|
|
|
<button v-if="draggable" class="drag-handle _button">
|
2020-10-17 13:12:00 +02:00
|
|
|
<Fa :icon="faBars"/>
|
2020-01-29 20:37:25 +01:00
|
|
|
</button>
|
|
|
|
<button @click="toggleContent(!showBody)" class="_button">
|
2020-10-17 13:12:00 +02:00
|
|
|
<template v-if="showBody"><Fa :icon="faAngleUp"/></template>
|
|
|
|
<template v-else><Fa :icon="faAngleDown"/></template>
|
2020-01-29 20:37:25 +01:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</header>
|
|
|
|
<p v-show="showBody" class="error" v-if="error != null">{{ $t('_pages.script.typeError', { slot: error.arg + 1, expect: $t(`script.types.${error.expect}`), actual: $t(`script.types.${error.actual}`) }) }}</p>
|
|
|
|
<p v-show="showBody" class="warn" v-if="warn != null">{{ $t('_pages.script.thereIsEmptySlot', { slot: warn.slot + 1 }) }}</p>
|
2020-04-16 16:13:33 +02:00
|
|
|
<div v-show="showBody" class="body">
|
2020-01-29 20:37:25 +01:00
|
|
|
<slot></slot>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 13:12:00 +02:00
|
|
|
import { defineComponent } from 'vue';
|
2020-01-29 20:37:25 +01:00
|
|
|
import { faBars, faAngleUp, faAngleDown } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import { faTrashAlt } from '@fortawesome/free-regular-svg-icons';
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
export default defineComponent({
|
2020-01-29 20:37:25 +01:00
|
|
|
props: {
|
|
|
|
expanded: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true
|
|
|
|
},
|
|
|
|
removable: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true
|
|
|
|
},
|
|
|
|
draggable: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
error: {
|
|
|
|
required: false,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
warn: {
|
|
|
|
required: false,
|
|
|
|
default: null
|
|
|
|
}
|
|
|
|
},
|
2020-12-05 04:50:09 +01:00
|
|
|
emits: ['toggle', 'remove'],
|
2020-01-29 20:37:25 +01:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
showBody: this.expanded,
|
|
|
|
faTrashAlt, faBars, faAngleUp, faAngleDown
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toggleContent(show: boolean) {
|
|
|
|
this.showBody = show;
|
|
|
|
this.$emit('toggle', show);
|
|
|
|
},
|
|
|
|
remove() {
|
|
|
|
this.$emit('remove');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.cpjygsrt {
|
|
|
|
position: relative;
|
2021-03-02 14:57:16 +01:00
|
|
|
overflow: hidden;
|
2020-01-29 20:37:25 +01:00
|
|
|
background: var(--panel);
|
2020-07-04 20:49:58 +02:00
|
|
|
border: solid 2px var(--X12);
|
2020-01-29 20:37:25 +01:00
|
|
|
border-radius: 6px;
|
|
|
|
|
|
|
|
&:hover {
|
2020-07-04 20:49:58 +02:00
|
|
|
border: solid 2px var(--X13);
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
&.warn {
|
|
|
|
border: solid 2px #dec44c;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.error {
|
|
|
|
border: solid 2px #f00;
|
|
|
|
}
|
|
|
|
|
|
|
|
& + .cpjygsrt {
|
|
|
|
margin-top: 16px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> header {
|
|
|
|
> .title {
|
|
|
|
z-index: 1;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0 16px;
|
|
|
|
line-height: 42px;
|
|
|
|
font-size: 0.9em;
|
|
|
|
font-weight: bold;
|
|
|
|
box-shadow: 0 1px rgba(#000, 0.07);
|
|
|
|
|
|
|
|
> [data-icon] {
|
|
|
|
margin-right: 6px;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:empty {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .buttons {
|
|
|
|
position: absolute;
|
|
|
|
z-index: 2;
|
|
|
|
top: 0;
|
|
|
|
right: 0;
|
|
|
|
|
|
|
|
> button {
|
|
|
|
padding: 0;
|
|
|
|
width: 42px;
|
|
|
|
font-size: 0.9em;
|
|
|
|
line-height: 42px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.drag-handle {
|
|
|
|
cursor: move;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .warn {
|
|
|
|
color: #b19e49;
|
|
|
|
margin: 0;
|
|
|
|
padding: 16px 16px 0 16px;
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .error {
|
|
|
|
color: #f00;
|
|
|
|
margin: 0;
|
|
|
|
padding: 16px 16px 0 16px;
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
2020-04-16 16:13:33 +02:00
|
|
|
|
|
|
|
> .body {
|
2020-10-17 13:12:00 +02:00
|
|
|
::v-deep(.juejbjww), ::v-deep(.eiipwacr) {
|
2020-04-16 16:13:33 +02:00
|
|
|
&:not(.inline):first-child {
|
|
|
|
margin-top: 28px;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:not(.inline):last-child {
|
|
|
|
margin-bottom: 20px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
</style>
|