apply "prettier" styling

This commit is contained in:
Jörn-Michael Miehe 2023-09-07 01:17:14 +00:00
parent 4be3e38962
commit 40284c4061
17 changed files with 147 additions and 93 deletions

View file

@ -51,7 +51,7 @@ export default class extends Vue {
"days/visible_days",
(visible_days: number) => {
this.visible_days = visible_days;
}
},
);
}
}

View file

@ -1,8 +1,12 @@
<template>
<nav class="breadcrumb has-succeeds-separator">
<ul>
<li v-for="(step, index) in steps" :key="`step-${index}`" :class="modelValue === index ? 'is-active' : ''"
@click="change_step(index)">
<li
v-for="(step, index) in steps"
:key="`step-${index}`"
:class="modelValue === index ? 'is-active' : ''"
@click="change_step(index)"
>
<a>
<span class="icon is-small">
<font-awesome-icon :icon="step.icon" />

View file

@ -5,8 +5,14 @@
<figure class="image">
<img :src="$advent22.api_url('general/background')" />
<ThouCanvas>
<CalendarDoor v-for="(_, index) in doors" :key="`door-${index}`" :door="doors[index]" @doorClick="door_click"
@doorSuccess="door_success" @doorFailure="door_failure" />
<CalendarDoor
v-for="(_, index) in doors"
:key="`door-${index}`"
:door="doors[index]"
@doorClick="door_click"
@doorSuccess="door_success"
@doorFailure="door_failure"
/>
</ThouCanvas>
</figure>
</section>
@ -53,7 +59,7 @@ export default class extends Vue {
</script>
<style lang="scss" scoped>
section>figure {
section > figure {
user-select: none;
}
</style>

View file

@ -16,11 +16,7 @@ import SVGRect from "./rects/SVGRect.vue";
props: {
door: Door,
},
emits: [
"doorClick",
"doorSuccess",
"doorFailure",
],
emits: ["doorClick", "doorSuccess", "doorFailure"],
})
export default class extends Vue {
public door!: Door;
@ -35,9 +31,9 @@ export default class extends Vue {
let msg = "Unbekannter Fehler, bitte wiederholen!";
if (
(reason instanceof AxiosError)
&& (reason.response !== undefined)
&& (reason.response.status === 401)
reason instanceof AxiosError &&
reason.response !== undefined &&
reason.response.status === 401
) {
msg = "Netter Versuch :)";
}

View file

@ -13,7 +13,11 @@
<figure class="image">
<img :src="$advent22.api_url('general/background')" />
<ThouCanvas>
<PreviewDoor v-for="(_, index) in doors" :key="`door-${index}`" v-model:door="doors[index]" />
<PreviewDoor
v-for="(_, index) in doors"
:key="`door-${index}`"
v-model:door="doors[index]"
/>
</ThouCanvas>
</figure>
</section>
@ -46,7 +50,7 @@ export default class extends Vue {
</script>
<style lang="scss" scoped>
section>figure {
section > figure {
user-select: none;
}
</style>

View file

@ -10,7 +10,12 @@
</div>
<figure class="image">
<img :src="$advent22.api_url('general/background')" />
<RectangleCanvas :rectangles="rectangles" @draw="on_draw" @drag="on_drag" @remove="on_remove" />
<RectangleCanvas
:rectangles="rectangles"
@draw="on_draw"
@drag="on_drag"
@remove="on_remove"
/>
</figure>
</section>
</template>
@ -72,7 +77,7 @@ export default class extends Vue {
</script>
<style lang="scss" scoped>
section>figure {
section > figure {
user-select: none;
}
</style>

View file

@ -1,12 +1,27 @@
<template>
<SVGRect :rectangle="door.position" :focused="editing" />
<foreignObject :x="Math.round(parent_aspect_ratio * door.position.left)" :y="door.position.top"
:width="Math.round(parent_aspect_ratio * door.position.width)" :height="door.position.height"
:style="`transform: scaleX(${1 / parent_aspect_ratio})`">
<div xmlns="http://www.w3.org/1999/xhtml" class="is-flex is-align-items-center is-justify-content-center"
@click.left="on_click">
<input v-if="editing" v-model="day_str" ref="day_input" class="input is-large" type="number" min="-1"
placeholder="Tag" @keydown="on_keydown" />
<foreignObject
:x="Math.round(parent_aspect_ratio * door.position.left)"
:y="door.position.top"
:width="Math.round(parent_aspect_ratio * door.position.width)"
:height="door.position.height"
:style="`transform: scaleX(${1 / parent_aspect_ratio})`"
>
<div
xmlns="http://www.w3.org/1999/xhtml"
class="is-flex is-align-items-center is-justify-content-center"
@click.left="on_click"
>
<input
v-if="editing"
v-model="day_str"
ref="day_input"
class="input is-large"
type="number"
min="-1"
placeholder="Tag"
@keydown="on_keydown"
/>
<div v-else class="is-size-1 has-text-weight-bold">
<template v-if="door.day >= 0">{{ door.day }}</template>
</div>
@ -122,7 +137,7 @@ export default class extends Vue {
foreignObject {
cursor: pointer;
>div {
> div {
color: red;
height: inherit;
}

View file

@ -1,7 +1,18 @@
<template>
<ThouCanvas @mousedown.left="draw_start" @mouseup.left="draw_finish" @mousedown.right="drag_start"
@mouseup.right="drag_finish" @mousemove="on_mousemove" @click.middle="remove_rect" @dblclick.left="remove_rect">
<SVGRect v-for="(rect, index) in rectangles" :key="`rect-${index}`" :rectangle="rect" />
<ThouCanvas
@mousedown.left="draw_start"
@mouseup.left="draw_finish"
@mousedown.right="drag_start"
@mouseup.right="drag_finish"
@mousemove="on_mousemove"
@click.middle="remove_rect"
@dblclick.left="remove_rect"
>
<SVGRect
v-for="(rect, index) in rectangles"
:key="`rect-${index}`"
:rectangle="rect"
/>
<SVGRect v-if="preview_visible" :focused="true" :rectangle="preview_rect" />
</ThouCanvas>
</template>

View file

@ -10,7 +10,7 @@ export class Door {
}
public get day(): number {
return this._day
return this._day;
}
public set day(day: unknown) {

View file

@ -1,6 +1,11 @@
<template>
<rect :class="focused ? 'focus' : ''" :x="rectangle.left" :y="rectangle.top" :width="rectangle.width"
:height="rectangle.height" />
<rect
:class="focused ? 'focus' : ''"
:x="rectangle.left"
:y="rectangle.top"
:width="rectangle.width"
:height="rectangle.height"
/>
</template>
<script lang="ts">

View file

@ -1,7 +1,16 @@
<template>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 1000 1000" preserveAspectRatio="none"
@contextmenu.prevent @mousedown="transform_mouse_event" @mousemove="transform_mouse_event"
@mouseup="transform_mouse_event" @click="transform_mouse_event" @dblclick="transform_mouse_event">
<svg
xmlns="http://www.w3.org/2000/svg"
version="1.1"
viewBox="0 0 1000 1000"
preserveAspectRatio="none"
@contextmenu.prevent
@mousedown="transform_mouse_event"
@mousemove="transform_mouse_event"
@mouseup="transform_mouse_event"
@click="transform_mouse_event"
@dblclick="transform_mouse_event"
>
<slot name="default" />
</svg>
</template>
@ -19,7 +28,7 @@ function get_event_thous(event: MouseEvent): Vector2D {
return new Vector2D(
Math.round((event.offsetX / target.clientWidth) * 1000),
Math.round((event.offsetY / target.clientHeight) * 1000)
Math.round((event.offsetY / target.clientHeight) * 1000),
);
}

View file

@ -20,8 +20,7 @@ export class Vector2D {
}
public equals(other: Vector2D): boolean {
return this.x === other.x &&
this.y === other.y;
return this.x === other.x && this.y === other.y;
}
}
@ -38,7 +37,7 @@ export class Rectangle {
return new Vector2D(
Math.min(this.corner_1.x, this.corner_2.x),
Math.min(this.corner_1.y, this.corner_2.y),
)
);
}
public get left(): number {
@ -53,7 +52,7 @@ export class Rectangle {
return new Vector2D(
Math.max(this.corner_1.x, this.corner_2.x),
Math.max(this.corner_1.y, this.corner_2.y),
)
);
}
public get size(): Vector2D {
@ -69,7 +68,7 @@ export class Rectangle {
}
public get middle(): Vector2D {
return this.origin.plus(this.size.scale(0.5))
return this.origin.plus(this.size.scale(0.5));
}
public get area(): number {
@ -77,22 +76,20 @@ export class Rectangle {
}
public equals(other: Rectangle): boolean {
return this.origin.equals(other.origin) &&
this.corner.equals(other.corner);
return this.origin.equals(other.origin) && this.corner.equals(other.corner);
}
public contains(point: Vector2D): boolean {
return point.x >= this.origin.x &&
return (
point.x >= this.origin.x &&
point.y >= this.origin.y &&
point.x <= this.corner.x &&
point.y <= this.corner.y;
point.y <= this.corner.y
);
}
public update(corner_1?: Vector2D, corner_2?: Vector2D): Rectangle {
return new Rectangle(
corner_1 || this.corner_1,
corner_2 || this.corner_2,
);
return new Rectangle(corner_1 || this.corner_1, corner_2 || this.corner_2);
}
public move(vector: Vector2D): Rectangle {

View file

@ -7,4 +7,4 @@ declare module "@vue/runtime-core" {
}
}
export { };
export {};

View file

@ -1,6 +1,6 @@
/* eslint-disable */
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
declare module "*.vue" {
import type { DefineComponent } from "vue";
const component: DefineComponent<{}, {}, any>;
export default component;
}

View file

@ -1,12 +1,12 @@
import { Advent22Plugin } from "@/plugins/advent22"
import { FontAwesomePlugin } from "@/plugins/fontawesome"
import { createApp } from 'vue'
import App from './App.vue'
import { Advent22Plugin } from "@/plugins/advent22";
import { FontAwesomePlugin } from "@/plugins/fontawesome";
import { createApp } from "vue";
import App from "./App.vue";
import "@/main.scss"
import "@/main.scss";
const app = createApp(App)
app.use(Advent22Plugin)
app.use(FontAwesomePlugin)
const app = createApp(App);
app.use(Advent22Plugin);
app.use(FontAwesomePlugin);
app.mount('#app')
app.mount("#app");

View file

@ -1,5 +1,5 @@
import axios, { AxiosInstance, ResponseType } from 'axios';
import { App, Plugin } from 'vue';
import axios, { AxiosInstance, ResponseType } from "axios";
import { App, Plugin } from "vue";
export class Advent22 {
private axios: AxiosInstance;
@ -13,7 +13,6 @@ export class Advent22 {
// in production mode, return "//host/api"
if (process.env.NODE_ENV === "production") {
return `//${window.location.host}/api`;
} else if (process.env.NODE_ENV !== "development") {
// not in prouction or development mode
console.warn("Unexpected NODE_ENV value");
@ -24,11 +23,13 @@ export class Advent22 {
}
public api_url(endpoint?: string): string {
if (endpoint === undefined)
if (endpoint === undefined) {
return this.api_baseurl;
}
while (endpoint.startsWith('/'))
while (endpoint.startsWith("/")) {
endpoint = endpoint.substring(1);
}
return `${this.api_baseurl}/${endpoint}`;
}
@ -52,7 +53,8 @@ export class Advent22 {
responseType: responseType,
};
this.axios.get<T>(this.api_url(endpoint), req_data)
this.axios
.get<T>(this.api_url(endpoint), req_data)
.then((response) => on_success(response.data))
.catch((reason) => on_failure(endpoint, reason));
}
@ -68,12 +70,12 @@ export class Advent22 {
const reader = new FileReader();
reader.readAsDataURL(data);
reader.onloadend = () => {
if (typeof reader.result === "string")
if (typeof reader.result === "string") {
on_success(reader.result);
else
} else {
on_failure(endpoint, "failed data url");
}
}
};
},
on_failure,
"blob",
@ -112,5 +114,5 @@ export class Advent22 {
export const Advent22Plugin: Plugin = {
install(app: App) {
app.config.globalProperties.$advent22 = new Advent22();
}
}
},
};

View file

@ -1,20 +1,20 @@
import { App, Plugin } from 'vue';
import { App, Plugin } from "vue";
/* import the fontawesome core */
import { library } from '@fortawesome/fontawesome-svg-core';
import { library } from "@fortawesome/fontawesome-svg-core";
/* import specific icons */
import { fab } from '@fortawesome/free-brands-svg-icons';
import { fas } from '@fortawesome/free-solid-svg-icons';
import { fab } from "@fortawesome/free-brands-svg-icons";
import { fas } from "@fortawesome/free-solid-svg-icons";
/* add icons to the library */
library.add(fas, fab);
/* import font awesome icon component */
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
export const FontAwesomePlugin: Plugin = {
install(app: App) {
app.component('font-awesome-icon', FontAwesomeIcon);
}
}
app.component("font-awesome-icon", FontAwesomeIcon);
},
};