Skip to content

Commit 8df7d22

Browse files
authored
Merge pull request #3 from ishansasika/release/v2.1.0-theming-and-ux
Release/v2.1.0 : Theming and UX
2 parents 9eaa0dc + 2b919db commit 8df7d22

16 files changed

Lines changed: 1464 additions & 37 deletions

File tree

CHANGELOG.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,71 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.1.0] - 2025-01-07
9+
10+
### Added
11+
12+
#### Theming System
13+
- **ThemeProvider Component** - Global theme configuration for all loaders
14+
- Set default colors, sizes, speeds, and UX options
15+
- Automatically applies to all loader components
16+
- Optional - components work without it
17+
- Example:
18+
```tsx
19+
<ThemeProvider theme={{ primaryColor: '#8b5cf6', defaultSpeed: 'fast' }}>
20+
<App />
21+
</ThemeProvider>
22+
```
23+
24+
- **useTheme Hook** - Access theme configuration in custom components
25+
- Returns current theme from ThemeProvider
26+
- Falls back to empty theme if no provider present
27+
- Useful for creating custom loaders
28+
29+
#### Loading State Management
30+
- **useLoader Hook** - Smart loading state management
31+
- Built-in delay, minimum duration, and auto-hide
32+
- Returns loading state and control functions
33+
- Provides `isVisible` for optimal UX
34+
- Example:
35+
```tsx
36+
const { loading, startLoading, stopLoading, isVisible } = useLoader({
37+
delay: 200,
38+
minDuration: 600,
39+
});
40+
```
41+
42+
#### Enhanced CSS Variables
43+
- Added comprehensive CSS custom properties for theming
44+
- Size presets: `--loader-size-xs` through `--loader-size-xl`
45+
- Spacing variables: `--loader-gap`, `--loader-padding`
46+
- Border radius: `--loader-radius-sm/md/lg/full`
47+
- Transition durations: `--loader-transition-fast/normal/slow`
48+
- **Dark mode support** - Automatic skeleton color adjustment for dark themes
49+
- Uses `@media (prefers-color-scheme: dark)`
50+
- Adjusts skeleton base and highlight colors
51+
52+
### Fixed
53+
54+
#### TypingIndicator Component
55+
- **Improved animation timing** - Delay between dots now scales with animation duration
56+
- Uses 15% of animation duration for smoother sequencing
57+
- Works correctly with all speed settings (slow, normal, fast)
58+
- **Enhanced animation smoothness**
59+
- Adjusted keyframe timing (70% idle instead of 60%)
60+
- Increased bounce height for better visibility
61+
- Improved fade opacity range
62+
- **Performance optimization** - Added `willChange: 'transform, opacity'` for better rendering
63+
64+
### Changed
65+
66+
- Updated version to 2.1.0
67+
- CSS bundle slightly increased to 6.94 KB (was 6.27 KB) due to enhanced theme variables
68+
- Still 67% smaller than v1.x (21 KB)
69+
- Gzipped: 1.85 KB
70+
71+
---
72+
873
## [2.0.0] - 2025-01-07
974

1075
### 🎉 Major Release - Zero Configuration, Smaller Bundle

README.md

Lines changed: 203 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ See all 25 components in action with interactive examples and customization opti
1616
## Features
1717

1818
- **25 Premium Components** across 5 categories (Skeleton, Spinner, Progress, Pulse, Overlay)
19+
- **Global Theming** - ThemeProvider for app-wide customization ✨ *New in v2.1.0*
20+
- **Smart Loading UX** - useLoader hook with delay, minDuration, and autoHide ✨ *New in v2.1.0*
21+
- **Enhanced CSS Variables** - Comprehensive theming with dark mode support ✨ *New in v2.1.0*
1922
- **Zero Configuration** - No Tailwind or build setup required ✨ *New in v2.0.0*
2023
- **Tiny Bundle Size** - 70% smaller CSS (6.27 KB → 1.64 KB gzipped) ✨ *New in v2.0.0*
2124
- **Zero Runtime Dependencies** - No external dependencies needed ✨ *New in v2.0.0*
@@ -54,6 +57,29 @@ import 'premium-react-loaders/styles';
5457

