bookrank / static /css /animations.css
gongyijie85
feat: deploy BookRank application
80b1205
Raw History Blame Contribute Delete
10.8 kB
/* BookRank Animations & Loading States - Optimized for Performance */
/* Check for reduced motion preference */
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}
/* Skeleton Loading Animation - Enhanced */
@keyframes shimmer {
0% {
background-position: 200% 0;
}
100% {
background-position: -200% 0;
}
}
.skeleton {
background: linear-gradient(
90deg,
var(--bg-tertiary) 25%,
var(--bg-secondary) 50%,
var(--bg-tertiary) 75%
);
background-size: 200% 100%;
animation: shimmer 1.5s ease-in-out infinite;
border-radius: var(--radius-md);
/* Optimize rendering */
will-change: background-position;
contain: content;
}
.skeleton-card {
background: var(--bg-card);
border-radius: var(--radius-lg);
overflow: hidden;
box-shadow: var(--shadow-md);
}
.skeleton-image {
width: 100%;
aspect-ratio: 2/3;
background: linear-gradient(
90deg,
var(--bg-tertiary) 25%,
var(--bg-secondary) 50%,
var(--bg-tertiary) 75%
);
background-size: 200% 100%;
animation: shimmer 1.5s ease-in-out infinite;
will-change: background-position;
}
.skeleton-content {
padding: var(--spacing-md);
}
.skeleton-title {
height: 20px;
margin-bottom: var(--spacing-sm);
border-radius: var(--radius-sm);
background: linear-gradient(
90deg,
var(--bg-tertiary) 25%,
var(--bg-secondary) 50%,
var(--bg-tertiary) 75%
);
background-size: 200% 100%;
animation: shimmer 1.5s ease-in-out infinite;
}
.skeleton-author {
height: 16px;
width: 60%;
margin-bottom: var(--spacing-sm);
border-radius: var(--radius-sm);
background: linear-gradient(
90deg,
var(--bg-tertiary) 25%,
var(--bg-secondary) 50%,
var(--bg-tertiary) 75%
);
background-size: 200% 100%;
animation: shimmer 1.5s ease-in-out infinite;
}
.skeleton-tag {
height: 24px;
width: 80px;
border-radius: var(--radius-full);
background: linear-gradient(
90deg,
var(--bg-tertiary) 25%,
var(--bg-secondary) 50%,
var(--bg-tertiary) 75%
);
background-size: 200% 100%;
animation: shimmer 1.5s ease-in-out infinite;
}
/* Fade In Animation */
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.fade-in {
animation: fadeIn 0.5s ease-out forwards;
will-change: opacity, transform;
}
/* Stagger Animation for Cards - Performance Optimized */
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.card-animate {
opacity: 0;
animation: fadeInUp 0.5s ease-out forwards;
will-change: opacity, transform;
/* Optimize animation performance */
animation-fill-mode: forwards;
}
/* Stagger delays - limited to prevent performance issues */
.card-animate:nth-child(1) { animation-delay: 0.05s; }
.card-animate:nth-child(2) { animation-delay: 0.1s; }
.card-animate:nth-child(3) { animation-delay: 0.15s; }
.card-animate:nth-child(4) { animation-delay: 0.2s; }
.card-animate:nth-child(5) { animation-delay: 0.25s; }
.card-animate:nth-child(6) { animation-delay: 0.3s; }
.card-animate:nth-child(7) { animation-delay: 0.35s; }
.card-animate:nth-child(8) { animation-delay: 0.4s; }
/* Pulse Animation for Loading */
@keyframes pulse {
0%, 100% {
opacity: 1;
}
50% {
opacity: 0.5;
}
}
.pulse {
animation: pulse 2s ease-in-out infinite;
will-change: opacity;
}
/* Spin Animation */
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.spin {
animation: spin 1s linear infinite;
will-change: transform;
}
/* Heart Beat Animation for Favorite */
@keyframes heartBeat {
0% {
transform: scale(1);
}
14% {
transform: scale(1.3);
}
28% {
transform: scale(1);
}
42% {
transform: scale(1.3);
}
70% {
transform: scale(1);
}
}
.heart-beat {
animation: heartBeat 0.5s ease-in-out;
will-change: transform;
}
/* Slide In from Left */
@keyframes slideInLeft {
from {
transform: translateX(-100%);
opacity: 0;
}
to {
transform: translateX(0);
opacity: 1;
}
}
.slide-in-left {
animation: slideInLeft 0.3s ease-out forwards;
will-change: transform, opacity;
}
/* Slide In from Right */
@keyframes slideInRight {
from {
transform: translateX(100%);
opacity: 0;
}
to {
transform: translateX(0);
opacity: 1;
}
}
.slide-in-right {
animation: slideInRight 0.3s ease-out forwards;
will-change: transform, opacity;
}
/* Bounce Animation */
@keyframes bounce {
0%, 20%, 50%, 80%, 100% {
transform: translateY(0);
}
40% {
transform: translateY(-10px);
}
60% {
transform: translateY(-5px);
}
}
.bounce {
animation: bounce 1s ease infinite;
will-change: transform;
}
/* Shimmer Effect for Loading - Enhanced */
@keyframes shimmerEffect {
0% {
background-position: -1000px 0;
}
100% {
background-position: 1000px 0;
}
}
.shimmer {
background: linear-gradient(
90deg,
rgba(255, 255, 255, 0) 0%,
rgba(255, 255, 255, 0.4) 50%,
rgba(255, 255, 255, 0) 100%
);
background-size: 1000px 100%;
animation: shimmerEffect 2s infinite linear;
will-change: background-position;
}
/* Loading Spinner - Vercel Style */
.loading-spinner {
display: inline-block;
width: 40px;
height: 40px;
border: 3px solid rgba(23, 23, 23, 0.1);
border-radius: 50%;
border-top-color: var(--primary-color);
animation: spin 1s linear infinite;
will-change: transform;
}
.loading-spinner-sm {
width: 24px;
height: 24px;
border-width: 2px;
}
.loading-spinner-lg {
width: 64px;
height: 64px;
border-width: 4px;
}
/* Loading Overlay */
.loading-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(255, 255, 255, 0.9);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
z-index: 1000;
backdrop-filter: blur(4px);
/* Performance optimization */
will-change: opacity;
transition: opacity 0.3s ease;
}
@media (prefers-color-scheme: dark) {
.loading-overlay {
background: rgba(15, 23, 42, 0.9);
}
}
[data-theme="dark"] .loading-overlay {
background: rgba(15, 23, 42, 0.9);
}
.loading-overlay.hidden {
opacity: 0;
pointer-events: none;
}
.loading-text {
margin-top: var(--spacing-lg);
color: var(--text-secondary);
font-size: 1rem;
}
/* Progress Bar - Vercel Style */
@keyframes progress {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
.progress-bar {
width: 100%;
height: 4px;
background: var(--bg-tertiary);
border-radius: var(--radius-full);
overflow: hidden;
}
.progress-bar-fill {
height: 100%;
background: var(--primary-color);
border-radius: var(--radius-full);
transition: width 0.3s ease;
will-change: width;
}
.progress-bar-animated .progress-bar-fill {
animation: progress 2s ease-in-out infinite;
}
/* Toast Notification - Enhanced */
@keyframes slideInDown {
from {
transform: translateY(-100%);
opacity: 0;
}
to {
transform: translateY(0);
opacity: 1;
}
}
@keyframes slideOutUp {
from {
transform: translateY(0);
opacity: 1;
}
to {
transform: translateY(-100%);
opacity: 0;
}
}
.toast {
/* Inherit from base.css */
}
.toast.toast-enter {
animation: slideInDown 0.3s ease forwards;
will-change: transform, opacity;
}
.toast.toast-exit {
animation: slideOutUp 0.3s ease forwards;
will-change: transform, opacity;
}
/* Modal Animation - Enhanced */
@keyframes modalFadeIn {
from {
opacity: 0;
transform: scale(0.95);
}
to {
opacity: 1;
transform: scale(1);
}
}
.modal.active .modal-content {
animation: modalFadeIn 0.3s ease forwards;
will-change: opacity, transform;
}
/* Card hover animations */
@keyframes cardHoverLift {
from {
transform: translateY(0);
}
to {
transform: translateY(-4px);
}
}
.card:hover {
transform: translateY(-4px);
will-change: transform;
}
/* Image load animation */
@keyframes imageReveal {
from {
opacity: 0;
transform: scale(1.02);
}
to {
opacity: 1;
transform: scale(1);
}
}
.card-image img.loaded {
animation: imageReveal 0.3s ease forwards;
}
/* Skeleton pulse for loading states */
@keyframes skeletonPulse {
0%, 100% {
opacity: 1;
}
50% {
opacity: 0.5;
}
}
.skeleton-loading {
animation: skeletonPulse 1.5s ease-in-out infinite;
will-change: opacity;
}
/* Lazy load reveal */
@keyframes lazyLoadReveal {
from {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.lazy-load-reveal {
animation: lazyLoadReveal 0.3s ease forwards;
will-change: opacity, transform;
}
/* Button ripple effect (optional, can be disabled for performance) */
.btn-ripple {
position: relative;
overflow: hidden;
}
.btn-ripple::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 0;
height: 0;
border-radius: 50%;
background: rgba(255, 255, 255, 0.3);
transform: translate(-50%, -50%);
transition: width 0.3s ease, height 0.3s ease;
}
.btn-ripple:active::after {
width: 200%;
height: 200%;
}
/* Entrance animations for page elements */
@keyframes slideInFromBottom {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.page-header,
.filter-bar,
.export-actions-bar,
.quick-link-section {
animation: slideInFromBottom 0.4s ease forwards;
will-change: opacity, transform;
}
.page-header {
animation-delay: 0.1s;
opacity: 0;
}
.filter-bar {
animation-delay: 0.2s;
opacity: 0;
}
.export-actions-bar {
animation-delay: 0.3s;
opacity: 0;
}
.quick-link-section {
animation-delay: 0.4s;
opacity: 0;
}