Skip to content

Commit

Permalink
dropdown, refactor css, wip pages
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroCorp committed Jul 13, 2024
1 parent c5fd91b commit 66adf90
Show file tree
Hide file tree
Showing 22 changed files with 518 additions and 206 deletions.
6 changes: 6 additions & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ export default defineNuxtConfig({
},
},
},
components: [
{
path: '~/components',
pathPrefix: false,
},
],
modules: ["nuxt-icons", "@nuxtjs/i18n", "@nuxtjs/mdc", "@nuxt/image"],
i18n: {
vueI18n: './src/i18n/i18n.config.ts',
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,19 @@
"dependencies": {
"@nuxt/image": "^1.7.0",
"@nuxtjs/i18n": "^8.3.1",
"@nuxtjs/mdc": "^0.8.0",
"@nuxtjs/mdc": "^0.8.2",
"@vueuse/components": "^10.11.0",
"@vueuse/core": "^10.11.0",
"nuxt": "^3.12.1",
"nuxt": "^3.12.2",
"nuxt-icons": "^3.2.1",
"vue": "^3.4.27",
"vue-router": "^4.3.3",
"vue": "^3.4.31",
"vue-router": "^4.4.0",
"zod": "^3.23.8"
},
"devDependencies": {
"@tailwindcss/forms": "^0.5.7",
"autoprefixer": "^10.4.19",
"postcss": "^8.4.38",
"postcss": "^8.4.39",
"tailwindcss": "^3.4.4"
}
}
20 changes: 4 additions & 16 deletions src/assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,12 @@
@tailwind components;
@tailwind utilities;

html {
@apply antialiased scroll-smooth;
}

.nuxt-icon svg {
margin-bottom: 0;
width: auto !important;
height: auto !important;
}

.bg-books {
background-image: url('/bg.jpeg');
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}

.text-shadow {
text-shadow: 0px 2px 5px rgb(0, 0, 0, 0.75);
}

