public/components/HomeStatBox.vue

93 lines
1.8 KiB
Vue
Raw Normal View History

<script setup lang="ts">
2022-08-09 15:37:32 -04:00
import type { Color, ViewportLength } from "csstype";
// fix ReferenceError: _unref is not defined
// https://github.com/nuxt/framework/issues/5546
import { unref as _unref } from "vue";
2022-08-09 11:43:20 -04:00
const {
href,
color = "pink",
2022-08-09 16:25:23 -04:00
darkcolor = "#c88994",
2022-08-09 11:43:20 -04:00
title,
clearstyles = false,
2022-08-09 15:37:32 -04:00
forceheight,
2022-08-09 11:43:20 -04:00
} = defineProps<{
href?: string;
color?: Color;
2022-08-09 16:25:23 -04:00
darkcolor?: Color;
title?: string;
2022-08-09 11:43:20 -04:00
clearstyles?: boolean;
2022-08-09 15:37:32 -04:00
forceheight?: ViewportLength<"rem">;
}>();
2022-08-09 11:43:20 -04:00
const padding = clearstyles ? "0" : "1rem";
2022-08-10 10:56:49 -04:00
const height = forceheight ?? "100%";
// v-bind DOES NOT WORK on initial render
// so unfortunately we have to use the old way
const cssVars = {
"--padding": padding,
"--height": height,
"--color": color,
"--darkcolor": darkcolor,
};
</script>
2022-07-22 16:08:55 -04:00
2022-07-22 15:32:00 -04:00
<template>
2022-08-10 10:56:49 -04:00
<a class="no-underline inline-block flex flex-col items-stretch" :href="href">
<div class="container box" :style="cssVars">
<p class="m-0 w-full title">{{ title }}</p>
2022-08-08 18:41:29 -04:00
<div class="main-content">
<slot />
</div>
</div>
</a>
2022-07-22 15:32:00 -04:00
</template>
2022-07-22 16:08:55 -04:00
<style scoped>
.container {
/* make sure width is good for fullscreen 1080p,
* fullscreen 1080p at 1.25 scaling,
* mobile
*/
width: 28rem;
2022-08-10 10:56:49 -04:00
height: var(--height);
border: 0.5rem solid var(--color);
border-radius: 0.5rem;
2022-08-09 19:31:13 -04:00
transition: transform 0.2s ease;
box-shadow: 0 0.1rem 0.5rem 0 gray;
}
.container:hover,
.container:active {
transform: scale(1.05);
}
2022-08-09 16:25:23 -04:00
html.dark .container {
border: 0.5rem solid v-bind(darkcolor);
2022-08-09 19:31:13 -04:00
box-shadow: 0 0.1rem 0.5rem 0 black;
2022-08-09 16:25:23 -04:00
}
.main-content {
2022-08-10 10:56:49 -04:00
padding: var(--padding);
padding-top: 0;
2022-08-09 15:54:17 -04:00
overflow-wrap: break-word;
}
.title {
2022-08-10 10:56:49 -04:00
background: var(--color);
}
2022-08-09 16:25:23 -04:00
html.dark .title {
2022-08-10 10:56:49 -04:00
background: var(--dark-color);
2022-08-09 16:25:23 -04:00
}
@media screen and (max-width: 600px) {
.container {
2022-08-09 16:00:55 -04:00
width: 90vw;
}
2022-07-22 16:08:55 -04:00
}
</style>