-
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.
styles for link
- Loading branch information
Showing
6 changed files
with
110 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,9 @@ | ||
<script setup lang="ts"> | ||
import { ref, onMounted, onBeforeUnmount } from 'vue'; | ||
import { useUsers } from '@/composables/user'; | ||
import IconSpinner from '@/components/IconSpinner.vue'; | ||
import UserCard from '@/components/UserCard.vue'; | ||
const { users, query, observerShow, getUsers } = useUsers(); | ||
// Reference to the IntersectionObserver instance. | ||
const observer = ref<IntersectionObserver>(); | ||
// Reference to the HTML element used for the observer. | ||
const observerElement = ref<HTMLInputElement | null>(null); | ||
/** | ||
* Lifecycle hook that is called after the component is mounted. | ||
* It initializes an IntersectionObserver to load more users when the observer element is in view. | ||
*/ | ||
onMounted(() => { | ||
observer.value = new IntersectionObserver( | ||
([entry]) => { | ||
if (entry && entry.isIntersecting) { | ||
getUsers(); | ||
query.value.page++; | ||
} | ||
}, | ||
{ threshold: 0.5 }, | ||
); | ||
// Observes the specified element for intersection changes. | ||
if (observerElement.value) observer.value.observe(observerElement.value); | ||
}); | ||
/** | ||
* Lifecycle hook that is called before the component is unmounted. | ||
* It disconnects the IntersectionObserver to clean up resources. | ||
* In this case it is not needed, but usually such observers are transferred to the plugin, | ||
* and there you will already need it | ||
*/ | ||
onBeforeUnmount(() => { | ||
observer.value?.disconnect(); | ||
}); | ||
import UserList from './components/UserList.vue'; | ||
</script> | ||
|
||
<template> | ||
<main class=""> | ||
<h1 class="mb-8 px-4 py-2">User List</h1> | ||
<!-- new syntax 3.4 short same bind :user --> | ||
<UserCard v-for="(user, index) in users" :key="index" :user class="mt-3 first:mt-0" /> | ||
<div v-if="observerShow" ref="observerElement" class="flex justify-center items-center"> | ||
<IconSpinner /> | ||
</div> | ||
<main> | ||
<UserList /> | ||
</main> | ||
</template> |
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 +1,25 @@ | ||
@import './tailwind.css' | ||
@import './tailwind.css'; | ||
|
||
|
||
.underline { | ||
display: inline-block; | ||
position: relative; | ||
text-decoration: none; | ||
color: black; | ||
} | ||
|
||
.underline::after { | ||
content: ''; | ||
position: absolute; | ||
bottom: 0; | ||
left: 50%; | ||
width: 0; | ||
height: 2px; | ||
background-color: black; | ||
transition: width 0.3s ease, left 0.3s ease; | ||
} | ||
|
||
.underline:hover::after { | ||
width: 100%; | ||
left: 0; | ||
} |
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,53 @@ | ||
<script setup lang="ts"> | ||
import { ref, onMounted, onBeforeUnmount } from 'vue'; | ||
import { useUsers } from '@/composables/user'; | ||
import IconSpinner from '@/components/IconSpinner.vue'; | ||
import UserCard from '@/components/UserCard.vue'; | ||
const { users, query, observerShow, getUsers } = useUsers(); | ||
// Reference to the IntersectionObserver instance. | ||
const observer = ref<IntersectionObserver>(); | ||
// Reference to the HTML element used for the observer. | ||
const observerElement = ref<HTMLInputElement | null>(null); | ||
/** | ||
* Lifecycle hook that is called after the component is mounted. | ||
* It initializes an IntersectionObserver to load more users when the observer element is in view. | ||
*/ | ||
onMounted(() => { | ||
observer.value = new IntersectionObserver( | ||
([entry]) => { | ||
if (entry && entry.isIntersecting) { | ||
getUsers(); | ||
query.value.page++; | ||
} | ||
}, | ||
{ threshold: 0.5 }, | ||
); | ||
// Observes the specified element for intersection changes. | ||
if (observerElement.value) observer.value.observe(observerElement.value); | ||
}); | ||
/** | ||
* Lifecycle hook that is called before the component is unmounted. | ||
* It disconnects the IntersectionObserver to clean up resources. | ||
* In this case it is not needed, but usually such observers are transferred to the plugin, | ||
* and there you will already need it | ||
*/ | ||
onBeforeUnmount(() => { | ||
observer.value?.disconnect(); | ||
}); | ||
</script> | ||
|
||
<template> | ||
<h1 class="mb-8 px-4 py-2">User List</h1> | ||
<!-- new syntax 3.4 short same bind :user --> | ||
<UserCard v-for="(user, index) in users" :key="index" :user class="mt-3 first:mt-0" /> | ||
<div v-if="observerShow" ref="observerElement" class="flex justify-center items-center"> | ||
<IconSpinner /> | ||
</div> | ||
</template> |
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