Skip to content

Commit

Permalink
New sidebar, click to copy
Browse files Browse the repository at this point in the history
  • Loading branch information
shedaniel committed Aug 6, 2022
1 parent 2ebdd72 commit 2352f5a
Show file tree
Hide file tree
Showing 17 changed files with 351 additions and 103 deletions.
50 changes: 44 additions & 6 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
"preview": "vite preview"
},
"dependencies": {
"copy-to-clipboard": "^3.3.2",
"daisyui": "^2.15.0",
"nprogress": "^0.2.0",
"pinia": "^2.0.0-rc.10",
"pinia-plugin-persistedstate": "^1.6.1",
"tailwind-gradient-mask-image": "^1.0.0",
"vue": "^3.2.25",
"vue-axios": "^3.4.1"
},
Expand Down
24 changes: 24 additions & 0 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {mapActions, mapState} from "pinia"
import Footer from "./components/Footer.vue"
import Navbar from "./components/Navbar.vue"
import {useNotificationStore} from "./app/notification-store";
const routes: { [route: string]: any; } = {
"/": Home,
Expand All @@ -31,12 +32,14 @@ export default defineComponent({
return routes[this.current || "/"] || NotFound
},
...mapState(useAlertsStore, ["alerts"]),
...mapState(useNotificationStore, ["notifications"]),
},
methods: {
getAlertFor(type: string): Alert[] {
return this.alerts.filter((alert: Alert) => alert.type === type)
},
...mapActions(useAlertsStore, ["removeAlert"]),
...mapActions(useNotificationStore, ["removeNotification"]),
},
mounted() {
let theme = localStorage.getItem("theme")
Expand Down Expand Up @@ -90,6 +93,15 @@ export default defineComponent({
</div>
</div>

<div class="absolute right-10 z-10">
<TransitionGroup name="list" tag="div">
<div v-for="notification in Object.keys(notifications)" @click="removeNotification(notification)"
class="toast mt-4 bg-base-100 p-5 shadow-2xl rounded-xl">
{{ notifications[notification].message }}
</div>
</TransitionGroup>
</div>

<component :is="currentView"/>
</div>
<Footer/>
Expand All @@ -105,4 +117,16 @@ body {
outline: 0 !important;
border: 0 !important;
}
.list-move, /* apply transition to moving elements */
.list-enter-active,
.list-leave-active {
transition: all 0.5s ease;
}
.list-enter-from,
.list-leave-to {
opacity: 0;
transform: translateX(30px);
}
</style>
17 changes: 13 additions & 4 deletions frontend/src/app/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,23 @@ export function reqOss<T = any>(): Promise<AxiosResponse<T>> {
return HTTP.get(`/api/oss`)
}

export let namespaceGroups: { [key: string]: string | string[] } = {
"yarn": "Fabric",
"mojang": "Fabric",
"mojang_srg": "Forge",
"mojang_hashed": "Quilt",
"mcp": "Forge",
"quilt-mappings": "Quilt",
}

export let namespaceLocalizations: { [namespace: string]: string } = {
"yarn": "Yarn",
"mojang": "Official Mojang (Fabric Intermediary)",
"mojang_srg": "Official Mojang (Forge SRG)",
"mojang_hashed": "Official Mojang (Quilt Hashed)",
"mojang": "Mojang (Intermediary)",
"mojang_srg": "Mojang (SRG)",
"mojang_hashed": "Mojang (Hashed)",
"mcp": "MCP",
"quilt-mappings": "Quilt Mappings",
"legacy-yarn": "Legacy Yarn (Unofficial)",
"legacy-yarn": "Legacy Yarn",
"yarrn": "Yarrn",
"plasma": "Plasma",
}
7 changes: 7 additions & 0 deletions frontend/src/app/copy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import copy from "copy-to-clipboard";
import {useNotificationStore} from "./notification-store";

export function copyAs(str: string) {
copy(str);
useNotificationStore().addNotification({message: "Copied to clipboard"});
}
6 changes: 5 additions & 1 deletion frontend/src/app/dep-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ export function formatDepLine(configuration: string, notation: string, wrap?: st

export function formatDep(configuration: string, notation: string, block: boolean, wrap?: string): string {
if (!block) return formatDepLine(configuration, notation, wrap)
return formatBlock(formatDepLine(configuration, notation, wrap))
}

export function formatBlock(inner: string): string {
return `dependencies {
${formatDepLine(configuration, notation, wrap)}
${inner}
}`
}

Expand Down
28 changes: 28 additions & 0 deletions frontend/src/app/notification-store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {defineStore} from "pinia"

export interface Notification {
message: string,
}

export interface State {
notifications: Notification[],
}

function newState(): State {
return {
notifications: [],
}
}

export const useNotificationStore = defineStore({
id: "notification",
state: newState,
actions: {
addNotification(alert: Notification) {
this.notifications.push(alert)
},
removeNotification(index: number) {
this.notifications = this.notifications.filter((value, i) => i != index)
},
},
})
2 changes: 1 addition & 1 deletion frontend/src/components/dependencies/DependencyBlock.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<Block>
<Header>{{ title }}</Header>
<slot></slot>
<slot/>
</Block>
</template>

Expand Down
62 changes: 36 additions & 26 deletions frontend/src/components/dependencies/DependencyFilterBlock.vue
Original file line number Diff line number Diff line change
@@ -1,40 +1,50 @@
<template>
<div class="flex flex-col">
<SubHeader :add-padding="false" class="pb-2">Loader</SubHeader>
<select class="select select-sm font-light p-0"
@change="loader = (($event.target as any)?.value?.toLowerCase() ?? loader)" :value="loader ?? ''">
<option disabled selected>Select mod loader</option>
<option v-for="loader in loaders">
{{ loader }}
</option>
</select>
<SubHeader :add-padding="false" class="pb-1">Loader</SubHeader>

<div class="divider mt-0 mb-0"/>
<SubHeader :add-padding="false" class="pb-2">Build System</SubHeader>
<select class="select select-sm font-light p-0"
@change="forgeGradle = (($event.target as any)?.value === 'ForgeGradle')" :value="forgeGradle ? 'ForgeGradle' : 'Architectury Loom'">
<option disabled selected>Select build system</option>
<option>Architectury Loom</option>
<option>ForgeGradle</option>
</select>
<div v-for="l in loaders" :class="[
loader === l ? 'opacity-100 font-bold' : 'opacity-50 font-normal',
'cursor-pointer p-2 capitalize rounded transition-all hover:opacity-100 hover:bg-neutral hover:text-white']" @click="loader = l">
{{ l }}
</div>

<div v-if="loader === 'forge'">
<div class="divider mt-0 mb-0"/>
<SubHeader :add-padding="false" class="pb-1">Build System</SubHeader>

<div :class="[
!forgeGradle ? 'opacity-100 font-bold' : 'opacity-50 font-normal',
'cursor-pointer p-2 capitalize rounded transition-all hover:opacity-100 hover:bg-neutral hover:text-white']" @click="forgeGradle = false">
Architectury Loom
</div>

<div :class="[
forgeGradle ? 'opacity-100 font-bold' : 'opacity-50 font-normal',
'cursor-pointer p-2 capitalize rounded transition-all hover:opacity-100 hover:bg-neutral hover:text-white']" @click="forgeGradle = true">
ForgeGradle
</div>
</div>

<div class="divider mt-0 mb-0"/>
<SubHeader :add-padding="false" class="pb-2">Version</SubHeader>
<div class="flex flex-col flex-nowrap justify-center h-full whitespace-nowrap pb-2">
<SubHeader :add-padding="false" class="pb-1">Version</SubHeader>
<div class="flex flex-col flex-nowrap justify-center h-full whitespace-nowrap pb-2" v-if="loader === 'fabric'">
<div>
<span class="pr-2">Enable snapshots</span>
<input type="checkbox" class="checkbox checkbox-primary h-4" :checked="allowSnapshots" aria-label="Enable Snapshots"
@input="allowSnapshots = (($event.target as any)?.checked ?? allowSnapshots)"/>
</div>
</div>

<select class="select select-sm font-light"
@change="version = (($event.target as any)?.value ?? version)" :value="version ?? ''">
<option disabled selected>Select version</option>
<option v-for="v in applicableVersions">
{{ v }}
</option>
</select>

<div class="bg-base-300 rounded-lg">
<div class="px-1 py-2 h-52 overflow-x-clip gradient-mask-b-80 overflow-y-scroll">
<p v-for="v in applicableVersions"
:class="[version === v ? 'opacity-100 font-bold' : 'opacity-50 font-normal',
'transition-all hover:opacity-100 hover:bg-neutral hover:text-white px-2 py-1 rounded-md cursor-pointer']"
@click="version = v">
{{ v }}
</p>
</div>
</div>
</div>
</template>

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/dependencies/SubHeader.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="text-base-content font-extrabold text-xl" :class="addPadding ? 'py-2' : ''">
<div class="font-extrabold text-xl" :class="addPadding ? 'py-2' : ''">
<slot/>
</div>
</template>
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/components/mappings/EntryDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<div class="text-base whitespace-nowrap flex py-1">
<span class="pr-2">{{ title }}</span>
<div class="px-2 rounded bg-base-300 overflow-x-auto" v-if="code">
<pre><code class="break-all whitespace-pre text-xs">{{ content }}</code></pre>
<pre><code class="break-all whitespace-pre text-xs"><slot/></code></pre>
</div>
<span v-else>{{ content }}</span>
<span v-else><slot/></span>
</div>
</template>

Expand All @@ -16,7 +16,6 @@ export default defineComponent({
name: "EntryDetails",
props: {
title: String,
content: String,
code: {
type: Boolean,
default: () => true,
Expand Down
Loading

0 comments on commit 2352f5a

Please sign in to comment.