diff --git a/ui/src/components/Calendar.vue b/ui/src/components/Calendar.vue index d10b671..441fcd9 100644 --- a/ui/src/components/Calendar.vue +++ b/ui/src/components/Calendar.vue @@ -2,9 +2,21 @@ - - {{ figure_caption }} - + + + + {{ figure_caption }} + + + + + + @@ -12,6 +24,7 @@ v-for="(door, index) in doors" :key="`door-${index}`" :door="door" + :visible="show_doors" @doorClick="door_click" @doorSuccess="door_success" @doorFailure="door_failure" @@ -30,12 +43,14 @@ import { Door } from "@/lib/door"; import { Options, Vue } from "vue-class-component"; import MultiModal from "./MultiModal.vue"; +import BulmaButton from "./bulma/Button.vue"; import CalendarDoor from "./calendar/CalendarDoor.vue"; import ThouCanvas from "./calendar/ThouCanvas.vue"; @Options({ components: { MultiModal, + BulmaButton, ThouCanvas, CalendarDoor, }, @@ -47,6 +62,7 @@ export default class extends Vue { public readonly doors!: Door[]; private readonly idle_caption = "Finde die Türchen auf dem Adventskalender!"; + public show_doors = false; private multi_modal?: MultiModal; public figure_caption = this.idle_caption; diff --git a/ui/src/components/calendar/CalendarDoor.vue b/ui/src/components/calendar/CalendarDoor.vue index 1b895ce..532fb56 100644 --- a/ui/src/components/calendar/CalendarDoor.vue +++ b/ui/src/components/calendar/CalendarDoor.vue @@ -1,5 +1,12 @@ - + + {{ door.day }} + - - diff --git a/ui/src/components/calendar/SVGRect.vue b/ui/src/components/calendar/SVGRect.vue index 51206f5..17c59b2 100644 --- a/ui/src/components/calendar/SVGRect.vue +++ b/ui/src/components/calendar/SVGRect.vue @@ -1,5 +1,22 @@ + + + + + { + // don't loop endlessly + if (this.refreshKey < 10000) { + this.refreshKey++; + } + }, 100); + } + + public get parent_aspect_ratio(): number { + this.refreshKey; // read it just to force recompute on change + + if ( + !(this.$refs.rect instanceof SVGRectElement) || + this.$refs.rect.parentElement === null + ) { + this.refresh(); + return 1; + } + + const parent = this.$refs.rect.parentElement; + const result = parent.clientWidth / parent.clientHeight; + + // force recompute for suspicious results + if (result === 0 || result === Infinity) { + this.refresh(); + return 1; + } + + return result; + } }