Reformat, refactor some code and fix some linting errors

This commit is contained in:
Ramon Wenger 2024-01-04 18:40:44 +01:00
parent 41b2357bf6
commit 6e85b3a9dc
2 changed files with 88 additions and 49 deletions

View File

@ -1,24 +1,66 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="de"> <html lang="de">
<head>
<head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" /> <meta
name="viewport"
content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0"
/>
<title>_APP_TITLE_</title> <title>_APP_TITLE_</title>
<link href="https://fonts.googleapis.com/css?family=Material+Icons" rel="stylesheet" type="text/css" /> <link
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,600,800" rel="stylesheet" /> href="https://fonts.googleapis.com/css?family=Material+Icons"
<link href="https://use.typekit.net/tck7ptw.css" rel="stylesheet" /> rel="stylesheet"
type="text/css"
/>
<link
href="https://fonts.googleapis.com/css?family=Montserrat:400,600,800"
rel="stylesheet"
/>
<link
href="https://use.typekit.net/tck7ptw.css"
rel="stylesheet"
/>
<link rel="apple-touch-icon" sizes="180x180" href="/static/apple-touch-icon.png" /> <link
<link rel="icon" type="image/png" sizes="32x32" href="_FAVICON_32_" /> rel="apple-touch-icon"
<link rel="icon" type="image/png" sizes="16x16" href="_FAVICON_16_" /> sizes="180x180"
<link rel="manifest" href="/static/site.webmanifest" /> href="/static/apple-touch-icon.png"
<link rel="mask-icon" href="/static/safari-pinned-tab.svg" color="#5bbad5" /> />
<meta name="msapplication-TileColor" content="#da532c" /> <link
<meta name="theme-color" content="#ffffff" /> rel="icon"
type="image/png"
sizes="32x32"
href="_FAVICON_32_"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="_FAVICON_16_"
/>
<link
rel="manifest"
href="/static/site.webmanifest"
/>
<link
rel="mask-icon"
href="/static/safari-pinned-tab.svg"
color="#5bbad5"
/>
<meta
name="msapplication-TileColor"
content="#da532c"
/>
<meta
name="theme-color"
content="#ffffff"
/>
<!-- for sentry replay web worker --> <!-- for sentry replay web worker -->
<meta http-equiv="Content-Security-Policy" content="worker-src 'self' blob:;" /> <meta
http-equiv="Content-Security-Policy"
content="worker-src 'self' blob:;"
/>
<script> <script>
window.UPLOADCARE_PUBLIC_KEY = '78212ff39934a59775ac'; window.UPLOADCARE_PUBLIC_KEY = '78212ff39934a59775ac';
@ -34,11 +76,13 @@
}, },
}; };
</script> </script>
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>
<script type="module" src="/src/main.ts"></script> <script
</body> type="module"
src="/src/main.ts"
></script>
</body>
</html> </html>

View File

@ -2,7 +2,7 @@
<div <div
:class="{ 'hideable-element--greyed-out': isHidden }" :class="{ 'hideable-element--greyed-out': isHidden }"
class="content-block__container hideable-element content-list__parent" class="content-block__container hideable-element content-list__parent"
ref="wrapper" ref="contentBlockDiv"
> >
<div <div
:class="specialClass" :class="specialClass"
@ -137,7 +137,7 @@ const ContentComponent = defineAsyncComponent(() => import('@/components/content
const { me, schoolClass } = getMe(); const { me, schoolClass } = getMe();
const wrapper = ref<HTMLElement | null>(null); const contentBlockDiv = ref<HTMLElement | null>(null);
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
@ -245,7 +245,7 @@ const { mutate: doDeleteContentBlock } = useMutation(DELETE_CONTENT_BLOCK_MUTATI
})); }));
onMounted(() => { onMounted(() => {
const element = wrapper.value; const element = contentBlockDiv.value;
if (element !== null) { if (element !== null) {
if (route.hash === `#${props.contentBlock.id}`) { if (route.hash === `#${props.contentBlock.id}`) {
@ -265,7 +265,7 @@ onMounted(() => {
}); });
onUnmounted(() => { onUnmounted(() => {
const element = wrapper.value; const element = contentBlockDiv.value;
if (element !== null) { if (element !== null) {
console.log('unmounting'); console.log('unmounting');
@ -309,14 +309,9 @@ const specialClass = computed(() => `content-block--${props.contentBlock.type.to
const isInstrumentBlock = computed(() => !!props.contentBlock.instrumentCategory); const isInstrumentBlock = computed(() => !!props.contentBlock.instrumentCategory);
// todo: use dynamic css class with v-bind once we're on Vue 3: https://vuejs.org/api/sfc-css-features.html#v-bind-in-css // todo: use dynamic css class with v-bind once we're on Vue 3: https://vuejs.org/api/sfc-css-features.html#v-bind-in-css
const instrumentStyle = computed(() => { const instrumentStyle = computed(() =>
if (isInstrumentBlock.value) { isInstrumentBlock.value ? { backgroundColor: props.contentBlock.instrumentCategory?.background || '' } : {}
return { );
backgroundColor: props.contentBlock.instrumentCategory.background,
};
}
return {};
});
const instrumentLabel = computed(() => { const instrumentLabel = computed(() => {
const contentType = props.contentBlock.type.toLowerCase(); const contentType = props.contentBlock.type.toLowerCase();
if (contentType.startsWith('base')) { if (contentType.startsWith('base')) {
@ -324,7 +319,7 @@ const instrumentLabel = computed(() => {
return instrumentCategory(contentType); return instrumentCategory(contentType);
} }
if (isInstrumentBlock.value) { if (isInstrumentBlock.value) {
return instrumentCategory(props.contentBlock.instrumentCategory.name); return instrumentCategory(props.contentBlock.instrumentCategory?.name);
} }
return ''; return '';
}); });
@ -332,7 +327,7 @@ const instrumentLabel = computed(() => {
const instrumentLabelStyle = computed(() => { const instrumentLabelStyle = computed(() => {
if (isInstrumentBlock.value) { if (isInstrumentBlock.value) {
return { return {
color: props.contentBlock.instrumentCategory.foreground, color: props.contentBlock.instrumentCategory?.foreground,
}; };
} }