A UI effects library for modern web applications with optimized imports.
npm install @radui/fx
This library uses a direct import pattern exclusively. This means you need to import components directly from their paths rather than from the package root.
- Better Tree-Shaking: Direct imports enable bundlers to eliminate unused code more effectively, resulting in smaller bundle sizes.
- Clear Dependencies: They make it explicit what's being imported, enhancing code readability.
- Improved Build Performance: Direct imports can lead to faster build times by reducing unnecessary processing.
- Type Safety: TypeScript can more accurately track imports and exports with this pattern.
// ✅ Recommended - direct imports
import Fade from '@radui/fx/Fade';
import Slide from '@radui/fx/Slide';
// ❌ Not supported - importing from the package root
import { Fade, Slide } from '@radui/fx'; // This won't work!
The library is designed to be imported using direct component imports for better tree-shaking and bundle optimization:
import Fade from "@radui/fx/Fade";
import Slide from "@radui/fx/Slide";
// Or utilities
import { createFadeAnimation } from "@radui/fx/Fade";
import { createSlideAnimation } from "@radui/fx/Slide";
function MyComponent() {
return (
<div>
<Fade duration={0.5} delay={0.2}>
This content fades in
</Fade>
<Slide direction="left" distance={100} duration={0.6}>
This content slides in from the left
</Slide>
</div>
);
}
Access motion adapter utilities:
import { createTransition } from "@radui/fx/utils/motion-adapter";
Get version information:
import { version, getLibraryInfo } from "@radui/fx/version";
console.log(`Using @radui/fx version: ${version}`);
import { motion } from 'framer-motion'; // or from 'motion'
import { createFadeAnimation } from '@radui/fx/Fade';
function MyComponent() {
const fadeVariants = createFadeAnimation({ duration: 0.8 });
return (
<motion.div
initial="hidden"
animate="visible"
variants={fadeVariants}
>
Fade me in!
</motion.div>
);
}
import Fade, { createFadeAnimation } from "@radui/fx/Fade";
duration
: Duration of the animation in seconds (default: 0.5)delay
: Delay before the animation starts in seconds (default: 0)initialOpacity
: Initial opacity value (default: 0)finalOpacity
: Final opacity value (default: 1)easing
: Easing function to use (default: "easeInOut")
import Slide, { createSlideAnimation } from "@radui/fx/Slide";
direction
: Direction from which to slide ("up", "down", "left", "right") (default: "up")distance
: Distance to slide in pixels (default: 50)duration
: Duration of the animation in seconds (default: 0.5)delay
: Delay before the animation starts in seconds (default: 0)easing
: Easing function to use (default: "easeInOut")
The library includes a Storybook setup to demonstrate the animations and components:
# Run Storybook locally
npm run storybook
This will start Storybook on http://localhost:6006 where you can:
- View all available animations
- Experiment with different parameters
- See usage examples
- Test components in isolation
# Clone the repository
git clone https://github.com/yourusername/rad-ui-fx.git
cd rad-ui-fx
# Install dependencies
npm install
# Run Storybook development server
npm run storybook
# or the shorthand
npm run sb
# Build Storybook for deployment
npm run build-storybook
# Deploy Storybook to GitHub Pages
npm run deploy-storybook
# Development with auto-recompile
npm run dev
# Build the library
npm run build
# Clean the build directory
npm run clean
# Run tests once
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage
# Check for linting issues
npm run lint
# Fix linting issues automatically when possible
npm run lint:fix
MIT