Skip to content

Add users, orgs, and collections to app #3213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 36 additions & 20 deletions apps/app-frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
import { RouterView, useRoute, useRouter } from 'vue-router'
import {
UserIcon,
ArrowBigUpDashIcon,
CompassIcon,
DownloadIcon,
Expand Down Expand Up @@ -233,6 +234,9 @@ async function fetchCredentials() {
credentials.value = creds
}

const profileMenu = ref()
const isProfileMenuOpen = computed(() => profileMenu.value?.isOpen)

async function signIn() {
await login().catch(handleError)
await fetchCredentials()
Expand Down Expand Up @@ -410,26 +414,34 @@ function handleAuxClick(e) {
<NavButton v-tooltip.right="'Settings'" :to="() => $refs.settingsModal.show()">
<SettingsIcon />
</NavButton>
<ButtonStyled v-if="credentials" type="transparent" circular>
<OverflowMenu
:options="[
{
id: 'sign-out',
action: () => logOut(),
color: 'danger',
},
]"
direction="left"
>
<Avatar
:src="credentials.user.avatar_url"
:alt="credentials.user.username"
size="32px"
circle
/>
<template #sign-out> <LogOutIcon /> Sign out </template>
</OverflowMenu>
</ButtonStyled>
<OverflowMenu
v-if="credentials"
ref="profileMenu"
placement="right-end"
class="w-12 h-12 border-none cursor-pointer rounded-full flex items-center justify-center text-2xl transition-all button-animation"
:class="isProfileMenuOpen ? 'bg-button-bg' : 'bg-transparent hover:bg-button-bg'"
:options="[
{
id: 'profile',
action: () => router.push(`/user/${credentials.user.id}`),
},
{
id: 'sign-out',
action: () => logOut(),
color: 'danger',
},
]"
direction="left"
>
<Avatar
:src="credentials.user.avatar_url"
:alt="credentials.user.username"
size="32px"
circle
/>
<template #profile> <UserIcon /> Profile </template>
<template #sign-out> <LogOutIcon /> Sign out </template>
</OverflowMenu>
<NavButton v-else v-tooltip.right="'Sign in'" :to="() => signIn()">
<LogInIcon />
<template #label>Sign in</template>
Expand Down Expand Up @@ -698,6 +710,9 @@ function handleAuxClick(e) {

.app-grid-navbar {
grid-area: nav;

// Fixes SVG scaling issues
filter: brightness(1.00001);
}

.app-grid-statusbar {
Expand Down Expand Up @@ -781,6 +796,7 @@ function handleAuxClick(e) {
height: 100%;
overflow: auto;
overflow-x: hidden;
scrollbar-gutter: stable;
}

.app-contents::before {
Expand Down
46 changes: 26 additions & 20 deletions apps/app-frontend/src/components/RowDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -181,24 +181,26 @@ const maxInstancesPerRow = ref(1)
const maxProjectsPerRow = ref(1)

const calculateCardsPerRow = () => {
// Calculate how many cards fit in one row
const containerWidth = rows.value[0].clientWidth
// Convert container width from pixels to rem
const containerWidthInRem =
containerWidth / parseFloat(getComputedStyle(document.documentElement).fontSize)

maxInstancesPerCompactRow.value = Math.floor((containerWidthInRem + 0.75) / 18.75)
maxInstancesPerRow.value = Math.floor((containerWidthInRem + 0.75) / 20.75)
maxProjectsPerRow.value = Math.floor((containerWidthInRem + 0.75) / 18.75)

if (maxInstancesPerRow.value < 5) {
maxInstancesPerRow.value *= 2
}
if (maxInstancesPerCompactRow.value < 5) {
maxInstancesPerCompactRow.value *= 2
}
if (maxProjectsPerRow.value < 3) {
maxProjectsPerRow.value *= 2
if (rows.value && rows.value[0]) {
// Calculate how many cards fit in one row
const containerWidth = rows.value[0].clientWidth
// Convert container width from pixels to rem
const containerWidthInRem =
containerWidth / parseFloat(getComputedStyle(document.documentElement).fontSize)

maxInstancesPerCompactRow.value = Math.floor((containerWidthInRem + 0.75) / 18.75)
maxInstancesPerRow.value = Math.floor((containerWidthInRem + 0.75) / 20.75)
maxProjectsPerRow.value = Math.floor((containerWidthInRem + 0.75) / 18.75)

if (maxInstancesPerRow.value < 5) {
maxInstancesPerRow.value *= 2
}
if (maxInstancesPerCompactRow.value < 5) {
maxInstancesPerCompactRow.value *= 2
}
if (maxProjectsPerRow.value < 3) {
maxProjectsPerRow.value *= 2
}
}
}

Expand All @@ -207,13 +209,17 @@ const resizeObserver = ref(null)
onMounted(() => {
calculateCardsPerRow()
resizeObserver.value = new ResizeObserver(calculateCardsPerRow)
resizeObserver.value.observe(rowContainer.value)
if (rowContainer.value) {
resizeObserver.value.observe(rowContainer.value)
}
window.addEventListener('resize', calculateCardsPerRow)
})

onUnmounted(() => {
window.removeEventListener('resize', calculateCardsPerRow)
resizeObserver.value.unobserve(rowContainer.value)
if (rowContainer.value) {
resizeObserver.value.unobserve(rowContainer.value)
}
})
</script>

Expand Down
44 changes: 22 additions & 22 deletions apps/app-frontend/src/components/ui/Instance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import { computed, onMounted, onUnmounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import {
DownloadIcon,
GameIcon,
PlayIcon,
SpinnerIcon,
StopCircleIcon,
GameIcon,
TimerIcon,
StopCircleIcon,
PlayIcon,
DownloadIcon,
} from '@modrinth/assets'
import { Avatar, ButtonStyled } from '@modrinth/ui'
import { ButtonStyled, Avatar, SmartClickable } from '@modrinth/ui'
import { convertFileSrc } from '@tauri-apps/api/core'
import { finish_install, kill, run } from '@/helpers/profile'
import { get_by_profile_path } from '@/helpers/process'
Expand Down Expand Up @@ -134,22 +134,26 @@ onUnmounted(() => unlisten())
</script>

<template>
<template v-if="compact">
<div
class="card-shadow grid grid-cols-[auto_1fr_auto] bg-bg-raised rounded-xl p-3 pl-4 gap-2 cursor-pointer hover:brightness-90 transition-all"
@click="seeInstance"
@mouseenter="checkProcess"
>
<SmartClickable class="card-shadow bg-bg-raised rounded-xl" @mouseenter="checkProcess">
<template #clickable>
<router-link
class="no-click-animation"
:to="`/instance/${encodeURIComponent(instance.path)}/`"
/>
</template>
<div v-if="compact" class="grid grid-cols-[auto_1fr_auto] p-3 pl-4 gap-2">
<Avatar
size="48px"
:src="instance.icon_path ? convertFileSrc(instance.icon_path) : null"
:tint-by="instance.path"
alt="Mod card"
/>
<div class="h-full flex items-center font-bold text-contrast leading-normal">
<div
class="h-full flex items-center font-bold text-contrast leading-normal smart-clickable:underline-on-hover"
>
<span class="line-clamp-2">{{ instance.name }}</span>
</div>
<div class="flex items-center">
<div class="flex items-center smart-clickable:allow-pointer-events">
<ButtonStyled v-if="playing" color="red" circular @mousehover="checkProcess">
<button v-tooltip="'Stop'" @click="(e) => stop(e, 'InstanceCard')">
<StopCircleIcon />
Expand All @@ -176,13 +180,7 @@ onUnmounted(() => unlisten())
<span class="text-sm"> Played {{ dayjs(instance.last_played).fromNow() }} </span>
</div>
</div>
</template>
<div v-else>
<div
class="button-base bg-bg-raised p-4 rounded-xl flex gap-3 group"
@click="seeInstance"
@mouseenter="checkProcess"
>
<div v-else class="p-4 rounded-xl flex gap-3 group" @mouseenter="checkProcess">
<div class="relative flex items-center justify-center">
<Avatar
size="48px"
Expand Down Expand Up @@ -231,7 +229,9 @@ onUnmounted(() => unlisten())
</div>
</div>
<div class="flex flex-col gap-1">
<p class="m-0 text-md font-bold text-contrast leading-tight line-clamp-1">
<p
class="m-0 text-md font-bold text-contrast leading-tight line-clamp-1 smart-clickable:underline-on-hover"
>
{{ instance.name }}
</p>
<div class="flex items-center col-span-3 gap-1 text-secondary font-semibold mt-auto">
Expand All @@ -242,5 +242,5 @@ onUnmounted(() => unlisten())
</div>
</div>
</div>
</div>
</SmartClickable>
</template>
19 changes: 6 additions & 13 deletions apps/app-frontend/src/components/ui/InstanceIndicator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,18 @@ import { convertFileSrc } from '@tauri-apps/api/core'
import { formatCategory } from '@modrinth/utils'
import { GameIcon, LeftArrowIcon } from '@modrinth/assets'
import { Avatar, ButtonStyled } from '@modrinth/ui'

type Instance = {
game_version: string
loader: string
path: string
install_stage: string
icon_path?: string
name: string
}
import type { GameInstance } from '@/helpers/types'

defineProps<{
instance: Instance
instance?: GameInstance
}>()
</script>

<template>
<div class="flex justify-between items-center border-0 border-b border-solid border-divider pb-4">
<div
v-if="instance"
class="flex justify-between items-center border-0 border-b border-solid border-divider pb-4"
>
<router-link
:to="`/instance/${encodeURIComponent(instance.path)}`"
tabindex="-1"
Expand Down Expand Up @@ -49,5 +44,3 @@ defineProps<{
</ButtonStyled>
</div>
</template>

<style scoped lang="scss"></style>
45 changes: 10 additions & 35 deletions apps/app-frontend/src/components/ui/ProjectCard.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
<script setup>
import { Avatar, TagItem } from '@modrinth/ui'
import { Avatar, SmartClickable, TagItem } from '@modrinth/ui'
import { DownloadIcon, HeartIcon, TagIcon } from '@modrinth/assets'
import { formatNumber, formatCategory } from '@modrinth/utils'
import { computed } from 'vue'
import dayjs from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime'
import { useRouter } from 'vue-router'

dayjs.extend(relativeTime)

const router = useRouter()

const props = defineProps({
project: {
type: Object,
Expand Down Expand Up @@ -40,29 +37,15 @@ const toColor = computed(() => {
const r = (color >>> 16) & 0xff
return 'rgba(' + [r, g, b, 1].join(',') + ')'
})

const toTransparent = computed(() => {
let color = props.project.color

color >>>= 0
const b = color & 0xff
const g = (color >>> 8) & 0xff
const r = (color >>> 16) & 0xff
return (
'linear-gradient(rgba(' +
[r, g, b, 0.03].join(',') +
'), 65%, rgba(' +
[r, g, b, 0.3].join(',') +
'))'
)
})
</script>

<template>
<div
<SmartClickable
class="card-shadow bg-bg-raised rounded-xl overflow-clip cursor-pointer hover:brightness-90 transition-all"
@click="router.push(`/project/${project.slug}`)"
>
<template #clickable>
<router-link class="no-click-animation" :to="`/project/${project.slug}`" />
</template>
<div
class="w-full aspect-[2/1] bg-cover bg-center bg-no-repeat"
:style="{
Expand All @@ -73,21 +56,13 @@ const toTransparent = computed(() => {
'https://launcher-files.modrinth.com/assets/maze-bg.png'
})`,
}"
>
<div
class="badges-wrapper"
:class="{
'no-image': !project.featured_gallery && !project.gallery[0],
}"
:style="{
background: !project.featured_gallery && !project.gallery[0] ? toTransparent : null,
}"
></div>
</div>
></div>
<div class="flex flex-col justify-center gap-2 px-4 py-3">
<div class="flex gap-2 items-center">
<Avatar size="48px" :src="project.icon_url" />
<div class="h-full flex items-center font-bold text-contrast leading-normal">
<div
class="h-full flex items-center font-bold text-contrast leading-normal smart-clickable:underline-on-hover"
>
<span class="line-clamp-2">{{ project.title }}</span>
</div>
</div>
Expand Down Expand Up @@ -115,7 +90,7 @@ const toTransparent = computed(() => {
</div>
</div>
</div>
</div>
</SmartClickable>
</template>

<style scoped lang="scss"></style>
Loading
Loading