mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
feat: move animation to astro styles
This commit is contained in:
1 parent
6f00728187
commit
913bc82350
3 files changed
+24
-23
No files matched your search
+5
-5
@@ -1,8 +1,7 @@
|
|||||||
import { Box } from '@radix-ui/themes';
|
import { Box } from '@radix-ui/themes';
|
||||||
import { useEffect, useRef } from 'react';
|
import { useEffect, useRef } from 'react';
|
||||||
import { embedPreviews } from '../../../constants/embeds';
|
import { embedPreviews } from '../../constants/embeds';
|
||||||
import { useEmbedStateCurry } from '../../../stores/embedState/utilities';
|
import { useEmbedStateCurry } from '../../stores/embedState/utilities';
|
||||||
import * as styles from './index.css';
|
|
||||||
|
|
||||||
interface PreviewWrapperProps {
|
interface PreviewWrapperProps {
|
||||||
name: keyof typeof embedPreviews;
|
name: keyof typeof embedPreviews;
|
||||||
@@ -19,9 +18,9 @@ export function PreviewWrapper({ name, naked }: PreviewWrapperProps) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!wrapper.current) return;
|
if (!wrapper.current) return;
|
||||||
|
|
||||||
wrapper.current.classList.remove(styles.animated);
|
wrapper.current.classList.remove('preview-container-animated');
|
||||||
void wrapper.current.offsetWidth;
|
void wrapper.current.offsetWidth;
|
||||||
wrapper.current.classList.add(styles.animated);
|
wrapper.current.classList.add('preview-container-animated');
|
||||||
}, [width, height]);
|
}, [width, height]);
|
||||||
|
|
||||||
if (naked) {
|
if (naked) {
|
||||||
@@ -47,6 +46,7 @@ export function PreviewWrapper({ name, naked }: PreviewWrapperProps) {
|
|||||||
overflow="hidden"
|
overflow="hidden"
|
||||||
style={{ transform: naked ? 'scale(0.25)' : 'translate(-50%, -50%)' }}
|
style={{ transform: naked ? 'scale(0.25)' : 'translate(-50%, -50%)' }}
|
||||||
ref={wrapper}
|
ref={wrapper}
|
||||||
|
className="preview-container-animated"
|
||||||
width={`${width}px`}
|
width={`${width}px`}
|
||||||
height={`${height}px`}
|
height={`${height}px`}
|
||||||
>
|
>
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
import { keyframes, style } from '@vanilla-extract/css';
|
|
||||||
|
|
||||||
const fadeOutBorder = keyframes({
|
|
||||||
from: {
|
|
||||||
outline: '1rem solid #ff0000ff',
|
|
||||||
},
|
|
||||||
to: {
|
|
||||||
outline: '1rem solid #ff000000',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export const animated = style({
|
|
||||||
animation: `${fadeOutBorder} 0.5s linear`,
|
|
||||||
|
|
||||||
':hover': {
|
|
||||||
outline: '1rem solid #ff000080',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -14,6 +14,25 @@ export const getStaticPaths = (() => {
|
|||||||
|
|
||||||
<title>BlitzKit - {capitalize(Astro.params.embed)} embed</title>
|
<title>BlitzKit - {capitalize(Astro.params.embed)} embed</title>
|
||||||
|
|
||||||
|
<style is:global>
|
||||||
|
@keyframes fade-out-border {
|
||||||
|
from {
|
||||||
|
outline: 1rem solid #ff0000ff;
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
outline: 0.75rem solid #ff000000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-container-animated {
|
||||||
|
animation: fade-out-border 0.5s linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-container-animated:hover {
|
||||||
|
outline: 1rem solid #ff000080;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
<BaseLayout>
|
<BaseLayout>
|
||||||
<Page client:load embed={Astro.params.embed} />
|
<Page client:load embed={Astro.params.embed} />
|
||||||
</BaseLayout>
|
</BaseLayout>
|
||||||
Reference in new issue
Block a user