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

View file

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

View file

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

View file

@ -1,23 +1,6 @@
@charset "utf-8"; @charset "utf-8";
//===================== @import "@/bulma-vars";
// 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";
//================= //=================
// variable tweaks // variable tweaks