SVGRect "variant" prop fitting color scheme

This commit is contained in:
Jörn-Michael Miehe 2023-09-20 22:04:47 +00:00
parent bc4054ef73
commit 9063ebe93a
5 changed files with 66 additions and 38 deletions

20
ui/src/bulma-vars.scss Normal file
View file

@ -0,0 +1,20 @@
@charset "utf-8";
//=====================
// custom color scheme
//=====================
$primary: #945DE1;
$link: #64B4BD;
$info: #8C4E80;
$success: #7E8E2B;
$warning: #F6CA6B;
$danger: #C5443B;
// Sass variables (bulma)
@import "~bulma/sass/utilities/initial-variables.sass";
@import "~bulma/sass/utilities/derived-variables.sass";
// Sass variables (bulma-prefers-dark)
@import "~bulma-prefers-dark/sass/utilities/initial-variables.sass";
@import "~bulma-prefers-dark/sass/utilities/derived-variables.sass";

View file

@ -1,6 +1,6 @@
<template>
<rect
:class="color !== undefined ? `visible ${color}` : ''"
:class="variant !== undefined ? variant : ''"
:x="rectangle.left"
:y="rectangle.top"
:width="rectangle.width"
@ -12,12 +12,11 @@
import { Rectangle } from "@/lib/rectangle";
import { Options, Vue } from "vue-class-component";
// type RectClass = "red" | "yellow" | "green" | "blue" | "purple";
type RectColor = "yellow" | "green";
type RectColor = "primary" | "link" | "info" | "success" | "warning" | "danger";
@Options({
props: {
color: {
variant: {
type: String,
required: false,
},
@ -25,29 +24,48 @@ type RectColor = "yellow" | "green";
},
})
export default class extends Vue {
public color?: RectColor;
public variant?: RectColor;
public rectangle!: Rectangle;
}
</script>
<style lang="scss" scoped>
@import "@/bulma-vars";
rect {
fill: transparent;
fill-opacity: 0.3;
stroke-opacity: 0.9;
stroke-width: 1;
&.visible {
fill-opacity: 0.2;
stroke-opacity: 0.9;
stroke-width: 1;
&.primary {
fill: $primary;
stroke: $primary;
}
&.yellow {
fill: gold;
stroke: yellow;
}
&.link {
fill: $link;
stroke: $link;
}
&.green {
fill: lightgreen;
stroke: green;
}
&.info {
fill: $info;
stroke: $info;
}
&.success {
fill: $success;
stroke: $success;
}
&.warning {
fill: $warning;
stroke: $warning;
}
&.danger {
fill: $danger;
stroke: $danger;
}
}
</style>

View file

@ -1,5 +1,8 @@
<template>
<SVGRect :rectangle="door.position" :color="editing ? 'yellow' : 'green'" />
<SVGRect
:rectangle="door.position"
:variant="editing ? 'success' : 'primary'"
/>
<foreignObject
:x="Math.round(parent_aspect_ratio * door.position.left)"
:y="door.position.top"

View file

@ -10,11 +10,15 @@
>
<SVGRect
v-for="(rect, index) in rectangles"
color="green"
variant="primary"
:key="`rect-${index}`"
:rectangle="rect"
/>
<SVGRect v-if="preview_visible" color="yellow" :rectangle="preview_rect" />
<SVGRect
v-if="preview_visible"
variant="success"
:rectangle="preview_rect"
/>
</ThouCanvas>
</template>

View file

@ -1,23 +1,6 @@
@charset "utf-8";
//=====================
// custom color scheme
//=====================
$primary: #945DE1;
$link: #64B4BD;
$info: #8C4E80;
$success: #7E8E2B;
$warning: #F6CA6B;
$danger: #C5443B;
// Sass variables (bulma)
@import "~bulma/sass/utilities/initial-variables";
@import "~bulma/sass/utilities/derived-variables";
// Sass variables (bulma-prefers-dark)
@import "~bulma-prefers-dark/sass/utilities/initial-variables";
@import "~bulma-prefers-dark/sass/utilities/derived-variables";
@import "@/bulma-vars";
//=================
// variable tweaks