advent22/ui/src/components/rects/Rect.vue

67 lines
1.1 KiB
Vue
Raw Normal View History

2023-01-17 18:25:56 +00:00
<template>
<rect
2023-01-17 22:33:11 +00:00
:class="classes"
2023-01-17 18:25:56 +00:00
:x="rectangle.left"
:y="rectangle.top"
:width="rectangle.width"
:height="rectangle.height"
/>
</template>
<script lang="ts">
import { Vue, Options } from "vue-class-component";
import { Rectangle } from "./rectangles";
@Options({
props: {
2023-01-17 22:33:11 +00:00
selected: {
type: Boolean,
default: false,
},
highlighted: {
2023-01-17 18:25:56 +00:00
type: Boolean,
default: false,
},
rectangle: Rectangle,
},
})
export default class Rect extends Vue {
2023-01-17 22:33:11 +00:00
private selected!: boolean;
private highlighted!: boolean;
2023-01-17 18:25:56 +00:00
private rectangle!: Rectangle;
2023-01-17 22:33:11 +00:00
private get classes(): string {
let result: string[] = [];
if (this.selected) {
result.push("select");
}
if (this.highlighted) {
result.push("highlight");
}
return result.join(" ");
}
2023-01-17 18:25:56 +00:00
}
</script>
<style lang="scss" scoped>
rect {
fill: lightgreen;
stroke: green;
fill-opacity: 0.2;
stroke-opacity: 0.9;
stroke-width: 1;
2023-01-17 22:33:11 +00:00
&.select {
fill-opacity: 0.4;
stroke-opacity: 1;
}
&.highlight {
2023-01-17 18:25:56 +00:00
fill: gold;
stroke: yellow;
}
}
</style>