-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refact: ui: use mobile layout in desktop (#216)
- Loading branch information
Showing
9 changed files
with
135 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<script setup lang="ts"> | ||
import { type User } from '@/proto/api/v1/shared_pb.ts' | ||
import { nextTick, ref } from 'vue' | ||
import { searchUsers } from '@/http/requests.ts' | ||
import { usePageTitleStore } from '@/stores/pageTitle.ts' | ||
import { MagnifyingGlassIcon } from '@heroicons/vue/20/solid' | ||
import { XMarkIcon } from '@heroicons/vue/24/outline' | ||
const searchBarOpen = ref(false) | ||
const input = ref<HTMLInputElement | null>(null) | ||
const users = ref(Array<User>()) | ||
const pageTitleStore = usePageTitleStore() | ||
const openSearchBar = () => { | ||
searchBarOpen.value = true | ||
nextTick(() => { | ||
input.value?.focus() | ||
}) | ||
} | ||
const closeSearchBar = () => { | ||
users.value = [] | ||
searchBarOpen.value = false | ||
} | ||
const onSearchUsers = async () => { | ||
if (!input.value) return | ||
if ((input.value.value?.length ?? 0) < 3) { | ||
users.value = [] | ||
return | ||
} | ||
const res = await searchUsers(input.value.value, new Uint8Array(0)) | ||
if (!res) return | ||
users.value = res.users | ||
} | ||
</script> | ||
|
||
<template> | ||
<nav> | ||
<div class="container"> | ||
<template v-if="searchBarOpen"> | ||
<form class="w-full"> | ||
<input | ||
ref="input" | ||
type="text" | ||
class="w-full text-sm border-none focus:ring-0" | ||
placeholder="Search users" | ||
@keyup="onSearchUsers" | ||
/> | ||
</form> | ||
<ul | ||
v-if="users.length > 0" | ||
class="absolute bg-gray-100 border-b-white border-b-2 left-0 right-0 top-16 divide-y divide-white max-w-7xl mx-auto lg:rounded-b-md" | ||
> | ||
<li v-for="user in users" :key="user.id" @click="closeSearchBar"> | ||
<RouterLink :to="`/users/${user.id}`" class="block px-5 py-5 text-sm font-medium"> | ||
{{ user.firstName }} {{ user.lastName }} | ||
</RouterLink> | ||
</li> | ||
</ul> | ||
<XMarkIcon class="w-8 h-6 cursor-pointer" @click="closeSearchBar" /> | ||
</template> | ||
<template v-else> | ||
<RouterLink to="/"> | ||
<img class="h-auto w-8" src="/favicon.png" /> | ||
</RouterLink> | ||
<div class="flex flex-1 gap-x-4 justify-center"> | ||
<p class="uppercase text-sm font-semibold text-gray-900"> | ||
{{ pageTitleStore.pageTitle }} | ||
</p> | ||
</div> | ||
<MagnifyingGlassIcon class="w-8 h-6 cursor-pointer" @click="openSearchBar" /> | ||
</template> | ||
</div> | ||
</nav> | ||
<div | ||
v-if="searchBarOpen" | ||
class="fixed z-20 top-0 left-0 right-0 bottom-0 bg-black opacity-50" | ||
@click="closeSearchBar" | ||
/> | ||
</template> | ||
|
||
<style scoped> | ||
nav { | ||
@apply sticky top-0 z-30 border-b-2 border-gray-200 bg-white; | ||
.container { | ||
@apply flex items-center justify-between max-w-7xl mx-auto gap-x-4 px-4 h-16; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.