Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update loading skeletons #4982

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions frontend/src/components/VSkeleton/VBone.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
<script setup lang="ts">
withDefaults(defineProps<{ shimmer?: boolean }>(), { shimmer: true })
</script>
<script setup lang="ts"></script>

<template>
<div :class="['bg-secondary', { shimmering: shimmer }]" />
<div class="bg-gradient shimmering motion-reduce:!animate-none" />
</template>

<style scoped>
.bg-gradient {
@apply bg-secondary;
background: linear-gradient(
to right,
var(--color-skeleton-base) 4%,
var(--color-skeleton-secondary) 25%,
var(--color-skeleton-base) 36%
);
background-size: 1000px 100%;
}

@keyframes shimmer {
0% {
background-position: -1000px 0;
Expand All @@ -18,12 +27,5 @@ withDefaults(defineProps<{ shimmer?: boolean }>(), { shimmer: true })

.shimmering {
animation: shimmer 3s infinite linear;
background: linear-gradient(
to right,
theme("backgroundColor.secondary") 4%,
theme("borderColor.default") 25%,
theme("backgroundColor.secondary") 36%
);
background-size: 1000px 100%;
}
</style>
8 changes: 5 additions & 3 deletions frontend/src/components/VSkeleton/VGridSkeleton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
* Display placeholder elements while waiting for the actual elements to be
* loaded in the results views.
*/
import { computed } from "vue"
import { computed, inject, ref } from "vue"

import type { SupportedSearchType } from "~/constants/media"

import { IsSidebarVisibleKey } from "~/types/provides"

import VAudioTrackSkeleton from "~/components/VSkeleton/VAudioTrackSkeleton.vue"
import VBone from "~/components/VSkeleton/VBone.vue"

const props = withDefaults(
defineProps<{
isForTab?: SupportedSearchType
numElems?: number
isSidebarVisible?: boolean
}>(),
{
isForTab: "image",
isSidebarVisible: false,
}
)

Expand All @@ -39,6 +39,8 @@ const elementCount = computed(() => {
}
return 8
})

const isSidebarVisible = inject(IsSidebarVisibleKey, ref(false))
</script>

<template>
Expand Down
37 changes: 6 additions & 31 deletions frontend/src/components/VSkeleton/meta/VGridSkeleton.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h } from "vue"
import { supportedSearchTypes } from "~/constants/media"

import VGridSkeleton from "~/components/VSkeleton/VGridSkeleton.vue"

Expand All @@ -7,42 +7,17 @@ import type { Meta, StoryObj } from "@storybook/vue3"
const meta = {
title: "Components/Skeleton",
component: VGridSkeleton,
argTypes: {
isForTab: { control: "select", options: supportedSearchTypes },
},
} satisfies Meta<typeof VGridSkeleton>

export default meta
type Story = StoryObj<typeof meta>

const Template: Story = {
render: (args) => ({
components: { VGridSkeleton },
setup() {
return () => h(VGridSkeleton, { isForTab: args.isForTab })
},
}),
}
export const AllTab: Story = {
...Template,
name: "All tab",

args: {
isForTab: "all",
},
}

export const ImageTab: Story = {
...Template,
name: "Image tab",

export const Default: Story = {
name: "Grid Skeleton",
args: {
isForTab: "image",
},
}

export const AudioTab = {
...Template,
name: "Audio tab",

args: {
isForTab: "audio",
},
}
6 changes: 6 additions & 0 deletions frontend/src/styles/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@
--color-modal-layer: var(--color-gray-12-60);
--color-new-highlight: var(--color-yellow-3);
--color-gray-new-highlight: var(--color-gray-1-20);
--color-skeleton-base: var(--color-gray-2);
--color-skeleton-secondary: var(--color-gray-3);
}
}

Expand Down Expand Up @@ -316,6 +318,8 @@
--color-modal-layer: var(--color-gray-12-80);
--color-new-highlight: var(--color-pink-6);
--color-gray-new-highlight: var(--color-gray-12-20);
--color-skeleton-base: var(--color-gray-2);
--color-skeleton-secondary: var(--color-gray-3);
}

:is(.dark-mode *),
Expand Down Expand Up @@ -373,6 +377,8 @@
--color-modal-layer: var(--color-gray-12-60);
--color-new-highlight: var(--color-yellow-3);
--color-gray-new-highlight: var(--color-gray-1-20);
--color-skeleton-base: var(--color-gray-11);
--color-skeleton-secondary: var(--color-gray-10);
}

body {
Expand Down