saudi-national-day-carousel 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +48 -0
- package/dist/animations/cssStrategy.d.ts +2 -0
- package/dist/components/ArrowButton.d.ts +8 -0
- package/dist/components/AssetDeck.d.ts +1 -0
- package/dist/components/Controls.d.ts +1 -0
- package/dist/components/Headline.d.ts +1 -0
- package/dist/components/Logo.d.ts +1 -0
- package/dist/components/Root.d.ts +2 -0
- package/dist/components/SaudiNationalDayCarousel.d.ts +16 -0
- package/dist/core/CarouselContext.d.ts +13 -0
- package/dist/core/deckMotion.d.ts +3 -0
- package/dist/core/defaults.d.ts +7 -0
- package/dist/core/layout.d.ts +3 -0
- package/dist/core/prefersReducedMotion.d.ts +2 -0
- package/dist/core/types.d.ts +57 -0
- package/dist/core/useCarouselState.d.ts +16 -0
- package/dist/core/useCompactLayout.d.ts +2 -0
- package/dist/core/useDeckSwipe.d.ts +17 -0
- package/dist/core/useSlideTransition.d.ts +2 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +541 -0
- package/dist/saudi-national-day-carousel.css +1 -0
- package/dist/saudi-national-day-carousel.umd.js +8 -0
- package/dist/slides/defaultSlides.d.ts +3 -0
- package/package.json +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Saudi National Day Carousel
|
|
2
|
+
|
|
3
|
+
GitHub: [farhat-baaroun/saudi-national-day-carousel](https://github.com/farhat-baaroun/saudi-national-day-carousel)
|
|
4
|
+
|
|
5
|
+
Storybook lives in a separate repo: [saudi-national-day-carousel-storybook](https://github.com/farhat-baaroun/saudi-national-day-carousel-storybook).
|
|
6
|
+
|
|
7
|
+
React 18 hero carousel with a stacked wide deck, compact peek + swipe, and a standalone UMD build.
|
|
8
|
+
|
|
9
|
+
The widget fills its parent. Layout uses container queries, not the viewport.
|
|
10
|
+
|
|
11
|
+
Stories live in the sibling `saudi-national-day-carousel-storybook` package, not here.
|
|
12
|
+
|
|
13
|
+
## React
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { SaudiNationalDayCarousel } from "saudi-national-day-carousel";
|
|
17
|
+
import "saudi-national-day-carousel/style.css";
|
|
18
|
+
|
|
19
|
+
export function Hero() {
|
|
20
|
+
return (
|
|
21
|
+
<div style={{ width: "100%", height: 491 }}>
|
|
22
|
+
<SaudiNationalDayCarousel />
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## UMD / CDN
|
|
29
|
+
|
|
30
|
+
After `npm publish`, jsDelivr and unpkg serve the UMD bundle:
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
<div id="hero" style="width:100%;aspect-ratio:1440/491"></div>
|
|
34
|
+
<script src="https://cdn.jsdelivr.net/npm/saudi-national-day-carousel/dist/saudi-national-day-carousel.umd.js"></script>
|
|
35
|
+
<script>
|
|
36
|
+
SaudiNationalDayCarousel.mount("#hero", { autoplayMs: 6000 });
|
|
37
|
+
</script>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Local demo: `demo/umd.html` (needs `npm run build` first).
|
|
41
|
+
|
|
42
|
+
## Scripts
|
|
43
|
+
|
|
44
|
+
| Command | Purpose |
|
|
45
|
+
| --- | --- |
|
|
46
|
+
| `npm run build` | ESM library + UMD widget |
|
|
47
|
+
| `npm test` | Unit tests |
|
|
48
|
+
| `npm publish` | Publish `dist/` to npm (then CDN) |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function AssetDeck(): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Controls(): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Headline(): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Logo(): import("react").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AssetDeck } from './AssetDeck';
|
|
2
|
+
import { CarouselRootProps } from '../core/types';
|
|
3
|
+
/**
|
|
4
|
+
* Saudi National Day hero carousel.
|
|
5
|
+
*
|
|
6
|
+
* Fills its parent. Wide parents show a staggered figure stack; compact
|
|
7
|
+
* parents (about 390×760) use a peek carousel that stops at the first and last slide.
|
|
8
|
+
*/
|
|
9
|
+
export declare function SaudiNationalDayCarousel(props: CarouselRootProps): import("react").JSX.Element;
|
|
10
|
+
export declare namespace SaudiNationalDayCarousel {
|
|
11
|
+
var Root: typeof import("./Root").Root;
|
|
12
|
+
var Deck: typeof AssetDeck;
|
|
13
|
+
var Headline: typeof import("./Headline").Headline;
|
|
14
|
+
var Controls: typeof import("./Controls").Controls;
|
|
15
|
+
var Logo: typeof import("./Logo").Logo;
|
|
16
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AnimationConfig, AnimationStrategy, CarouselApi, Slide } from './types';
|
|
3
|
+
export type CarouselProviderProps = {
|
|
4
|
+
slides?: Slide[];
|
|
5
|
+
initialIndex?: number;
|
|
6
|
+
animation?: Partial<AnimationConfig>;
|
|
7
|
+
animationStrategy?: AnimationStrategy;
|
|
8
|
+
onSlideChange?: (index: number) => void;
|
|
9
|
+
paused?: boolean;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
};
|
|
12
|
+
export declare function CarouselProvider({ slides, initialIndex, animation, animationStrategy, onSlideChange, paused, children, }: CarouselProviderProps): import("react").JSX.Element;
|
|
13
|
+
export declare function useCarousel(): CarouselApi;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function peekOffset(slideIndex: number, activeIndex: number, count: number): number | null;
|
|
2
|
+
export declare function stackOffset(slideIndex: number, activeIndex: number, count: number): number;
|
|
3
|
+
export declare function resolveSwipe(deltaX: number, threshold: number): -1 | 0 | 1;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AnimationConfig } from './types';
|
|
2
|
+
export declare const DEFAULT_ANIMATION: AnimationConfig;
|
|
3
|
+
export declare const DEFAULT_TITLE = "\u0639\u0650\u0632\u0651\u0646\u0627";
|
|
4
|
+
export declare const DEFAULT_INITIAL_INDEX = 5;
|
|
5
|
+
export declare const DESIGN_WIDTH = 1440;
|
|
6
|
+
export declare const DESIGN_HEIGHT = 491;
|
|
7
|
+
export declare function mergeAnimationConfig(overrides?: Partial<AnimationConfig>): AnimationConfig;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
export type Slide = {
|
|
3
|
+
id: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
typewriter: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
image: string;
|
|
8
|
+
imageAlt: string;
|
|
9
|
+
background?: string;
|
|
10
|
+
gradient?: string;
|
|
11
|
+
textColor?: string;
|
|
12
|
+
accentColor?: string;
|
|
13
|
+
patternColor?: string;
|
|
14
|
+
controlColor?: string;
|
|
15
|
+
};
|
|
16
|
+
export type AnimationConfig = {
|
|
17
|
+
durationMs: number;
|
|
18
|
+
easing: string;
|
|
19
|
+
typewriterMsPerChar: number;
|
|
20
|
+
autoplayMs: number | false;
|
|
21
|
+
};
|
|
22
|
+
export interface AnimationStrategy {
|
|
23
|
+
enter(el: HTMLElement, config: AnimationConfig): void | Promise<void>;
|
|
24
|
+
exit(el: HTMLElement, config: AnimationConfig): void | Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export type CarouselApi = {
|
|
27
|
+
slides: Slide[];
|
|
28
|
+
index: number;
|
|
29
|
+
goTo: (index: number) => void;
|
|
30
|
+
next: () => void;
|
|
31
|
+
prev: () => void;
|
|
32
|
+
setPaused: (paused: boolean) => void;
|
|
33
|
+
animation: AnimationConfig;
|
|
34
|
+
animationStrategy: AnimationStrategy;
|
|
35
|
+
reducedMotion: boolean;
|
|
36
|
+
compact: boolean;
|
|
37
|
+
canPrev: boolean;
|
|
38
|
+
canNext: boolean;
|
|
39
|
+
setCompact: (compact: boolean) => void;
|
|
40
|
+
};
|
|
41
|
+
export type CarouselRootProps = {
|
|
42
|
+
/** Override the six default National Day slides. */
|
|
43
|
+
slides?: Slide[];
|
|
44
|
+
/** Zero-based start slide. Defaults to Vision when using built-in slides. */
|
|
45
|
+
initialIndex?: number;
|
|
46
|
+
/** Motion, typewriter, and autoplay timing. */
|
|
47
|
+
animation?: Partial<AnimationConfig>;
|
|
48
|
+
/** Custom enter/exit strategy. Defaults to CSS classes. */
|
|
49
|
+
animationStrategy?: AnimationStrategy;
|
|
50
|
+
/** Fires after the active index changes. */
|
|
51
|
+
onSlideChange?: (index: number) => void;
|
|
52
|
+
className?: string;
|
|
53
|
+
style?: CSSProperties;
|
|
54
|
+
/** Replace the default logo / headline / controls / deck layout. */
|
|
55
|
+
children?: ReactNode;
|
|
56
|
+
};
|
|
57
|
+
export type MountOptions = Omit<CarouselRootProps, "children"> & Partial<AnimationConfig>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type UseCarouselStateOptions = {
|
|
2
|
+
slideCount: number;
|
|
3
|
+
initialIndex?: number;
|
|
4
|
+
autoplayMs?: number | false;
|
|
5
|
+
paused?: boolean;
|
|
6
|
+
reducedMotion?: boolean;
|
|
7
|
+
loop?: boolean;
|
|
8
|
+
onChange?: (index: number) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare function wrapIndex(index: number, count: number): number;
|
|
11
|
+
export declare function useCarouselState({ slideCount, initialIndex, autoplayMs, paused, reducedMotion, loop, onChange, }: UseCarouselStateOptions): {
|
|
12
|
+
index: number;
|
|
13
|
+
goTo: (nextIndex: number) => void;
|
|
14
|
+
next: () => void;
|
|
15
|
+
prev: () => void;
|
|
16
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PointerEvent as ReactPointerEvent, RefObject } from 'react';
|
|
2
|
+
type UseDeckSwipeOptions = {
|
|
3
|
+
next: () => void;
|
|
4
|
+
prev: () => void;
|
|
5
|
+
setPaused: (paused: boolean) => void;
|
|
6
|
+
reducedMotion: boolean;
|
|
7
|
+
canPrev?: boolean;
|
|
8
|
+
canNext?: boolean;
|
|
9
|
+
compact?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function useDeckSwipe(deckRef: RefObject<HTMLElement | null>, { next, prev, setPaused, reducedMotion, canPrev, canNext, compact, }: UseDeckSwipeOptions): {
|
|
12
|
+
onPointerDown: (event: ReactPointerEvent<HTMLElement>) => void;
|
|
13
|
+
onPointerMove: (event: ReactPointerEvent<HTMLElement>) => void;
|
|
14
|
+
onPointerUp: (event: ReactPointerEvent<HTMLElement>) => void;
|
|
15
|
+
onPointerCancel: (event: ReactPointerEvent<HTMLElement>) => void;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { SaudiNationalDayCarousel } from './components/SaudiNationalDayCarousel';
|
|
2
|
+
export { Root as SaudiNationalDayCarouselRoot } from './components/Root';
|
|
3
|
+
export { AssetDeck } from './components/AssetDeck';
|
|
4
|
+
export { Headline } from './components/Headline';
|
|
5
|
+
export { Controls } from './components/Controls';
|
|
6
|
+
export { Logo } from './components/Logo';
|
|
7
|
+
export { defaultSlides, VISION_GRADIENT } from './slides/defaultSlides';
|
|
8
|
+
export { cssAnimationStrategy } from './animations/cssStrategy';
|
|
9
|
+
export { mergeAnimationConfig, DEFAULT_ANIMATION, DEFAULT_TITLE, DEFAULT_INITIAL_INDEX } from './core/defaults';
|
|
10
|
+
export { COMPACT_COPY_MIN_PX, isCompactLayout } from './core/layout';
|
|
11
|
+
export type { Slide, AnimationConfig, AnimationStrategy, CarouselRootProps, CarouselApi, MountOptions, } from './core/types';
|