hyprland-website/src/routes/HeroBackground.svelte

247 lines
5 KiB
Svelte
Raw Normal View History

2023-09-04 20:54:16 +02:00
<script>
2023-09-13 14:27:13 +02:00
export let backgroundData
2023-09-04 20:54:16 +02:00
2023-09-13 14:27:13 +02:00
const { workspacesPerRow, gapLength, workspaceHeight, height, leftColumns, rightColumns } =
backgroundData
2023-09-04 20:54:16 +02:00
</script>
2023-09-07 21:03:47 +02:00
<div class="wrapper" aria-hidden="true">
2023-09-04 20:54:16 +02:00
<div
class="inner-wrapper"
2023-09-05 21:09:18 +02:00
style={`--amount: ${workspacesPerRow}; --workspace-gap: ${gapLength}px;--workspace-height: ${workspaceHeight}px; --length: ${height}px;`}
2023-09-04 20:54:16 +02:00
>
2023-09-05 21:09:18 +02:00
<!-- Gradient background -->
<div class="top-light" />
<div class="columns left" aria-hidden="true">
2023-09-04 20:54:16 +02:00
{#each leftColumns as column}
<div class="column">
{#each column as workspace}
<div class="workspace">
{#each workspace as tiles}
<div class="tiles">
{#each tiles as { color, image }}
<div
class="tile"
style:--color={color}
class:with-image={image}
style:--image={`url(${image})`}
></div>
2023-09-04 20:54:16 +02:00
{/each}
</div>
{/each}
</div>
{/each}
</div>
{/each}
</div>
2023-09-05 21:09:18 +02:00
<div class="columns right" aria-hidden="true">
2023-09-04 20:54:16 +02:00
{#each rightColumns as column}
<div class="column">
{#each column as workspace}
<div class="workspace">
{#each workspace as tiles}
<div class="tiles">
{#each tiles as { color, image }}
<div
class="tile"
style:--color={color}
class:with-image={image}
style:--image={`url(${image})`}
></div>
2023-09-04 20:54:16 +02:00
{/each}
</div>
{/each}
</div>
{/each}
</div>
{/each}
</div>
</div>
</div>
<style lang="postcss">
.left {
2023-09-13 14:27:13 +02:00
transform: rotateY(10deg);
2023-09-04 20:54:16 +02:00
}
.right {
2023-09-13 14:27:13 +02:00
transform: rotateY(-10deg);
2023-09-04 20:54:16 +02:00
}
.wrapper {
width: 100vw;
display: flex;
align-items: center;
justify-content: center;
2023-09-05 21:09:18 +02:00
height: calc(100vh - 48px);
contain: strict;
2023-09-13 14:27:13 +02:00
pointer-events: none;
2023-09-05 21:09:18 +02:00
@apply max-sm:hidden;
2023-09-04 20:54:16 +02:00
}
.inner-wrapper {
position: absolute;
perspective: 100px;
height: 100%;
2023-09-05 21:09:18 +02:00
width: max(100vw, 2200px);
2023-09-04 20:54:16 +02:00
contain: strict;
display: flex;
2023-09-05 21:09:18 +02:00
mask-image: linear-gradient(to top, transparent 0%, black 20%);
2023-09-07 21:03:47 +02:00
contain: layout style content;
2023-09-13 14:27:13 +02:00
pointer-events: none;
2023-09-05 21:09:18 +02:00
&::after {
content: ' ';
background: radial-gradient(80% 250%, theme(colors.black) 10%, transparent 50%);
position: absolute;
top: 50%;
left: 50%;
translate: -50% -50%;
width: 100%;
height: 100%;
z-index: -10;
pointer-events: none;
2023-09-07 21:03:47 +02:00
contain: strict;
2023-09-05 21:09:18 +02:00
}
2023-09-04 20:54:16 +02:00
}
.columns {
display: flex;
gap: 2rem;
flex-grow: 1;
2023-09-05 21:09:18 +02:00
mask-image: linear-gradient(to top, transparent 0%, black 30%);
z-index: -10;
height: var(--length);
min-height: var(--length);
max-height: var(--length);
2023-09-10 08:09:06 +02:00
/* animation: backwards animate-in ease-in 2000ms 300ms; */
2023-09-07 21:03:47 +02:00
contain: layout style content;
2023-09-04 20:54:16 +02:00
}
.column {
display: flex;
flex-direction: column;
2023-09-05 21:09:18 +02:00
height: 200%;
2023-09-04 20:54:16 +02:00
width: 100%;
gap: var(--workspace-gap);
2023-09-05 21:09:18 +02:00
z-index: -50;
2023-09-07 21:03:47 +02:00
/* animation: loop 98s infinite linear; */
contain: layout style content;
2023-09-05 21:09:18 +02:00
2023-09-13 14:27:13 +02:00
/* @media (prefers-reduced-motion) {
2023-09-05 21:09:18 +02:00
animation: none;
2023-09-13 14:27:13 +02:00
} */
2023-09-04 20:54:16 +02:00
}
.workspace {
display: flex;
gap: 8px;
2023-09-05 21:09:18 +02:00
min-height: var(--workspace-height);
max-height: var(--workspace-height);
2023-09-04 20:54:16 +02:00
width: 100%;
2023-09-07 21:03:47 +02:00
contain: layout style content;
2023-09-04 20:54:16 +02:00
}
.tiles {
display: flex;
flex-direction: column;
gap: 8px;
flex-grow: 1;
2023-09-07 21:03:47 +02:00
contain: layout style content;
2023-09-04 20:54:16 +02:00
}
.tile {
2023-09-13 14:27:13 +02:00
--reveal-length: 0.5s;
2023-09-05 21:09:18 +02:00
border: var(--color) 2px solid;
2023-09-04 20:54:16 +02:00
flex-grow: 1;
height: var(--height);
border-radius: 12px;
pointer-events: auto;
2023-09-13 14:27:13 +02:00
transition: 480ms ease-in-out;
transition-property: background-color background-image opacity scale box-shadow;
2023-09-07 21:03:47 +02:00
opacity: 0.5;
contain: strict;
2023-09-13 14:27:13 +02:00
pointer-events: all;
2023-09-04 20:54:16 +02:00
&:hover {
2023-09-07 21:03:47 +02:00
opacity: 1;
scale: 1.02;
2023-09-13 14:27:13 +02:00
background-color: color-mix(in hsl, var(--color), transparent 20%);
2023-09-05 21:09:18 +02:00
box-shadow:
0px 0px 10px var(--color),
0px 0px 40px var(--color);
2023-09-04 20:54:16 +02:00
}
2023-09-13 14:27:13 +02:00
&:hover.with-image {
scale: 1;
animation: reveal-artwork_tile calc(var(--reveal-length) + 280ms)
cubic-bezier(1, -0.4, 0.165, 1) forwards;
}
&.with-image::after {
content: ' ';
position: absolute;
inset: 0;
background-image: var(--image);
background-position: center;
background-size: contain;
background-repeat: no-repeat;
opacity: 0;
transition: opacity 1520ms ease-in-out;
}
&:hover::after {
animation: reveal-artwork var(--reveal-length) ease-in-out 400ms both;
opacity: 1;
transition: opacity 1520ms ease-in-out;
}
2023-09-04 20:54:16 +02:00
}
2023-09-05 21:09:18 +02:00
.top-light {
background: radial-gradient(
100% 80% at top,
2023-09-07 21:03:47 +02:00
theme(colors.cyan.500 / 50%) 0%,
2023-09-05 21:09:18 +02:00
theme(colors.sky.500 / 20%),
transparent
);
width: 100%;
height: 100%;
position: absolute;
z-index: 10;
top: 0;
left: 0;
pointer-events: none;
2023-09-07 21:03:47 +02:00
contain: strict;
2023-09-04 20:54:16 +02:00
}
@keyframes reveal-artwork {
0% {
opacity: 0%;
filter: brightness(1);
}
50% {
filter: brightness(1.45);
opacity: 40%;
}
100% {
filter: brightness(1);
opacity: 100%;
}
}
@keyframes reveal-artwork_tile {
0% {
opacity: inherit;
scale: 1;
}
50% {
filter: brightness(1.5);
scale: 1.1;
}
100% {
opacity: 100%;
scale: 1;
}
}
2023-09-04 20:54:16 +02:00
</style>