wip: more elegant solution; breaks DoorCanvas, PreviewDoor
This commit is contained in:
parent
5213e0b8b1
commit
53bfdfd7b5
4 changed files with 48 additions and 52 deletions
|
@ -1,10 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<SVGRect
|
<SVGRect
|
||||||
style="cursor: pointer"
|
style="cursor: pointer"
|
||||||
:variant="visible || hovered ? 'primary' : undefined"
|
variant="primary"
|
||||||
|
:visible="store.is_touch_device || force_visible"
|
||||||
:rectangle="door.position"
|
:rectangle="door.position"
|
||||||
@mouseenter="hovered = true"
|
|
||||||
@mouseleave="hovered = false"
|
|
||||||
>
|
>
|
||||||
<div class="has-text-danger">{{ door.day }}</div>
|
<div class="has-text-danger">{{ door.day }}</div>
|
||||||
</SVGRect>
|
</SVGRect>
|
||||||
|
@ -12,6 +11,7 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Door } from "@/lib/door";
|
import { Door } from "@/lib/door";
|
||||||
|
import { advent22Store } from "@/plugins/store";
|
||||||
import { Options, Vue } from "vue-class-component";
|
import { Options, Vue } from "vue-class-component";
|
||||||
|
|
||||||
import SVGRect from "./SVGRect.vue";
|
import SVGRect from "./SVGRect.vue";
|
||||||
|
@ -22,16 +22,16 @@ import SVGRect from "./SVGRect.vue";
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
door: Door,
|
door: Door,
|
||||||
visible: {
|
force_visible: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
export default class extends Vue {
|
export default class extends Vue {
|
||||||
public door!: Door;
|
public readonly store = advent22Store();
|
||||||
public visible!: boolean;
|
|
||||||
|
|
||||||
public hovered = false;
|
public door!: Door;
|
||||||
|
public force_visible!: boolean;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -7,23 +7,14 @@
|
||||||
:height="rectangle.height"
|
:height="rectangle.height"
|
||||||
:style="`transform: scaleX(${1 / store.calendar_aspect_ratio})`"
|
:style="`transform: scaleX(${1 / store.calendar_aspect_ratio})`"
|
||||||
>
|
>
|
||||||
<!-- v-if="variant !== undefined" -->
|
|
||||||
<div
|
<div
|
||||||
xmlns="http://www.w3.org/1999/xhtml"
|
xmlns="http://www.w3.org/1999/xhtml"
|
||||||
class="px-4 is-flex is-align-items-center is-justify-content-center is-size-1 has-text-weight-bold has-background-primary"
|
:class="`px-4 is-flex is-align-items-center is-justify-content-center is-size-1 has-text-weight-bold ${extra_classes}`"
|
||||||
style="height: inherit"
|
style="height: inherit"
|
||||||
>
|
>
|
||||||
<slot name="default" />
|
<slot name="default" />
|
||||||
</div>
|
</div>
|
||||||
</foreignObject>
|
</foreignObject>
|
||||||
<!-- <rect
|
|
||||||
v-bind="$attrs"
|
|
||||||
:class="variant !== undefined ? variant : ''"
|
|
||||||
:x="rectangle.left"
|
|
||||||
:y="rectangle.top"
|
|
||||||
:width="rectangle.width"
|
|
||||||
:height="rectangle.height"
|
|
||||||
/> -->
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
@ -41,58 +32,61 @@ type BulmaVariant =
|
||||||
|
|
||||||
@Options({
|
@Options({
|
||||||
props: {
|
props: {
|
||||||
variant: {
|
variant: String,
|
||||||
type: String,
|
visible: {
|
||||||
required: false,
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
},
|
},
|
||||||
rectangle: Rectangle,
|
rectangle: Rectangle,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
export default class extends Vue {
|
export default class extends Vue {
|
||||||
public variant?: BulmaVariant;
|
public readonly store = advent22Store();
|
||||||
|
|
||||||
|
private variant!: BulmaVariant;
|
||||||
|
private visible!: boolean;
|
||||||
public rectangle!: Rectangle;
|
public rectangle!: Rectangle;
|
||||||
|
|
||||||
public readonly store = advent22Store();
|
public get extra_classes(): string {
|
||||||
|
let result = this.variant;
|
||||||
|
|
||||||
|
if (this.visible) result += " visible";
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@import "@/bulma-vars";
|
@import "@/bulma-vars";
|
||||||
|
|
||||||
rect {
|
@mixin visible_rect($name, $color) {
|
||||||
fill: transparent;
|
&.#{$name} {
|
||||||
fill-opacity: 0.3;
|
background-color: rgba($color, 0.3);
|
||||||
stroke-opacity: 0.9;
|
border-color: rgba($color, 0.9);
|
||||||
stroke-width: 1;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&.primary {
|
foreignObject > div {
|
||||||
fill: $primary;
|
:deep() > * {
|
||||||
stroke: $primary;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.link {
|
&.visible,
|
||||||
fill: $link;
|
&:hover {
|
||||||
stroke: $link;
|
:deep() > * {
|
||||||
}
|
display: initial;
|
||||||
|
}
|
||||||
|
|
||||||
&.info {
|
border-width: 3px;
|
||||||
fill: $info;
|
border-style: solid;
|
||||||
stroke: $info;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.success {
|
@include visible_rect("primary", $primary);
|
||||||
fill: $success;
|
@include visible_rect("link", $link);
|
||||||
stroke: $success;
|
@include visible_rect("info", $info);
|
||||||
}
|
@include visible_rect("success", $success);
|
||||||
|
@include visible_rect("warning", $warning);
|
||||||
&.warning {
|
@include visible_rect("danger", $danger);
|
||||||
fill: $warning;
|
|
||||||
stroke: $warning;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.danger {
|
|
||||||
fill: $danger;
|
|
||||||
stroke: $danger;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -13,12 +13,13 @@
|
||||||
:key="`door-${index}`"
|
:key="`door-${index}`"
|
||||||
:door="door"
|
:door="door"
|
||||||
style="cursor: inherit"
|
style="cursor: inherit"
|
||||||
visible
|
force_visible
|
||||||
/>
|
/>
|
||||||
<SVGRect
|
<SVGRect
|
||||||
v-if="preview_visible"
|
v-if="preview_visible"
|
||||||
variant="success"
|
variant="success"
|
||||||
:rectangle="preview_rect"
|
:rectangle="preview_rect"
|
||||||
|
visible
|
||||||
/>
|
/>
|
||||||
</ThouCanvas>
|
</ThouCanvas>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
:rectangle="door.position"
|
:rectangle="door.position"
|
||||||
:variant="editing ? 'success' : 'primary'"
|
:variant="editing ? 'success' : 'primary'"
|
||||||
@click.left="on_click"
|
@click.left="on_click"
|
||||||
|
visible
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
v-if="editing"
|
v-if="editing"
|
||||||
|
|
Loading…
Reference in a new issue