advent22/ui/src/components/calendar/SVGRect.vue

82 lines
1.7 KiB
Vue
Raw Normal View History

2023-01-17 18:25:56 +00:00
<template>
2023-09-22 19:02:51 +00:00
<foreignObject
2023-11-05 22:36:58 +00:00
:x="Math.round(store.calendar_aspect_ratio * rectangle.left)"
2023-09-22 19:02:51 +00:00
:y="rectangle.top"
2023-11-05 22:36:58 +00:00
:width="Math.round(store.calendar_aspect_ratio * rectangle.width)"
2023-09-22 19:02:51 +00:00
:height="rectangle.height"
2023-11-05 22:36:58 +00:00
:style="`transform: scaleX(${1 / store.calendar_aspect_ratio})`"
2023-09-22 19:02:51 +00:00
>
<div
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 ${extra_classes}`"
2023-10-27 15:09:44 +00:00
style="height: inherit"
2023-11-09 18:31:07 +00:00
v-bind="$attrs"
2023-09-22 19:02:51 +00:00
>
<slot name="default" />
</div>
</foreignObject>
2023-01-17 18:25:56 +00:00
</template>
<script lang="ts">
2023-09-07 02:08:56 +00:00
import { Rectangle } from "@/lib/rectangle";
2023-11-05 22:36:58 +00:00
import { advent22Store } from "@/plugins/store";
2023-09-06 16:25:35 +00:00
import { Options, Vue } from "vue-class-component";
2023-01-17 18:25:56 +00:00
2023-09-22 19:02:51 +00:00
type BulmaVariant =
| "primary"
| "link"
| "info"
| "success"
| "warning"
| "danger";
2023-09-20 16:16:45 +00:00
2023-01-17 18:25:56 +00:00
@Options({
props: {
variant: String,
visible: {
type: Boolean,
default: false,
2023-01-17 18:25:56 +00:00
},
rectangle: Rectangle,
},
})
2023-01-24 23:19:25 +00:00
export default class extends Vue {
public readonly store = advent22Store();
private variant!: BulmaVariant;
private visible!: boolean;
2023-09-06 16:25:35 +00:00
public rectangle!: Rectangle;
2023-09-22 19:02:51 +00:00
public get extra_classes(): string {
let result = this.variant;
if (this.visible) result += " visible";
return result;
}
2023-01-17 18:25:56 +00:00
}
</script>
<style lang="scss" scoped>
2023-11-06 00:03:23 +00:00
@import "@/bulma-scheme";
foreignObject > div {
2023-11-06 00:32:56 +00:00
&:not(.visible, :hover):deep() > * {
display: none;
}
&.visible,
&:hover {
border-width: 3px;
border-style: solid;
2023-01-17 18:25:56 +00:00
2023-11-06 00:32:56 +00:00
@each $name, $color in $advent22-colors {
&.#{$name} {
background-color: rgba($color, 0.3);
border-color: rgba($color, 0.9);
}
}
2023-01-17 18:25:56 +00:00
}
}
2023-09-07 01:17:14 +00:00
</style>