mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +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 { useEffect, useRef } from 'react';
|
||||
import { embedPreviews } from '../../../constants/embeds';
|
||||
import { useEmbedStateCurry } from '../../../stores/embedState/utilities';
|
||||
import * as styles from './index.css';
|
||||
import { embedPreviews } from '../../constants/embeds';
|
||||
import { useEmbedStateCurry } from '../../stores/embedState/utilities';
|
||||
|
||||
interface PreviewWrapperProps {
|
||||
name: keyof typeof embedPreviews;
|
||||
@@ -19,9 +18,9 @@ export function PreviewWrapper({ name, naked }: PreviewWrapperProps) {
|
||||
useEffect(() => {
|
||||
if (!wrapper.current) return;
|
||||
|
||||
wrapper.current.classList.remove(styles.animated);
|
||||
wrapper.current.classList.remove('preview-container-animated');
|
||||
void wrapper.current.offsetWidth;
|
||||
wrapper.current.classList.add(styles.animated);
|
||||
wrapper.current.classList.add('preview-container-animated');
|
||||
}, [width, height]);
|
||||
|
||||
if (naked) {
|
||||
@@ -47,6 +46,7 @@ export function PreviewWrapper({ name, naked }: PreviewWrapperProps) {
|
||||
overflow="hidden"
|
||||
style={{ transform: naked ? 'scale(0.25)' : 'translate(-50%, -50%)' }}
|
||||
ref={wrapper}
|
||||
className="preview-container-animated"
|
||||
width={`${width}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>
|
||||
|
||||
<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>
|
||||
<Page client:load embed={Astro.params.embed} />
|
||||
</BaseLayout>
|
||||
Reference in new issue
Block a user