Skip to content

Commit 1e2ca84

Browse files
committed
Mobile friendlier
Signed-off-by: Vincent Fiduccia <[email protected]>
1 parent e9ba11e commit 1e2ca84

File tree

7 files changed

+264
-40
lines changed

7 files changed

+264
-40
lines changed

ui/app.vue

+87-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,53 @@
1+
<script lang="ts" setup>
2+
const sock = useSocket()
3+
const router = useRouter()
4+
5+
useHead({
6+
meta: [
7+
{ charset: 'utf-8' },
8+
{ name: 'apple-mobile-web-app-capable', content: 'yes' },
9+
{ name: 'format-detection', content: 'telephone=no' },
10+
{ name: 'viewport', content: `width=device-width, height=device-height` },
11+
],
12+
})
13+
14+
const root = ref<HTMLDivElement>()
15+
16+
watch(router.currentRoute, () => {
17+
root.value?.classList.remove('open')
18+
})
19+
20+
21+
function toggle() {
22+
root.value?.classList.toggle('open')
23+
}
24+
</script>
25+
126
<template>
2-
<div class="root bg-slate-100 dark:bg-slate-950">
3-
<LeftNav class="left-nav bg-slate-50 dark:bg-slate-900"/>
27+
<div ref="root" class="root bg-slate-50 dark:bg-slate-950">
28+
<header class="flex bg-slate-300 dark:bg-slate-900">
29+
<div class="toggle flex-initial p-2">
30+
<UButton icon="i-heroicons-bars-3" @click="toggle"/>
31+
</div>
32+
<div class="flex-initial">
33+
<img src="~/assets/logo.svg" class="dark:invert" style="height: 100%; padding: 0.25rem;"/>
34+
</div>
35+
36+
<div class="flex-1"/>
37+
38+
<div class="flex-initial text-right p-2" v-if="sock.sock.status !== 'OPEN'">
39+
<UBadge color="red" size="lg" variant="solid">
40+
<i class="i-heroicons-bolt-slash"/>&nbsp;{{ucFirst(sock.sock.status.toLowerCase())}}
41+
</UBadge>
42+
</div>
43+
44+
<div class="text-right p-2 flex-initial">
45+
<ThemeToggle />
46+
</div>
47+
</header>
48+
49+
<LeftNav class="left-nav bg-slate-100 dark:bg-slate-900"/>
50+
451
<main>
552
<NuxtPage />
653
</main>
@@ -9,17 +56,24 @@
956

1057
<style lang="scss" scoped>
1158
.root {
12-
--nav-width: 300px;
59+
--nav-width: 500px;
60+
--header-height: 50px;
1361
1462
display: grid;
15-
grid-template-areas: "nav main";
16-
grid-template-columns: var(--nav-width) 1fr;
17-
1863
position: absolute;
1964
top: 0;
2065
left: 0;
2166
right: 0;
2267
bottom: 0;
68+
overflow: hidden;
69+
70+
grid-template-areas: "header header" "nav main";
71+
grid-template-rows: var(--header-height) 1fr;
72+
grid-template-columns: 300px 1fr;
73+
74+
HEADER {
75+
grid-area: header;
76+
}
2377
2478
.left-nav {
2579
grid-area: nav;
@@ -33,4 +87,31 @@
3387
padding: 1rem;
3488
}
3589
}
90+
91+
// Desktop
92+
@media all and (min-width: 768px) {
93+
.root {
94+
.toggle {
95+
display: none;
96+
}
97+
}
98+
}
99+
100+
// Mobile
101+
@media all and (max-width: 767px) {
102+
.root {
103+
grid-template-columns: 0 100%;
104+
transition: grid-template-columns 250ms;
105+
106+
.left-nav { opacity: 0; }
107+
MAIN { opacity: 1}
108+
}
109+
.root.open {
110+
grid-template-columns: 100% 0;
111+
112+
.left-nav { opacity: 1; }
113+
MAIN { opacity: 0; }
114+
}
115+
}
116+
36117
</style>

ui/assets/logo.svg

+148
Loading

ui/components/call.vue