#__nuxt {
@apply antialiased min-h-screen bg-books;
}
1 change: 1 addition & 0 deletions src/assets/icons/down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 44 additions & 16 deletions src/components/Footer.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
const { locale, locales, setLocaleCookie } = useI18n();
const { t } = useI18n();
const currentLocale = computed({
get: () => locale.value,
Expand All @@ -11,21 +12,48 @@ const currentLocale = computed({
</script>

<template>
<footer class="text-white text-shadow text-center p-4">
<p>Copyright &copy; {{ new Date().getFullYear() }} Ace Books. {{ $t('footer.copyright') }}</p>
<!--
<form>
<select v-model="currentLocale" class="text-black">
<option
v-for="locale in locales"
:key="locale.code"
:selected="locale.code === currentLocale"
:value="locale.code"
>
{{ locale.name }}
</option>
</select>
</form>
-->
<footer class="text-white">
<div class="bg-green-900 px-2 py-8">
<div class="mx-auto md:w-3/4 flex flex-row">
<div>
<h3 class="text-lg font-semibold text-gray-100">{{ t('footer.legal') }}</h3>
<ul class="text-gray-300">
<li>{{ t('footer.cookies') }}</li>
<li>{{ t('footer.privacy') }}</li>
<li>{{ t('footer.terms') }}</li>
</ul>
</div>

<div class="ml-8">
<h3 class="text-lg font-semibold text-gray-100">{{ t('footer.support') }}</h3>
<ul class="text-gray-300">
<li>{{ t('footer.faqs') }}</li>
<li>{{ t('footer.contact') }}</li>
</ul>
</div>
</div>
</div>

<div class="bg-black px-2 py-4">
<div class="mx-auto md:w-3/4 flex flex-col-reverse md:flex-row items-center">
<div class="w-full md:w-4/5 mt-4 md:mt-0 text-center md:text-left">Copyright &copy; {{ new Date().getFullYear() }} Ace Books. {{ $t('footer.copyright') }}</div>

<div class="w-full md:w-1/5 flex flex-row justify-center md:justify-end">
<Dropdown v-model="currentLocale" :items="locales.map(localeObj => ({ text: localeObj.name || localeObj.code, value: localeObj.code }))">
<template #trigger="{ selected }">
<button class="border border-white p-2 rounded">
{{ locales.find(localeObj => localeObj.code === selected)?.name || 'Select an option' }}
</button>
</template>

<template #item="{ item, onClick }">
<button @click="() => onClick(item.value)" class="w-32 px-4 py-2 cursor-pointer hover:bg-black/10">
{{ item.text }}
</button>
</template>
</Dropdown>
</div>
</div>
</div>
</footer>
</template>
6 changes: 2 additions & 4 deletions src/components/FormValidationRule.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<script setup lang="ts">
interface Props {
defineProps<{
isValid: boolean;
}
defineProps<Props>();
}>();
</script>

<template>
Expand Down
35 changes: 7 additions & 28 deletions src/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const applyNavStyle = computed(() => {
}"
>
<header
class="sm:bg-opacity-0 sm:h-auto"
class="fixed w-full sm:bg-opacity-0 sm:h-auto z-20"
:class="{
'fixed bg-white bg-opacity-90 h-full w-full z-20': applyNavStyle,
'bg-white bg-opacity-90 h-full': applyNavStyle,
}"
>
<nav class="flex items-center p-4 flex-wrap">
Expand All @@ -35,7 +35,7 @@ const applyNavStyle = computed(() => {
class="p-2 mr-4 inline-flex items-center text-4xl cursor-pointer"
:class="{
'text-gray-700 hover:text-darkblue-500': applyNavStyle,
'text-white text-shadow': !applyNavStyle,
'text-white text-shadow shadow-black/75': !applyNavStyle,
}"
>
Ace Books
Expand Down Expand Up @@ -67,32 +67,11 @@ const applyNavStyle = computed(() => {
'text-center mt-8': applyNavStyle,
}"
>
<li
class="sm:inline-flex sm:w-auto w-full items-center justify-center sm:mx-6"
:class="{
'mt-5 mb-8 sm:my-0 text-gray-700 hover:text-darkblue-500': applyNavStyle,
}"
>
<NuxtLinkLocale
class="sm:text-white p-2 hover:underline"
:class="{
'text-gray-700 hover:text-darkblue-500': applyNavStyle,
}"
:to="route.path.includes('legal') ? '/' : '/legal/faqs'"
>
{{ $t(route.path.includes('legal') ? 'header.home' : 'header.faqs') }}
</NuxtLinkLocale>
</li>

<li class="sm:inline-flex sm:w-auto w-full items-center justify-center">
<NuxtLinkLocale
class="sm:text-white sm:border-white p-2 border-2 rounded-md bg-white bg-opacity-0 hover:bg-opacity-20 transition duration-300 ease-in-out"
:class="{
'text-gray-700 border-gray-700': applyNavStyle,
}"
to="/login"
>
{{ $t('header.sign_in') }}
<NuxtLinkLocale to="/login">
<MainButton class="p-2">
{{ $t('header.sign_in') }}
</MainButton>
</NuxtLinkLocale>
</li>
</ul>
Expand Down
6 changes: 2 additions & 4 deletions src/components/RenderMarkdown.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<script setup lang="ts">
interface Props {
defineProps<{
value: string;
}
defineProps<Props>();
}>();
</script>

<template>
Expand Down
79 changes: 79 additions & 0 deletions src/components/common/Dropdown.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<script setup lang="ts">
import { OnClickOutside } from '@vueuse/components';
import { useElementBounding, useWindowScroll } from '@vueuse/core';
const props = defineProps<{
items: { text: string, value: string; }[];
}>();
const model = defineModel();
const isOpen = ref(false);
const dropdown = ref<HTMLElement | null>(null);
const dropdownMenu = ref<HTMLElement | null>(null);
const { x: dropdownX, y: dropdownY } = useElementBounding(dropdown);
const { height: dropdownMenuHeight } = useElementBounding(dropdownMenu);
const { x: windowX, y: windowY } = useWindowScroll();
const top = computed(() => {
const MARGIN = 8;
if (!isOpen.value) return 0;
return windowY.value + dropdownY.value - dropdownMenuHeight.value - MARGIN;
});
const left = computed(() => {
if (!isOpen.value) return 0;
return dropdownX.value + windowX.value;
});
const toggleDropdown = () => {
isOpen.value = !isOpen.value;
};
const closeDropdown = (ev: any) => {
const isDropdownButton = ev.target.closest('.dropdown-button');
if (isDropdownButton) return;
isOpen.value = false;
};
const selectItem = (item: string) => {
console.log(item);
model.value = item;
isOpen.value = false;
};
</script>

<template>
<div class="relative" ref="dropdown" @click="toggleDropdown">
<div class="dropdown-button">
<slot name="trigger" :selected="model"></slot>
</div>
<Teleport to="#teleports">
<OnClickOutside @trigger="closeDropdown">
<div
ref="dropdownMenu"
class="absolute bg-white/50 rounded-md border border-white text-black backdrop-blur-sm shadow-lg z-50 flex flex-col"
:class="{
'pointer-events-none invisible': !isOpen,
}"
:style="{
left: left + 'px',
top: top + 'px',
}"
>
<slot
name="item"
v-for="(item, index) in items"
:key="index"
:item="item"
:onClick="selectItem"
></slot>
</div>
</OnClickOutside>
</Teleport>
</div>
</template>
13 changes: 13 additions & 0 deletions src/components/common/MainButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script setup lang="ts">
defineProps<{
class: string;
}>();
</script>

<template>
<button
:class="`text-white text-shadow shadow shadow-black/70 border-2 rounded-md hover:bg-white/20 transition duration-300 ease-in-out ${$props.class}`"
>
<slot />
</button>
</template>
7 changes: 7 additions & 0 deletions src/components/common/SecundaryButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script setup lang="ts">
</script>

<template>

</template>
2 changes: 1 addition & 1 deletion src/error.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ useHead({
<nav class="flex items-center p-4 flex-wrap">
<button
@click="handleError"
class="p-2 mr-4 inline-flex items-center text-white md:text-white text-4xl cursor-pointer text-shadow"
class="p-2 mr-4 inline-flex items-center text-white md:text-white text-4xl cursor-pointer text-shadow shadow-black/75"
>
Ace Books
</button>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/auth/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ useHead({
<div class="m-6 sm:mx-auto sm:w-full sm:max-w-md">
<NuxtLinkLocale
to="/"
class="flex justify-center mb-4 text-shadow text-center text-4xl cursor-pointer text-white"
class="flex justify-center mb-4 text-shadow shadow-black/75 text-center text-4xl cursor-pointer text-white"
>
Ace Books
</NuxtLinkLocale>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/auth/register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ useHead({
<div class="flex flex-col m-6 sm:mx-auto sm:w-full sm:max-w-md">
<NuxtLinkLocale
to="/"
class="flex justify-center my-4 text-shadow text-center text-4xl cursor-pointer text-white"
class="flex justify-center my-4 text-shadow shadow-black/75 text-center text-4xl cursor-pointer text-white"
>
Ace Books
</NuxtLinkLocale>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/auth/reset.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ useHead({
<div class="m-6 sm:mx-auto sm:w-full sm:max-w-md">
<NuxtLinkLocale
to="/"
class="flex justify-center mb-4 text-shadow text-center text-4xl cursor-pointer text-white"
class="flex justify-center mb-4 text-shadow shadow-black/75 text-center text-4xl cursor-pointer text-white"
>
Ace Books
</NuxtLinkLocale>
Expand Down
Loading

0 comments on commit 66adf90

Please sign in to comment.