-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
378 additions
and
152 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,41 +1,100 @@ | ||
<template> | ||
<div class="w-full fixed flex justify-center pt-2 pb-3" | ||
<div | ||
class="navbar w-full fixed flex justify-center pt-2 pb-3 h-20 z-[100]" | ||
:class="{ | ||
'bg-primary-50' : theme == 'dark', | ||
'bg-primary-50 shadow-lg': theme == 'dark', | ||
}" | ||
> | ||
<nav class="flex justify-center gap-28"> | ||
<img v-if="theme=='light'" class="w-44" src="/logo.svg" alt="logo" /> | ||
<img v-else class="w-44" src="/logo-dark.svg" alt="logo" /> | ||
<nav class="flex justify-center xl:gap-26 lg:gap-8 gap-3 max-w-[1200px]"> | ||
<RouterLink class="flex flex-col justify-center" to="/"> | ||
<img | ||
:src="theme == 'light' ? '/BikeFestival17th-Frontend/logo.svg' : '/BikeFestival17th-Frontend/logo-dark.svg'" | ||
alt="logo" | ||
class="block xl:w-44 lg:w-36 md:w-28 w-24 cursor-pointer" | ||
@click="" | ||
/> | ||
</RouterLink> | ||
|
||
<div class="flex gap-7"> | ||
<div class="flex xl:gap-7 lg:gap-3 gap-2"> | ||
<template v-for="item in navBarList"> | ||
<DropDown :theme="theme" :title="item.title" :linkList="item.linkList" /> | ||
<DropDown | ||
:theme="theme" | ||
:title="item.title" | ||
:linkList="item.linkList" | ||
/> | ||
</template> | ||
</div> | ||
|
||
<a | ||
href="/signup" | ||
class="block h-14 w-36 text-bold text-xl text-center font-bold text-primary-50 bg-primary-900 rounded-full" | ||
> | ||
<div class="flex flex-col justify-center h-full"> | ||
<span>即刻報名</span> | ||
</div> | ||
</a> | ||
<div class="flex flex-col justify-center"> | ||
<RouterLink | ||
href="#" | ||
class="block text-center font-bold bg-primary-900 rounded-full lg:h-14 lg:w-36 lg:text-xl md:h-10 md:w-24 h-8 w-20" | ||
> | ||
<div class="flex flex-col justify-center h-full"> | ||
<span | ||
class="text-bold text-primary-50 text-sm lg:text-xl md:text-base" | ||
>即刻報名</span | ||
> | ||
</div> | ||
</RouterLink> | ||
</div> | ||
</nav> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import navBarList from "../data/navBar.json"; | ||
import DropDown from "./DropDown.vue"; | ||
import { defineProps } from "vue"; | ||
import { defineProps, onMounted, ref, computed, watch } from "vue"; | ||
import { useRoute , RouterLink } from "vue-router"; | ||
const theme = ref("dark"); | ||
const props = defineProps({ | ||
theme : { | ||
theme: { | ||
type: String, | ||
default: "dark", // dark | ||
}, | ||
}); | ||
const router = useRoute(); | ||
const path = computed(() => { | ||
return router.path; | ||
}); | ||
// watch if path changed | ||
watch(path, (newVal, oldVal) => { | ||
if (newVal === "/") { | ||
theme.value = "light"; | ||
} else { | ||
theme.value = "dark"; | ||
} | ||
}); | ||
onMounted(() => { | ||
if (path.value === "/") { | ||
theme.value = "light"; | ||
} | ||
window.addEventListener("scroll", (e) => { | ||
// only for home page | ||
if (path.value !== "/") return; | ||
if (window.innerWidth >= 1024) { | ||
// desktop | ||
if (window.scrollY > 500) { | ||
theme.value = "dark"; | ||
} else { | ||
theme.value = "light"; | ||
} | ||
} else { | ||
// mobile | ||
} | ||
}); | ||
}); | ||
</script> | ||
|
||
<style scoped> | ||
.navbar { | ||
transition: all 0.2s ease-in-out; | ||
} | ||
</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.