+16-4
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ const outputTruncated = computed(() => {
103103
<i v-if="prefs.debug" class="text-blue-400">{{call}}</i>
104104
<div class="flex" :class="[isExpanded && 'mb-2']">
105105
<div class="flex-1">
106-
<div>
106+
<div class="break-all max-lg:text-sm">
107107
<UButton v-if="children.length || call.messages?.length || inputTruncated || outputTruncated" size="xs" :icon="icon" @click="toggle" class="align-baseline mr-1"/>
108108
{{displayName}}<template v-if="!isExpanded">({{inputShort}}) <i class="i-heroicons-arrow-right align-text-bottom"/> {{outputShort}}</template>
109109
</div>
110110
</div>
111-
<div class="flex-inline text-right">
111+
<div class="flex-inline text-right ml-1">
112112
<UTooltip v-if="isExpanded" :text="call.showSystemMessages ? 'Internal messages shown' : 'Internal messages hidden'">
113113
<UToggle v-model="call.showSystemMessages" class="mr-2" off-icon="i-heroicons-bars-2" on-icon="i-heroicons-bars-4" />
114114
</UTooltip>
@@ -117,7 +117,7 @@ const outputTruncated = computed(() => {
117117
<i class="i-heroicons-key"/>&nbsp;{{ prefs.mapCall(call.id) }}
118118
</UBadge> -->
119119
<UBadge size="md" :color="colorForState(call.state)" class="align-baseline" variant="subtle">
120-
<i :class="iconForState(call.state)"/>&nbsp;{{ucFirst(call.state)}}
120+
<i :class="iconForState(call.state)"/><span class="hidden lg:inline">&nbsp;{{ucFirst(call.state)}}</span>
121121
</UBadge>
122122
</div>
123123
</div>
@@ -143,7 +143,7 @@ const outputTruncated = computed(() => {
143143
/>
144144
</template>
145145

146-
<div v-if="children.length" class="ml-9">
146+
<div v-if="children.length" class="indent">
147147
<Call
148148
v-for="(child, idx) in children"
149149
:key="idx"
@@ -156,3 +156,15 @@ const outputTruncated = computed(() => {
156156
</div>
157157
</UCard>
158158
</template>
159+
160+
<style lang="scss" scoped>
161+
.indent {
162+
margin-left: 10px;
163+
}
164+
165+
@media all and (min-width: 768px) {
166+
.indent {
167+
margin-left: 2.5rem;
168+
}
169+
}
170+
</style>

ui/components/left-nav.vue

+3-20
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// const router = useRouter()
33
const gptList = await useGpts().listAll()
44
const runList = await useRuns().findAll()
5-
const sock = useSocket()
65
76
const gptLinks = computed(() => {
87
return (gptList || []).map(x => { return {
@@ -32,7 +31,7 @@ async function remove(e: MouseEvent, id: any) {
3231
<template>
3332
<nav class="left">
3433
<div class="scripts text-slate-700 dark:text-slate-400">
35-
<h4 class="header px-3 py-2 bg-slate-200 dark:bg-slate-800">GPTScripts</h4>
34+
<h4 class="header px-3 py-2 bg-slate-200 dark:bg-slate-800">Scripts</h4>
3635
<UVerticalNavigation :links="gptLinks" />
3736
</div>
3837

@@ -50,27 +49,14 @@ async function remove(e: MouseEvent, id: any) {
5049
</template>
5150
</UVerticalNavigation>
5251
</div>
53-
54-
<aside class="px-2 flex">
55-
<div class="flex-1 mt-1">
56-
<ThemeToggle />
57-
</div>
58-
<div class="flex-initial text-right" v-if="sock.sock.status !== 'OPEN'">
59-
<UBadge color="red" class="mt-2">
60-
<i class="i-heroicons-bolt-slash"/>&nbsp;{{ucFirst(sock.sock.status.toLowerCase())}}
61-
</UBadge>
62-
</div>
63-
</aside>
6452
</nav>
6553
</template>
6654

6755
<style lang="scss" scoped>
68-
$aside-height: 45px;
69-
7056
.left {
7157
display: grid;
72-
grid-template-areas: "scripts" "runs" "aside";
73-
grid-template-rows: 1fr 1fr $aside-height;
58+
grid-template-areas: "scripts" "runs";
59+
grid-template-rows: 1fr 1fr;
7460
height: 100%;
7561
}
7662
@@ -84,9 +70,6 @@ async function remove(e: MouseEvent, id: any) {
8470
overflow-y: auto;
8571
}
8672
87-
ASIDE {
88-
}
89-
9073
.delete-btn {
9174
display: none;
9275
}

0 commit comments

Comments
 (0)