5558
That's it! No Tailwind configuration or additional setup needed.
5659

60+
### Optional: Global Theming (v2.1.0+)
61+
62+
Wrap your app with `ThemeProvider` to customize all loaders globally:
63+
64+
```tsx
65+
import { ThemeProvider } from 'premium-react-loaders';
66+
67+
function App() {
68+
return (
69+
<ThemeProvider
70+
theme={{
71+
primaryColor: '#8b5cf6',
72+
secondaryColor: '#ec4899',
73+
defaultSize: 'lg',
74+
defaultSpeed: 'fast',
75+
}}
76+
>
77+
<YourApp />
78+
</ThemeProvider>
79+
);
80+
}
81+
```
82+
5783
## Quick Start
5884

5985
```tsx
@@ -311,6 +337,101 @@ import { SpinnerCircle, ProgressBar, PulseDots } from 'premium-react-loaders';
311337
<PulseDots size="md" reverse />
312338
```
313339

340+
### New in v2.1.0
341+
342+
**Global Theming** - Customize all loaders from one place:
343+
344+
```tsx
345+
import { ThemeProvider } from 'premium-react-loaders';
346+
347+
function App() {
348+
return (
349+
<ThemeProvider
350+
theme={{
351+
primaryColor: '#8b5cf6',
352+
secondaryColor: '#ec4899',
353+
skeletonBase: '#e2e8f0',
354+
skeletonHighlight: '#f1f5f9',
355+
defaultSize: 'lg',
356+
defaultSpeed: 'fast',
357+
defaultDelay: 200,
358+
defaultMinDuration: 600,
359+
respectMotionPreference: true,
360+
}}
361+
>
362+
{/* All loaders inherit these settings */}
363+
<SpinnerCircle /> {/* Uses theme colors and size */}
364+
<Skeleton /> {/* Uses theme skeleton colors */}
365+
</ThemeProvider>
366+
);
367+
}
368+
```
369+
370+
**Smart Loading State Management** - Better UX with the `useLoader` hook:
371+
372+
```tsx
373+
import { useLoader } from 'premium-react-loaders';
374+
import { SpinnerCircle } from 'premium-react-loaders';
375+
376+
function MyComponent() {
377+
const { loading, startLoading, stopLoading, isVisible } = useLoader({
378+
delay: 200, // Don't show loader for quick operations (<200ms)
379+
minDuration: 600, // Show loader for at least 600ms to avoid flashing
380+
autoHide: 5000, // Auto-hide after 5 seconds (optional)
381+
});
382+
383+
const fetchData = async () => {
384+
startLoading();
385+
try {
386+
await api.fetchData();
387+
} finally {
388+
stopLoading();
389+
}
390+
};
391+
392+
return (
393+
<div>
394+
<button onClick={fetchData}>Load Data</button>
395+
<SpinnerCircle visible={isVisible} />
396+
</div>
397+
);
398+
}
399+
```
400+
401+
**Enhanced CSS Variables** - More control with comprehensive theming:
402+
403+
```css
404+
:root {
405+
/* Colors */
406+
--loader-primary: #3b82f6;
407+
--loader-secondary: #8b5cf6;
408+
--skeleton-base: #e5e7eb;
409+
--skeleton-highlight: #f5f5f5;
410+
411+
/* Sizes */
412+
--loader-size-xs: 16px;
413+
--loader-size-sm: 24px;
414+
--loader-size-md: 40px;
415+
--loader-size-lg: 56px;
416+
--loader-size-xl: 72px;
417+
418+
/* Animation */
419+
--loader-transition-fast: 150ms;
420+
--loader-transition-normal: 300ms;
421+
--loader-transition-slow: 500ms;
422+
}
423+
424+
/* Dark mode support */
425+
@media (prefers-color-scheme: dark) {
426+
:root {
427+
--skeleton-base: #2d3748;
428+
--skeleton-highlight: #4a5568;
429+
}
430+
}
431+
```
432+
433+
**Improved TypingIndicator** - Smoother animations with dynamic timing that scales with speed settings.
434+
314435
## Customization
315436

