You've already forked AstralRinth
forked from didirus/AstralRinth
* Top 10 packs & mods by follows plugged into home page. Modpacks installable. * Only displays row if packs are present. Confirmation modal added. Displays play or X ctas. * Fixes attr ordering. * Rewires library page. Adds loader. * Updates kill_by_pid to kill_by_uuid. * Starts loading animation when installing on homepage. * Changes RowDisplay key. Polish. * Removes loader. Fixes InstallConfirmModal. * Removes loader. Polishing. * Z-index changes. * Z-index changes. * Fixes content going off screen. * Styling changes. * Filters out projects already installed on the home page. * Wires up instance.vue, homepage, and appbar to process API. * Cleans up process handling. App bar partially hooked up. * Removes scoped in Settings to fix AnimatedLogo. Adds loader to Instance. * Moves ctas outside of card. * Adds mouse over to Stop btn. * Removes unnecessary code. Fixes uuid reset. * Wires up Instance.vue to process API. * Removes appbar mod count. Updates code to use new linked_data and updated events. * Switches load_listener to profile_listener. Unlistens on unmount. * Cleans up instance card styling. * Fixes margin with uncollapsed navbar. Ensures RowDisplay has data. * Updates profile_listener. Increases stack size. * Provides more margin when navbar is expanded. * fix proper * Re-adds calculated width and height. Fixes navbar. * Increases stack size further. Navbar is not absolute. View width made into var. * Ensures the specific isntance for a killed process is set to off. * fix menu when not logged in --------- Co-authored-by: Jai A <jaiagr+gpg@pm.me>
200 lines
4.6 KiB
Vue
200 lines
4.6 KiB
Vue
<script setup>
|
|
import { ChevronLeftIcon, ChevronRightIcon } from 'omorphia'
|
|
import Instance from '@/components/ui/Instance.vue'
|
|
import News from '@/components/ui/News.vue'
|
|
import { onMounted, onUnmounted, ref } from 'vue'
|
|
|
|
const props = defineProps({
|
|
instances: {
|
|
type: Array,
|
|
default() {
|
|
return []
|
|
},
|
|
},
|
|
news: {
|
|
type: Array,
|
|
default() {
|
|
return []
|
|
},
|
|
},
|
|
label: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
canPaginate: Boolean,
|
|
})
|
|
|
|
const allowPagination = ref(false)
|
|
const modsRow = ref(null)
|
|
const newsRow = ref(null)
|
|
|
|
const shouldRenderNormalInstances = props.instances && props.instances?.length !== 0
|
|
const shouldRenderNews = props.news && props.news?.length !== 0
|
|
|
|
const handlePaginationDisplay = () => {
|
|
let parentsRow
|
|
if (shouldRenderNormalInstances) parentsRow = modsRow.value
|
|
if (shouldRenderNews) parentsRow = newsRow.value
|
|
if (!parentsRow) return
|
|
|
|
// This is wrapped in a setTimeout because the HtmlCollection seems to struggle
|
|
// with getting populated sometimes. It's a flaky error, but providing a bit of
|
|
// wait-time for the below expressions has not failed thus-far.
|
|
setTimeout(() => {
|
|
const children = parentsRow.children
|
|
const lastChild = children[children.length - 1]
|
|
const childBox = lastChild?.getBoundingClientRect()
|
|
|
|
if (childBox?.x + childBox?.width > window.innerWidth && props.canPaginate)
|
|
allowPagination.value = true
|
|
else allowPagination.value = false
|
|
}, 300)
|
|
}
|
|
|
|
onMounted(() => {
|
|
if (props.canPaginate) window.addEventListener('resize', handlePaginationDisplay)
|
|
// Check if pagination should be rendered on mount
|
|
handlePaginationDisplay()
|
|
})
|
|
onUnmounted(() => {
|
|
if (props.canPaginate) window.removeEventListener('resize', handlePaginationDisplay)
|
|
})
|
|
|
|
const handleLeftPage = () => {
|
|
if (shouldRenderNormalInstances) modsRow.value.scrollLeft -= 170
|
|
else if (shouldRenderNews) newsRow.value.scrollLeft -= 170
|
|
}
|
|
const handleRightPage = () => {
|
|
if (shouldRenderNormalInstances) modsRow.value.scrollLeft += 170
|
|
else if (shouldRenderNews) newsRow.value.scrollLeft += 170
|
|
}
|
|
</script>
|
|
<template>
|
|
<div v-if="props.instances.length > 0" class="row">
|
|
<div class="header">
|
|
<p>{{ props.label }}</p>
|
|
<hr aria-hidden="true" />
|
|
<div v-if="allowPagination" class="pagination">
|
|
<ChevronLeftIcon role="button" @click="handleLeftPage" />
|
|
<ChevronRightIcon role="button" @click="handleRightPage" />
|
|
</div>
|
|
</div>
|
|
<section v-if="shouldRenderNormalInstances" ref="modsRow" class="instances">
|
|
<Instance
|
|
v-for="instance in props.instances"
|
|
:key="instance?.project_id || instance?.id"
|
|
display="card"
|
|
:instance="instance"
|
|
class="row-instance"
|
|
/>
|
|
</section>
|
|
<section v-else-if="shouldRenderNews" ref="newsRow" class="news">
|
|
<News v-for="actualNews in props.news" :key="actualNews.id" :news="actualNews" />
|
|
</section>
|
|
</div>
|
|
</template>
|
|
<style lang="scss" scoped>
|
|
.row {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
width: 100%;
|
|
padding: 1rem;
|
|
|
|
&:nth-child(even) {
|
|
background: var(--color-bg);
|
|
}
|
|
|
|
.header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: inherit;
|
|
width: 100%;
|
|
margin-bottom: 1rem;
|
|
gap: 1rem;
|
|
|
|
p {
|
|
font-size: 1rem;
|
|
white-space: nowrap;
|
|
color: var(--color-contrast);
|
|
}
|
|
|
|
hr {
|
|
background-color: var(--color-gray);
|
|
height: 1px;
|
|
width: 100%;
|
|
border: none;
|
|
}
|
|
|
|
.pagination {
|
|
display: inherit;
|
|
align-items: inherit;
|
|
|
|
svg {
|
|
background: var(--color-raised-bg);
|
|
border-radius: var(--radius-lg);
|
|
width: 1.3rem;
|
|
height: 1.2rem;
|
|
cursor: pointer;
|
|
margin-right: 0.5rem;
|
|
transition: all ease-in-out 0.1s;
|
|
|
|
&:hover {
|
|
filter: brightness(150%);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
section {
|
|
display: flex;
|
|
align-items: inherit;
|
|
transition: all ease-in-out 0.4s;
|
|
gap: 1rem;
|
|
}
|
|
|
|
.news {
|
|
margin: auto;
|
|
width: 100%;
|
|
scroll-behavior: smooth;
|
|
overflow-x: scroll;
|
|
overflow-y: hidden;
|
|
|
|
&::-webkit-scrollbar {
|
|
width: 0px;
|
|
background: transparent;
|
|
}
|
|
}
|
|
|
|
.instances {
|
|
display: flex;
|
|
flex-direction: row;
|
|
width: 100%;
|
|
gap: 1rem;
|
|
margin-right: auto;
|
|
margin-top: 0.8rem;
|
|
scroll-behavior: smooth;
|
|
overflow-x: scroll;
|
|
overflow-y: hidden;
|
|
|
|
&::-webkit-scrollbar {
|
|
width: 0px;
|
|
background: transparent;
|
|
}
|
|
}
|
|
}
|
|
|
|
.dark-mode {
|
|
.row {
|
|
&:nth-child(odd) {
|
|
background-color: rgb(30, 31, 34);
|
|
}
|
|
}
|
|
}
|
|
|
|
.row-instance {
|
|
min-width: 12rem;
|
|
max-width: 12rem;
|
|
}
|
|
</style>
|