316437
All components support multiple customization methods:
@@ -339,16 +460,77 @@ Direct color control:
339460
<SpinnerCircle color="#8b5cf6" secondaryColor="#e0e0e0" />
340461
```
341462

342-
### 4. CSS Variables
463+
### 4. CSS Variables (Enhanced in v2.1.0)
343464

344-
Override theme variables globally:
465+
Override theme variables globally for comprehensive customization:
345466

346467
```css
347468
:root {
469+
/* Primary colors */
348470
--loader-primary: #3b82f6;
349471
--loader-secondary: #8b5cf6;
350-
--skeleton-base: #e0e0e0;
472+
473+
/* Skeleton colors */
474+
--skeleton-base: #e5e7eb;
351475
--skeleton-highlight: #f5f5f5;
476+
477+
/* Size presets */
478+
--loader-size-xs: 16px;
479+
--loader-size-sm: 24px;
480+
--loader-size-md: 40px;
481+
--loader-size-lg: 56px;
482+
--loader-size-xl: 72px;
483+
484+
/* Spacing and layout */
485+
--loader-gap: 0.5rem;
486+
--loader-radius-sm: 0.25rem;
487+
--loader-radius-md: 0.5rem;
488+
--loader-radius-lg: 1rem;
489+
--loader-radius-full: 9999px;
490+
491+
/* Animation speeds */
492+
--loader-transition-fast: 150ms;
493+
--loader-transition-normal: 300ms;
494+
--loader-transition-slow: 500ms;
495+
496+
/* Overlay */
497+
--loader-overlay-backdrop: rgba(0, 0, 0, 0.5);
498+
}
499+
500+
/* Dark mode support */
501+
@media (prefers-color-scheme: dark) {
502+
:root {
503+
--skeleton-base: #2d3748;
504+
--skeleton-highlight: #4a5568;
505+
}
506+
}
507+
```
508+
509+
### 5. ThemeProvider (v2.1.0+)
510+
511+
Use the `ThemeProvider` component for runtime theming:
512+
513+
```tsx
514+
import { ThemeProvider, useTheme } from 'premium-react-loaders';
515+
516+
function App() {
517+
return (
518+
<ThemeProvider
519+
theme={{
520+
primaryColor: '#8b5cf6',
521+
secondaryColor: '#ec4899',
522+
defaultSize: 'lg',
523+
}}
524+
>
525+
<YourComponents />
526+
</ThemeProvider>
527+
);
528+
}
529+
530+
// Access theme in child components
531+
function ChildComponent() {
532+
const { theme } = useTheme();
533+
return <SpinnerCircle />; // Automatically uses theme settings
352534
}
353535
```
354536

@@ -362,6 +544,9 @@ import type {
362544
SpinnerCircleProps,
363545
ProgressBarProps,
364546
PulseDotsProps,
547+
LoaderTheme,
548+
UseLoaderOptions,
549+
UseLoaderReturn,
365550
} from 'premium-react-loaders';
366551

367552
const MyComponent: React.FC = () => {
@@ -373,6 +558,21 @@ const MyComponent: React.FC = () => {
373558

374559
return <Skeleton {...skeletonProps} />;
375560
};
561+
562+
// Theme typing (v2.1.0+)
563+
const customTheme: LoaderTheme = {
564+
primaryColor: '#8b5cf6',
565+
secondaryColor: '#ec4899',
566+
defaultSize: 'lg',
567+
defaultSpeed: 'fast',
568+
};
569+
570+
// useLoader hook typing (v2.1.0+)
571+
const loaderOptions: UseLoaderOptions = {
572+
delay: 200,
573+
minDuration: 600,
574+
autoHide: 5000,
575+
};
376576
```
377577

378578
## Common Props

0 commit comments

Comments
 (0)