@juanlaria/lifted 0.1.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/README.md +73 -0
- package/dist/core/calculations.d.ts +25 -0
- package/dist/core/calculations.d.ts.map +1 -0
- package/dist/core/color.d.ts +23 -0
- package/dist/core/color.d.ts.map +1 -0
- package/dist/core/css-generator.d.ts +21 -0
- package/dist/core/css-generator.d.ts.map +1 -0
- package/dist/core/types.d.ts +217 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/index-4W01YOTU.cjs +2 -0
- package/dist/index-G-GHoQdJ.js +231 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +24 -0
- package/dist/index.js +1 -0
- package/dist/react/LiftedBox.d.ts +9 -0
- package/dist/react/LiftedBox.d.ts.map +1 -0
- package/dist/react/LiftedProvider.d.ts +11 -0
- package/dist/react/LiftedProvider.d.ts.map +1 -0
- package/dist/react/hooks/index.d.ts +3 -0
- package/dist/react/hooks/index.d.ts.map +1 -0
- package/dist/react/hooks/useDarkMode.d.ts +11 -0
- package/dist/react/hooks/useDarkMode.d.ts.map +1 -0
- package/dist/react/hooks/useElevation.d.ts +25 -0
- package/dist/react/hooks/useElevation.d.ts.map +1 -0
- package/dist/react/index.d.ts +6 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react.d.ts +1 -0
- package/dist/react.esm.js +186 -0
- package/dist/react.js +1 -0
- package/dist/vanilla/index.d.ts +10 -0
- package/dist/vanilla/index.d.ts.map +1 -0
- package/dist/vanilla/init.d.ts +8 -0
- package/dist/vanilla/init.d.ts.map +1 -0
- package/dist/vanilla.d.ts +1 -0
- package/dist/vanilla.esm.js +93 -0
- package/dist/vanilla.js +1 -0
- package/package.json +82 -0
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Lifted
|
|
2
|
+
|
|
3
|
+
Beautiful, realistic CSS shadows with layered depth.
|
|
4
|
+
|
|
5
|
+
Inspired by [Josh Comeau's "Designing Beautiful Shadows"](https://www.joshwcomeau.com/css/designing-shadows/) and [Tobias Ahlin's "Smoother & sharper shadows"](https://tobiasahlin.com/blog/layered-smooth-box-shadows/).
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Layered shadows** using powers-of-2 technique for realistic depth
|
|
10
|
+
- **Continuous elevation** (-1 to 1) with smooth interpolation
|
|
11
|
+
- **Inner shadows** - negative elevation creates inset/pressed effects
|
|
12
|
+
- **Dynamic light source** - static angles or mouse/cursor tracking
|
|
13
|
+
- **Color-matched shadows** - automatically derives shadow color from background
|
|
14
|
+
- **Dark mode support** - automatic detection + manual override
|
|
15
|
+
- **Framework agnostic** - works with React, vanilla JS, or any framework
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install lifted
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
### React
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { LiftedBox } from 'lifted/react';
|
|
29
|
+
|
|
30
|
+
// Raised card
|
|
31
|
+
<LiftedBox elevation={0.5} background="#FDFDFD">
|
|
32
|
+
Card content
|
|
33
|
+
</LiftedBox>
|
|
34
|
+
|
|
35
|
+
// Pressed/inset effect
|
|
36
|
+
<LiftedBox elevation={-0.3} background="#F5F5F5">
|
|
37
|
+
Pressed button
|
|
38
|
+
</LiftedBox>
|
|
39
|
+
|
|
40
|
+
// Mouse-tracking light
|
|
41
|
+
<LiftedBox elevation={0.6} lightSource="mouse">
|
|
42
|
+
Dynamic shadows!
|
|
43
|
+
</LiftedBox>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Vanilla JavaScript
|
|
47
|
+
|
|
48
|
+
```javascript
|
|
49
|
+
import { initLiftedBox } from 'lifted/vanilla';
|
|
50
|
+
|
|
51
|
+
const instance = initLiftedBox(element, {
|
|
52
|
+
elevation: 0.5,
|
|
53
|
+
background: '#FDFDFD',
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
instance.setElevation(-0.2); // Inner shadow
|
|
57
|
+
instance.destroy(); // Cleanup
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Elevation Values
|
|
61
|
+
|
|
62
|
+
| Value | Effect |
|
|
63
|
+
|-------|--------|
|
|
64
|
+
| `-1` | Maximum inner shadow |
|
|
65
|
+
| `-0.3` | Standard pressed effect |
|
|
66
|
+
| `0` | No shadow |
|
|
67
|
+
| `0.3` | Subtle raised card |
|
|
68
|
+
| `0.5` | Medium elevation |
|
|
69
|
+
| `1` | Maximum floating effect |
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
MIT © Juan Laria
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ShadowLayer, LightSource, LightSourceProp, Position, Bounds } from './types';
|
|
2
|
+
|
|
3
|
+
export declare const MAX_LAYERS = 5;
|
|
4
|
+
export declare const BASE_OPACITY = 0.075;
|
|
5
|
+
export declare const DEFAULT_LIGHT_ANGLE = -45;
|
|
6
|
+
export declare const DEFAULT_MAX_MOUSE_ANGLE = 30;
|
|
7
|
+
export declare function normalizeLightSource(source: LightSourceProp | undefined): LightSource;
|
|
8
|
+
export declare function calculateLightAngle(lightSource: LightSource, elementBounds?: Bounds, mousePosition?: Position | null): number;
|
|
9
|
+
export declare function angleToOffsetRatios(angleDeg: number): {
|
|
10
|
+
ratioX: number;
|
|
11
|
+
ratioY: number;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Calculates shadow layers based on elevation level.
|
|
15
|
+
* Uses the powers-of-2 technique from Tobias Ahlin.
|
|
16
|
+
*
|
|
17
|
+
* @param elevation - Value from -1 (inner shadow) to 1 (drop shadow)
|
|
18
|
+
* @param lightAngle - Angle of light source in degrees
|
|
19
|
+
* @param intensity - Overall intensity multiplier
|
|
20
|
+
*/
|
|
21
|
+
export declare function calculateShadowLayers(elevation: number, lightAngle?: number, intensity?: number): ShadowLayer[];
|
|
22
|
+
export declare function lerp(start: number, end: number, t: number): number;
|
|
23
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
24
|
+
export declare function smoothPosition(current: Position, target: Position, smoothing: number): Position;
|
|
25
|
+
//# sourceMappingURL=calculations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculations.d.ts","sourceRoot":"","sources":["../../src/core/calculations.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,eAAe,EACf,QAAQ,EACR,MAAM,EACP,MAAM,SAAS,CAAC;AAMjB,eAAO,MAAM,UAAU,IAAI,CAAC;AAC5B,eAAO,MAAM,YAAY,QAAQ,CAAC;AAClC,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAM1C,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,GAAG,WAAW,CAgBrF;AAED,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,WAAW,EACxB,aAAa,CAAC,EAAE,MAAM,EACtB,aAAa,CAAC,EAAE,QAAQ,GAAG,IAAI,GAC9B,MAAM,CAiCR;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAMxF;AAMD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,UAAU,GAAE,MAA4B,EACxC,SAAS,GAAE,MAAU,GACpB,WAAW,EAAE,CA0Cf;AAMD,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAElE;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAErE;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,QAAQ,CAK/F"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lifted - Color Utilities
|
|
3
|
+
*
|
|
4
|
+
* Functions for parsing colors and calculating shadow colors
|
|
5
|
+
* based on Josh Comeau's "Goldilocks color" technique.
|
|
6
|
+
*/
|
|
7
|
+
export interface HSL {
|
|
8
|
+
h: number;
|
|
9
|
+
s: number;
|
|
10
|
+
l: number;
|
|
11
|
+
}
|
|
12
|
+
export interface RGB {
|
|
13
|
+
r: number;
|
|
14
|
+
g: number;
|
|
15
|
+
b: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function parseColor(color: string): HSL | null;
|
|
18
|
+
export declare function hexToHSL(hex: string): HSL;
|
|
19
|
+
export declare function rgbToHSL({ r, g, b }: RGB): HSL;
|
|
20
|
+
export declare function calculateShadowColor(background: string, isDarkMode?: boolean): string;
|
|
21
|
+
export declare function generateLayerColor(baseColor: string, opacity: number): string;
|
|
22
|
+
export declare function isLightColor(color: string): boolean;
|
|
23
|
+
//# sourceMappingURL=color.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/core/color.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,WAAW,GAAG;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,GAAG;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,IAAI,CAyBpD;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAczC;AAED,wBAAgB,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,GAAG,GAAG,CAiC9C;AAMD,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,GAAE,OAAe,GAAG,MAAM,CAgB5F;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAQ7E;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGnD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ShadowLayerWithColor, ShadowOptions, ShadowResult, Bounds, Position } from './types';
|
|
2
|
+
|
|
3
|
+
export declare function generateShadow(options: ShadowOptions, elementBounds?: Bounds, mousePosition?: Position | null): ShadowResult;
|
|
4
|
+
export declare function generateBoxShadow(elevation: number, options?: Partial<Omit<ShadowOptions, 'elevation'>>): string;
|
|
5
|
+
export declare function layersToCSS(layers: ShadowLayerWithColor[]): string;
|
|
6
|
+
export declare const ELEVATION_PRESETS: {
|
|
7
|
+
readonly deepInset: -0.75;
|
|
8
|
+
readonly inset: -0.3;
|
|
9
|
+
readonly none: 0;
|
|
10
|
+
readonly subtle: 0.15;
|
|
11
|
+
readonly small: 0.25;
|
|
12
|
+
readonly medium: 0.5;
|
|
13
|
+
readonly large: 0.75;
|
|
14
|
+
readonly xlarge: 1;
|
|
15
|
+
};
|
|
16
|
+
export type ElevationPreset = keyof typeof ELEVATION_PRESETS;
|
|
17
|
+
export declare function resolveElevation(value: number | ElevationPreset): number;
|
|
18
|
+
export declare function generateStyleObject(options: ShadowOptions, elementBounds?: Bounds, mousePosition?: Position | null): React.CSSProperties;
|
|
19
|
+
export declare const DEFAULT_SHADOW_TRANSITION = "box-shadow 150ms cubic-bezier(0.2, 0.6, 0.3, 1)";
|
|
20
|
+
export declare function generateTransition(durationMs?: number, includeTransform?: boolean): string;
|
|
21
|
+
//# sourceMappingURL=css-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-generator.d.ts","sourceRoot":"","sources":["../../src/core/css-generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAEV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,MAAM,EACN,QAAQ,EACT,MAAM,SAAS,CAAC;AAiBjB,wBAAgB,cAAc,CAC5B,OAAO,EAAE,aAAa,EACtB,aAAa,CAAC,EAAE,MAAM,EACtB,aAAa,CAAC,EAAE,QAAQ,GAAG,IAAI,GAC9B,YAAY,CAgCd;AAED,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,CAAM,GACtD,MAAM,CAGR;AAaD,wBAAgB,WAAW,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAoBlE;AA+BD,eAAO,MAAM,iBAAiB;;;;;;;;;CASpB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAE7D,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,GAAG,MAAM,CAKxE;AAMD,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,aAAa,EACtB,aAAa,CAAC,EAAE,MAAM,EACtB,aAAa,CAAC,EAAE,QAAQ,GAAG,IAAI,GAC9B,KAAK,CAAC,aAAa,CAYrB;AAED,eAAO,MAAM,yBAAyB,oDAAoD,CAAC;AAE3F,wBAAgB,kBAAkB,CAAC,UAAU,GAAE,MAAY,EAAE,gBAAgB,GAAE,OAAe,GAAG,MAAM,CAStG"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lifted - Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Represents a single shadow layer in the layered shadow system.
|
|
6
|
+
*/
|
|
7
|
+
export interface ShadowLayer {
|
|
8
|
+
/** Horizontal offset in pixels */
|
|
9
|
+
offsetX: number;
|
|
10
|
+
/** Vertical offset in pixels */
|
|
11
|
+
offsetY: number;
|
|
12
|
+
/** Blur radius in pixels */
|
|
13
|
+
blur: number;
|
|
14
|
+
/** Spread radius in pixels (usually 0 for realistic shadows) */
|
|
15
|
+
spread: number;
|
|
16
|
+
/** Opacity of this layer (0-1) */
|
|
17
|
+
opacity: number;
|
|
18
|
+
/** Whether this is an inner (inset) shadow */
|
|
19
|
+
inset?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Complete shadow configuration including color.
|
|
23
|
+
*/
|
|
24
|
+
export interface ShadowLayerWithColor extends ShadowLayer {
|
|
25
|
+
/** Shadow color in any CSS color format */
|
|
26
|
+
color: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Static light source with a fixed angle.
|
|
30
|
+
*/
|
|
31
|
+
export interface StaticLightSource {
|
|
32
|
+
type: 'static';
|
|
33
|
+
/** Angle in degrees (-180 to 180, where -45 is top-left) */
|
|
34
|
+
angle: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Mouse-following light source.
|
|
38
|
+
*/
|
|
39
|
+
export interface MouseLightSource {
|
|
40
|
+
type: 'mouse';
|
|
41
|
+
/** Smoothing factor for mouse movement (0-1, lower = smoother) */
|
|
42
|
+
smoothing?: number;
|
|
43
|
+
/** Maximum angle deviation from center */
|
|
44
|
+
maxAngle?: number;
|
|
45
|
+
/** Fallback angle when mouse position is unavailable */
|
|
46
|
+
fallbackAngle?: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Custom light source controlled by external value.
|
|
50
|
+
*/
|
|
51
|
+
export interface CustomLightSource {
|
|
52
|
+
type: 'custom';
|
|
53
|
+
/** Current angle value */
|
|
54
|
+
angle: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Union of all light source types.
|
|
58
|
+
*/
|
|
59
|
+
export type LightSource = StaticLightSource | MouseLightSource | CustomLightSource;
|
|
60
|
+
/**
|
|
61
|
+
* Shorthand light source prop type.
|
|
62
|
+
* Can be a number (static angle), 'mouse', or full configuration.
|
|
63
|
+
*/
|
|
64
|
+
export type LightSourceProp = number | 'mouse' | LightSource;
|
|
65
|
+
/**
|
|
66
|
+
* Props for the LiftedBox React component.
|
|
67
|
+
*/
|
|
68
|
+
export interface LiftedBoxProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {
|
|
69
|
+
/**
|
|
70
|
+
* Elevation level from -1 (maximum inner shadow) to 1 (maximum drop shadow).
|
|
71
|
+
* - Negative values create inset/inner shadows (pressed effect)
|
|
72
|
+
* - Zero means no shadow
|
|
73
|
+
* - Positive values create drop shadows (raised effect)
|
|
74
|
+
* @default 0.3
|
|
75
|
+
*/
|
|
76
|
+
elevation?: number;
|
|
77
|
+
/**
|
|
78
|
+
* HTML element to render as.
|
|
79
|
+
* @default 'div'
|
|
80
|
+
*/
|
|
81
|
+
as?: keyof JSX.IntrinsicElements;
|
|
82
|
+
/**
|
|
83
|
+
* Light source configuration.
|
|
84
|
+
* @default -45 (top-left)
|
|
85
|
+
*/
|
|
86
|
+
lightSource?: LightSourceProp;
|
|
87
|
+
/**
|
|
88
|
+
* Background color. Used for automatic shadow color calculation.
|
|
89
|
+
*/
|
|
90
|
+
background?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Manual shadow color override.
|
|
93
|
+
*/
|
|
94
|
+
shadowColor?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Shadow color for dark mode (when using auto-detect).
|
|
97
|
+
*/
|
|
98
|
+
shadowColorDark?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Shadow intensity multiplier.
|
|
101
|
+
* @default 1
|
|
102
|
+
*/
|
|
103
|
+
intensity?: number;
|
|
104
|
+
/**
|
|
105
|
+
* Whether to animate shadow changes.
|
|
106
|
+
* @default true
|
|
107
|
+
*/
|
|
108
|
+
animated?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Transition duration in milliseconds.
|
|
111
|
+
* @default 150
|
|
112
|
+
*/
|
|
113
|
+
transitionDuration?: number;
|
|
114
|
+
/**
|
|
115
|
+
* Children elements.
|
|
116
|
+
*/
|
|
117
|
+
children?: React.ReactNode;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Global configuration for Lifted.
|
|
121
|
+
*/
|
|
122
|
+
export interface LiftedConfig {
|
|
123
|
+
/** Whether to automatically detect dark mode */
|
|
124
|
+
autoDetectDarkMode?: boolean;
|
|
125
|
+
/** Default elevation for all components */
|
|
126
|
+
defaultElevation?: number;
|
|
127
|
+
/** Default light source for all components */
|
|
128
|
+
defaultLightSource?: LightSourceProp;
|
|
129
|
+
/** Color scheme override ('light' | 'dark' | 'auto') */
|
|
130
|
+
colorScheme?: 'light' | 'dark' | 'auto';
|
|
131
|
+
/** Disable all transitions */
|
|
132
|
+
disableTransitions?: boolean;
|
|
133
|
+
/** Custom color mapping function */
|
|
134
|
+
customColorMapping?: (background: string, isDark: boolean) => string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Context value for LiftedProvider.
|
|
138
|
+
*/
|
|
139
|
+
export interface LiftedContextValue extends LiftedConfig {
|
|
140
|
+
/** Current dark mode state */
|
|
141
|
+
isDarkMode: boolean;
|
|
142
|
+
/** Current mouse position (if tracking) */
|
|
143
|
+
mousePosition: Position | null;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Options for vanilla JS initialization.
|
|
147
|
+
*/
|
|
148
|
+
export interface VanillaLiftedBoxOptions {
|
|
149
|
+
elevation?: number;
|
|
150
|
+
lightSource?: LightSourceProp;
|
|
151
|
+
background?: string;
|
|
152
|
+
shadowColor?: string;
|
|
153
|
+
shadowColorDark?: string;
|
|
154
|
+
intensity?: number;
|
|
155
|
+
animated?: boolean;
|
|
156
|
+
transitionDuration?: number;
|
|
157
|
+
isDarkMode?: boolean;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Instance returned by vanilla JS initialization.
|
|
161
|
+
*/
|
|
162
|
+
export interface VanillaLiftedBoxInstance {
|
|
163
|
+
/** Update the elevation */
|
|
164
|
+
setElevation: (elevation: number) => void;
|
|
165
|
+
/** Update the light source */
|
|
166
|
+
setLightSource: (source: LightSourceProp) => void;
|
|
167
|
+
/** Update multiple options */
|
|
168
|
+
update: (options: Partial<VanillaLiftedBoxOptions>) => void;
|
|
169
|
+
/** Get current shadow CSS */
|
|
170
|
+
getShadowCSS: () => string;
|
|
171
|
+
/** Remove all shadow styling and cleanup */
|
|
172
|
+
destroy: () => void;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Position with x and y coordinates.
|
|
176
|
+
*/
|
|
177
|
+
export interface Position {
|
|
178
|
+
x: number;
|
|
179
|
+
y: number;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Element bounds.
|
|
183
|
+
*/
|
|
184
|
+
export interface Bounds {
|
|
185
|
+
x: number;
|
|
186
|
+
y: number;
|
|
187
|
+
width: number;
|
|
188
|
+
height: number;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Shadow generation options.
|
|
192
|
+
*/
|
|
193
|
+
export interface ShadowOptions {
|
|
194
|
+
/**
|
|
195
|
+
* Elevation level from -1 (maximum inner shadow) to 1 (maximum drop shadow).
|
|
196
|
+
* @default 0.3
|
|
197
|
+
*/
|
|
198
|
+
elevation?: number;
|
|
199
|
+
lightSource?: LightSourceProp;
|
|
200
|
+
background?: string;
|
|
201
|
+
shadowColor?: string;
|
|
202
|
+
shadowColorDark?: string;
|
|
203
|
+
intensity?: number;
|
|
204
|
+
isDarkMode?: boolean;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Result of shadow generation.
|
|
208
|
+
*/
|
|
209
|
+
export interface ShadowResult {
|
|
210
|
+
/** Calculated shadow layers */
|
|
211
|
+
layers: ShadowLayerWithColor[];
|
|
212
|
+
/** CSS box-shadow string */
|
|
213
|
+
boxShadow: string;
|
|
214
|
+
/** CSS custom properties */
|
|
215
|
+
cssVariables: Record<string, string>;
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";function b(t){return t===void 0?{type:"static",angle:-45}:typeof t=="number"?{type:"static",angle:t}:t==="mouse"?{type:"mouse",smoothing:.1,maxAngle:30,fallbackAngle:-45}:t}function p(t,n,e){switch(t.type){case"static":case"custom":return t.angle;case"mouse":{if(!e||!n)return t.fallbackAngle??-45;const a=n.x+n.width/2,o=n.y+n.height/2,i=e.x-a,l=e.y-o;let r=Math.atan2(l,i)*(180/Math.PI)+180;const c=t.maxAngle??30,h=t.fallbackAngle??-45;let s=r-h;for(;s>180;)s-=360;for(;s<-180;)s+=360;return s=Math.max(-c,Math.min(c,s)),h+s}default:return-45}}function m(t){const n=t*(Math.PI/180);return{ratioX:Math.cos(n),ratioY:Math.sin(n)}}function M(t,n=-45,e=1){const a=Math.max(-1,Math.min(1,t));if(a===0)return[];const o=a<0,l=Math.abs(a)*5,{ratioX:f,ratioY:r}=m(n),c=o?-1:1,h=[];for(let s=0;s<5;s++){const A=s+1,u=Math.pow(2,s);if(A<=l)h.push({offsetX:u*f*e*c,offsetY:u*r*e*c,blur:u*e,spread:0,opacity:.075*e,inset:o});else if(A-1<l){const L=l-(A-1);h.push({offsetX:u*f*L*e*c,offsetY:u*r*L*e*c,blur:u*L*e,spread:0,opacity:.075*L*e,inset:o})}}return h}function _(t,n,e){return t+(n-t)*e}function G(t,n,e){return{x:_(t.x,n.x,e),y:_(t.y,n.y,e)}}function g(t){if(t.match(/^#([0-9a-f]{3,8})$/i))return I(t);const e=t.match(/^hsl\(\s*([\d.]+)\s*,?\s*([\d.]+)%?\s*,?\s*([\d.]+)%?\s*\)/i);if(e)return{h:parseFloat(e[1]),s:parseFloat(e[2]),l:parseFloat(e[3])};const a=t.match(/^rgb\(\s*([\d.]+)\s*,?\s*([\d.]+)\s*,?\s*([\d.]+)\s*\)/i);return a?E({r:parseFloat(a[1]),g:parseFloat(a[2]),b:parseFloat(a[3])}):null}function I(t){let n=0,e=0,a=0;return t.length===4?(n=parseInt(t[1]+t[1],16),e=parseInt(t[2]+t[2],16),a=parseInt(t[3]+t[3],16)):t.length>=7&&(n=parseInt(t.slice(1,3),16),e=parseInt(t.slice(3,5),16),a=parseInt(t.slice(5,7),16)),E({r:n,g:e,b:a})}function E({r:t,g:n,b:e}){t/=255,n/=255,e/=255;const a=Math.max(t,n,e),o=Math.min(t,n,e);let i=0,l=0;const f=(a+o)/2;if(a!==o){const r=a-o;switch(l=f>.5?r/(2-a-o):r/(a+o),a){case t:i=((n-e)/r+(n<e?6:0))/6;break;case n:i=((e-t)/r+2)/6;break;case e:i=((t-n)/r+4)/6;break}}return{h:Math.round(i*360),s:Math.round(l*100),l:Math.round(f*100)}}function w(t,n=!1){const e=g(t);if(!e)return n?"hsl(0 0% 100% / 0.1)":"hsl(220 3% 15%)";if(n){const a=Math.max(0,e.s-20),o=Math.min(100,e.l+30);return`hsl(${e.h} ${a}% ${o}%)`}else{const a=Math.max(0,e.s*.6),o=Math.max(10,e.l*.5);return`hsl(${e.h} ${a}% ${o}%)`}}function $(t,n){const e=g(t);return e?`hsl(${e.h} ${e.s}% ${e.l}% / ${n})`:`hsl(220 3% 15% / ${n})`}function F(t){const n=g(t);return n?n.l>50:!0}function S(t,n,e){const{elevation:a=.3,lightSource:o,background:i,shadowColor:l,shadowColorDark:f,intensity:r=1,isDarkMode:c=!1}=t,h=b(o),s=p(h,n,e),A=M(a,s,r);let u;l?u=l:c&&f?u=f:i?u=w(i,c):u=c?"hsl(0 0% 100% / 0.1)":"hsl(220 3% 15%)";const L=D(A,u),x=T(L),y=N(L,a,s);return{layers:L,boxShadow:x,cssVariables:y}}function O(t,n={}){return S({elevation:t,...n}).boxShadow}function D(t,n){return t.map(e=>({...e,color:$(n,e.opacity)}))}function T(t){return t.length===0?"none":t.map(n=>{const{offsetX:e,offsetY:a,blur:o,spread:i,color:l,inset:f}=n,r=d(e),c=d(a),h=d(o),s=d(i),A=f?"inset ":"";return i===0?`${A}${r} ${c} ${h} ${l}`:`${A}${r} ${c} ${h} ${s} ${l}`}).join(`,
|
|
2
|
+
`)}function d(t){return t===0?"0":`${Math.round(t*100)/100}px`}function N(t,n,e){return{"--lifted-elevation":n.toString(),"--lifted-light-angle":`${e}deg`,"--lifted-layers":t.length.toString(),"--lifted-shadow":T(t)}}const C={deepInset:-.75,inset:-.3,none:0,subtle:.15,small:.25,medium:.5,large:.75,xlarge:1};function U(t){return typeof t=="number"?t:C[t]}function Y(t,n,e){const o={boxShadow:S(t,n,e).boxShadow};return t.background&&(o.backgroundColor=t.background),o}const H="box-shadow 150ms cubic-bezier(0.2, 0.6, 0.3, 1)";function X(t=150,n=!1){const e="cubic-bezier(0.2, 0.6, 0.3, 1)",a=[`box-shadow ${t}ms ${e}`];return n&&a.push(`transform ${t}ms ${e}`),a.join(", ")}exports.BASE_OPACITY=.075;exports.DEFAULT_LIGHT_ANGLE=-45;exports.DEFAULT_SHADOW_TRANSITION=H;exports.ELEVATION_PRESETS=C;exports.MAX_LAYERS=5;exports.angleToOffsetRatios=m;exports.calculateLightAngle=p;exports.calculateShadowColor=w;exports.calculateShadowLayers=M;exports.generateBoxShadow=O;exports.generateLayerColor=$;exports.generateShadow=S;exports.generateStyleObject=Y;exports.generateTransition=X;exports.hexToHSL=I;exports.isLightColor=F;exports.layersToCSS=T;exports.normalizeLightSource=b;exports.parseColor=g;exports.resolveElevation=U;exports.rgbToHSL=E;exports.smoothPosition=G;
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
const D = 5, U = 0.075, k = -45;
|
|
2
|
+
function M(t) {
|
|
3
|
+
return t === void 0 ? { type: "static", angle: -45 } : typeof t == "number" ? { type: "static", angle: t } : t === "mouse" ? {
|
|
4
|
+
type: "mouse",
|
|
5
|
+
smoothing: 0.1,
|
|
6
|
+
maxAngle: 30,
|
|
7
|
+
fallbackAngle: -45
|
|
8
|
+
} : t;
|
|
9
|
+
}
|
|
10
|
+
function T(t, e, n) {
|
|
11
|
+
switch (t.type) {
|
|
12
|
+
case "static":
|
|
13
|
+
case "custom":
|
|
14
|
+
return t.angle;
|
|
15
|
+
case "mouse": {
|
|
16
|
+
if (!n || !e)
|
|
17
|
+
return t.fallbackAngle ?? -45;
|
|
18
|
+
const s = e.x + e.width / 2, a = e.y + e.height / 2, i = n.x - s, l = n.y - a;
|
|
19
|
+
let r = Math.atan2(l, i) * (180 / Math.PI) + 180;
|
|
20
|
+
const c = t.maxAngle ?? 30, h = t.fallbackAngle ?? -45;
|
|
21
|
+
let o = r - h;
|
|
22
|
+
for (; o > 180; ) o -= 360;
|
|
23
|
+
for (; o < -180; ) o += 360;
|
|
24
|
+
return o = Math.max(-c, Math.min(c, o)), h + o;
|
|
25
|
+
}
|
|
26
|
+
default:
|
|
27
|
+
return -45;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function $(t) {
|
|
31
|
+
const e = t * (Math.PI / 180);
|
|
32
|
+
return {
|
|
33
|
+
ratioX: Math.cos(e),
|
|
34
|
+
ratioY: Math.sin(e)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function w(t, e = -45, n = 1) {
|
|
38
|
+
const s = Math.max(-1, Math.min(1, t));
|
|
39
|
+
if (s === 0)
|
|
40
|
+
return [];
|
|
41
|
+
const a = s < 0, l = Math.abs(s) * 5, { ratioX: u, ratioY: r } = $(e), c = a ? -1 : 1, h = [];
|
|
42
|
+
for (let o = 0; o < 5; o++) {
|
|
43
|
+
const d = o + 1, f = Math.pow(2, o);
|
|
44
|
+
if (d <= l)
|
|
45
|
+
h.push({
|
|
46
|
+
offsetX: f * u * n * c,
|
|
47
|
+
offsetY: f * r * n * c,
|
|
48
|
+
blur: f * n,
|
|
49
|
+
spread: 0,
|
|
50
|
+
opacity: 0.075 * n,
|
|
51
|
+
inset: a
|
|
52
|
+
});
|
|
53
|
+
else if (d - 1 < l) {
|
|
54
|
+
const A = l - (d - 1);
|
|
55
|
+
h.push({
|
|
56
|
+
offsetX: f * u * A * n * c,
|
|
57
|
+
offsetY: f * r * A * n * c,
|
|
58
|
+
blur: f * A * n,
|
|
59
|
+
spread: 0,
|
|
60
|
+
opacity: 0.075 * A * n,
|
|
61
|
+
inset: a
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return h;
|
|
66
|
+
}
|
|
67
|
+
function p(t, e, n) {
|
|
68
|
+
return t + (e - t) * n;
|
|
69
|
+
}
|
|
70
|
+
function N(t, e, n) {
|
|
71
|
+
return {
|
|
72
|
+
x: p(t.x, e.x, n),
|
|
73
|
+
y: p(t.y, e.y, n)
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function L(t) {
|
|
77
|
+
if (t.match(/^#([0-9a-f]{3,8})$/i))
|
|
78
|
+
return I(t);
|
|
79
|
+
const n = t.match(/^hsl\(\s*([\d.]+)\s*,?\s*([\d.]+)%?\s*,?\s*([\d.]+)%?\s*\)/i);
|
|
80
|
+
if (n)
|
|
81
|
+
return {
|
|
82
|
+
h: parseFloat(n[1]),
|
|
83
|
+
s: parseFloat(n[2]),
|
|
84
|
+
l: parseFloat(n[3])
|
|
85
|
+
};
|
|
86
|
+
const s = t.match(/^rgb\(\s*([\d.]+)\s*,?\s*([\d.]+)\s*,?\s*([\d.]+)\s*\)/i);
|
|
87
|
+
return s ? E({
|
|
88
|
+
r: parseFloat(s[1]),
|
|
89
|
+
g: parseFloat(s[2]),
|
|
90
|
+
b: parseFloat(s[3])
|
|
91
|
+
}) : null;
|
|
92
|
+
}
|
|
93
|
+
function I(t) {
|
|
94
|
+
let e = 0, n = 0, s = 0;
|
|
95
|
+
return t.length === 4 ? (e = parseInt(t[1] + t[1], 16), n = parseInt(t[2] + t[2], 16), s = parseInt(t[3] + t[3], 16)) : t.length >= 7 && (e = parseInt(t.slice(1, 3), 16), n = parseInt(t.slice(3, 5), 16), s = parseInt(t.slice(5, 7), 16)), E({ r: e, g: n, b: s });
|
|
96
|
+
}
|
|
97
|
+
function E({ r: t, g: e, b: n }) {
|
|
98
|
+
t /= 255, e /= 255, n /= 255;
|
|
99
|
+
const s = Math.max(t, e, n), a = Math.min(t, e, n);
|
|
100
|
+
let i = 0, l = 0;
|
|
101
|
+
const u = (s + a) / 2;
|
|
102
|
+
if (s !== a) {
|
|
103
|
+
const r = s - a;
|
|
104
|
+
switch (l = u > 0.5 ? r / (2 - s - a) : r / (s + a), s) {
|
|
105
|
+
case t:
|
|
106
|
+
i = ((e - n) / r + (e < n ? 6 : 0)) / 6;
|
|
107
|
+
break;
|
|
108
|
+
case e:
|
|
109
|
+
i = ((n - t) / r + 2) / 6;
|
|
110
|
+
break;
|
|
111
|
+
case n:
|
|
112
|
+
i = ((t - e) / r + 4) / 6;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
h: Math.round(i * 360),
|
|
118
|
+
s: Math.round(l * 100),
|
|
119
|
+
l: Math.round(u * 100)
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function x(t, e = !1) {
|
|
123
|
+
const n = L(t);
|
|
124
|
+
if (!n)
|
|
125
|
+
return e ? "hsl(0 0% 100% / 0.1)" : "hsl(220 3% 15%)";
|
|
126
|
+
if (e) {
|
|
127
|
+
const s = Math.max(0, n.s - 20), a = Math.min(100, n.l + 30);
|
|
128
|
+
return `hsl(${n.h} ${s}% ${a}%)`;
|
|
129
|
+
} else {
|
|
130
|
+
const s = Math.max(0, n.s * 0.6), a = Math.max(10, n.l * 0.5);
|
|
131
|
+
return `hsl(${n.h} ${s}% ${a}%)`;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function y(t, e) {
|
|
135
|
+
const n = L(t);
|
|
136
|
+
return n ? `hsl(${n.h} ${n.s}% ${n.l}% / ${e})` : `hsl(220 3% 15% / ${e})`;
|
|
137
|
+
}
|
|
138
|
+
function O(t) {
|
|
139
|
+
const e = L(t);
|
|
140
|
+
return e ? e.l > 50 : !0;
|
|
141
|
+
}
|
|
142
|
+
function b(t, e, n) {
|
|
143
|
+
const {
|
|
144
|
+
elevation: s = 0.3,
|
|
145
|
+
lightSource: a,
|
|
146
|
+
background: i,
|
|
147
|
+
shadowColor: l,
|
|
148
|
+
shadowColorDark: u,
|
|
149
|
+
intensity: r = 1,
|
|
150
|
+
isDarkMode: c = !1
|
|
151
|
+
} = t, h = M(a), o = T(h, e, n), d = w(s, o, r);
|
|
152
|
+
let f;
|
|
153
|
+
l ? f = l : c && u ? f = u : i ? f = x(i, c) : f = c ? "hsl(0 0% 100% / 0.1)" : "hsl(220 3% 15%)";
|
|
154
|
+
const A = C(d, f), S = m(A), _ = F(A, s, o);
|
|
155
|
+
return { layers: A, boxShadow: S, cssVariables: _ };
|
|
156
|
+
}
|
|
157
|
+
function X(t, e = {}) {
|
|
158
|
+
return b({ elevation: t, ...e }).boxShadow;
|
|
159
|
+
}
|
|
160
|
+
function C(t, e) {
|
|
161
|
+
return t.map((n) => ({
|
|
162
|
+
...n,
|
|
163
|
+
color: y(e, n.opacity)
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
166
|
+
function m(t) {
|
|
167
|
+
return t.length === 0 ? "none" : t.map((e) => {
|
|
168
|
+
const { offsetX: n, offsetY: s, blur: a, spread: i, color: l, inset: u } = e, r = g(n), c = g(s), h = g(a), o = g(i), d = u ? "inset " : "";
|
|
169
|
+
return i === 0 ? `${d}${r} ${c} ${h} ${l}` : `${d}${r} ${c} ${h} ${o} ${l}`;
|
|
170
|
+
}).join(`,
|
|
171
|
+
`);
|
|
172
|
+
}
|
|
173
|
+
function g(t) {
|
|
174
|
+
return t === 0 ? "0" : `${Math.round(t * 100) / 100}px`;
|
|
175
|
+
}
|
|
176
|
+
function F(t, e, n) {
|
|
177
|
+
return {
|
|
178
|
+
"--lifted-elevation": e.toString(),
|
|
179
|
+
"--lifted-light-angle": `${n}deg`,
|
|
180
|
+
"--lifted-layers": t.length.toString(),
|
|
181
|
+
"--lifted-shadow": m(t)
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
const G = {
|
|
185
|
+
deepInset: -0.75,
|
|
186
|
+
inset: -0.3,
|
|
187
|
+
none: 0,
|
|
188
|
+
subtle: 0.15,
|
|
189
|
+
small: 0.25,
|
|
190
|
+
medium: 0.5,
|
|
191
|
+
large: 0.75,
|
|
192
|
+
xlarge: 1
|
|
193
|
+
};
|
|
194
|
+
function Y(t) {
|
|
195
|
+
return typeof t == "number" ? t : G[t];
|
|
196
|
+
}
|
|
197
|
+
function H(t, e, n) {
|
|
198
|
+
const a = {
|
|
199
|
+
boxShadow: b(t, e, n).boxShadow
|
|
200
|
+
};
|
|
201
|
+
return t.background && (a.backgroundColor = t.background), a;
|
|
202
|
+
}
|
|
203
|
+
const v = "box-shadow 150ms cubic-bezier(0.2, 0.6, 0.3, 1)";
|
|
204
|
+
function R(t = 150, e = !1) {
|
|
205
|
+
const n = "cubic-bezier(0.2, 0.6, 0.3, 1)", s = [`box-shadow ${t}ms ${n}`];
|
|
206
|
+
return e && s.push(`transform ${t}ms ${n}`), s.join(", ");
|
|
207
|
+
}
|
|
208
|
+
export {
|
|
209
|
+
U as B,
|
|
210
|
+
k as D,
|
|
211
|
+
G as E,
|
|
212
|
+
D as M,
|
|
213
|
+
R as a,
|
|
214
|
+
x as b,
|
|
215
|
+
T as c,
|
|
216
|
+
w as d,
|
|
217
|
+
X as e,
|
|
218
|
+
v as f,
|
|
219
|
+
b as g,
|
|
220
|
+
$ as h,
|
|
221
|
+
O as i,
|
|
222
|
+
y as j,
|
|
223
|
+
H as k,
|
|
224
|
+
m as l,
|
|
225
|
+
I as m,
|
|
226
|
+
M as n,
|
|
227
|
+
E as o,
|
|
228
|
+
L as p,
|
|
229
|
+
Y as r,
|
|
230
|
+
N as s
|
|
231
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lifted - Main Entry Point
|
|
3
|
+
*
|
|
4
|
+
* Beautiful, realistic CSS shadows with layered depth.
|
|
5
|
+
*/
|
|
6
|
+
export { generateShadow, generateBoxShadow, layersToCSS, ELEVATION_PRESETS, resolveElevation, generateStyleObject, generateTransition, DEFAULT_SHADOW_TRANSITION, } from './core/css-generator';
|
|
7
|
+
export { calculateShadowLayers, calculateLightAngle, normalizeLightSource, angleToOffsetRatios, MAX_LAYERS, BASE_OPACITY, DEFAULT_LIGHT_ANGLE, } from './core/calculations';
|
|
8
|
+
export { calculateShadowColor, parseColor, hexToHSL, rgbToHSL, isLightColor, generateLayerColor, } from './core/color';
|
|
9
|
+
export type { ShadowLayer, ShadowLayerWithColor, ShadowOptions, ShadowResult, LightSource, LightSourceProp, StaticLightSource, MouseLightSource, CustomLightSource, Position, Bounds, LiftedBoxProps, LiftedConfig, LiftedContextValue, VanillaLiftedBoxOptions, VanillaLiftedBoxInstance, } from './core/types';
|
|
10
|
+
export type { ElevationPreset } from './core/css-generator';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,YAAY,EACZ,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,oBAAoB,EACpB,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAGtB,YAAY,EACV,WAAW,EACX,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,MAAM,EACN,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,cAAc,CAAC;AAEtB,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { B as s, D as o, f as r, E as l, M as t, h as S, c as L, b as T, d as g, e as n, j as A, g as E, k as i, a as c, m as h, i as _, l as C, n as O, p as d, r as I, o as f } from "./index-G-GHoQdJ.js";
|
|
2
|
+
export {
|
|
3
|
+
s as BASE_OPACITY,
|
|
4
|
+
o as DEFAULT_LIGHT_ANGLE,
|
|
5
|
+
r as DEFAULT_SHADOW_TRANSITION,
|
|
6
|
+
l as ELEVATION_PRESETS,
|
|
7
|
+
t as MAX_LAYERS,
|
|
8
|
+
S as angleToOffsetRatios,
|
|
9
|
+
L as calculateLightAngle,
|
|
10
|
+
T as calculateShadowColor,
|
|
11
|
+
g as calculateShadowLayers,
|
|
12
|
+
n as generateBoxShadow,
|
|
13
|
+
A as generateLayerColor,
|
|
14
|
+
E as generateShadow,
|
|
15
|
+
i as generateStyleObject,
|
|
16
|
+
c as generateTransition,
|
|
17
|
+
h as hexToHSL,
|
|
18
|
+
_ as isLightColor,
|
|
19
|
+
C as layersToCSS,
|
|
20
|
+
O as normalizeLightSource,
|
|
21
|
+
d as parseColor,
|
|
22
|
+
I as resolveElevation,
|
|
23
|
+
f as rgbToHSL
|
|
24
|
+
};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-4W01YOTU.cjs");exports.BASE_OPACITY=e.BASE_OPACITY;exports.DEFAULT_LIGHT_ANGLE=e.DEFAULT_LIGHT_ANGLE;exports.DEFAULT_SHADOW_TRANSITION=e.DEFAULT_SHADOW_TRANSITION;exports.ELEVATION_PRESETS=e.ELEVATION_PRESETS;exports.MAX_LAYERS=e.MAX_LAYERS;exports.angleToOffsetRatios=e.angleToOffsetRatios;exports.calculateLightAngle=e.calculateLightAngle;exports.calculateShadowColor=e.calculateShadowColor;exports.calculateShadowLayers=e.calculateShadowLayers;exports.generateBoxShadow=e.generateBoxShadow;exports.generateLayerColor=e.generateLayerColor;exports.generateShadow=e.generateShadow;exports.generateStyleObject=e.generateStyleObject;exports.generateTransition=e.generateTransition;exports.hexToHSL=e.hexToHSL;exports.isLightColor=e.isLightColor;exports.layersToCSS=e.layersToCSS;exports.normalizeLightSource=e.normalizeLightSource;exports.parseColor=e.parseColor;exports.resolveElevation=e.resolveElevation;exports.rgbToHSL=e.rgbToHSL;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { LiftedBoxProps } from '../core/types';
|
|
3
|
+
|
|
4
|
+
export declare const LiftedBox: React.ForwardRefExoticComponent<LiftedBoxProps & React.RefAttributes<HTMLElement>>;
|
|
5
|
+
export declare const LiftedCard: React.ForwardRefExoticComponent<Omit<LiftedBoxProps, "elevation"> & React.RefAttributes<HTMLElement>>;
|
|
6
|
+
export declare const LiftedButton: React.ForwardRefExoticComponent<Omit<LiftedBoxProps, "as"> & React.RefAttributes<HTMLElement>>;
|
|
7
|
+
export declare const LiftedModal: React.ForwardRefExoticComponent<Omit<LiftedBoxProps, "elevation"> & React.RefAttributes<HTMLElement>>;
|
|
8
|
+
export default LiftedBox;
|
|
9
|
+
//# sourceMappingURL=LiftedBox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LiftedBox.d.ts","sourceRoot":"","sources":["../../src/react/LiftedBox.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAA2D,MAAM,OAAO,CAAC;AAEhF,OAAO,KAAK,EAAE,cAAc,EAAoB,MAAM,eAAe,CAAC;AAStE,eAAO,MAAM,SAAS,oFAwHrB,CAAC;AAQF,eAAO,MAAM,UAAU,uGAEtB,CAAC;AAGF,eAAO,MAAM,YAAY,gGAIxB,CAAC;AAGF,eAAO,MAAM,WAAW,uGAEvB,CAAC;AAGF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { LiftedConfig, LiftedContextValue } from '../core/types';
|
|
3
|
+
|
|
4
|
+
export declare function useLiftedContext(): LiftedContextValue | null;
|
|
5
|
+
export declare function useLifted(): LiftedContextValue;
|
|
6
|
+
export interface LiftedProviderProps extends LiftedConfig {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare function LiftedProvider({ children, autoDetectDarkMode, defaultElevation, defaultLightSource, colorScheme, disableTransitions, customColorMapping, }: LiftedProviderProps): React.ReactElement;
|
|
10
|
+
export default LiftedProvider;
|
|
11
|
+
//# sourceMappingURL=LiftedProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LiftedProvider.d.ts","sourceRoot":"","sources":["../../src/react/LiftedProvider.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAkE,MAAM,OAAO,CAAC;AAEvF,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAY,MAAM,eAAe,CAAC;AAShF,wBAAgB,gBAAgB,IAAI,kBAAkB,GAAG,IAAI,CAE5D;AAED,wBAAgB,SAAS,IAAI,kBAAkB,CAW9C;AAMD,MAAM,WAAW,mBAAoB,SAAQ,YAAY;IACvD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAMD,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,kBAAyB,EACzB,gBAAsB,EACtB,kBAAwB,EACxB,WAAoB,EACpB,kBAA0B,EAC1B,kBAAkB,GACnB,EAAE,mBAAmB,GAAG,KAAK,CAAC,YAAY,CAgD1C;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lifted - useDarkMode Hook
|
|
3
|
+
*
|
|
4
|
+
* SSR-safe hook for detecting system dark mode preference.
|
|
5
|
+
*/
|
|
6
|
+
export interface UseDarkModeOptions {
|
|
7
|
+
defaultValue?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function useDarkMode(options?: UseDarkModeOptions): boolean;
|
|
10
|
+
export default useDarkMode;
|
|
11
|
+
//# sourceMappingURL=useDarkMode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDarkMode.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useDarkMode.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,WAAW,kBAAkB;IACjC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAoBrE;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lifted - useElevation Hook
|
|
3
|
+
*
|
|
4
|
+
* Hook for managing interactive elevation states.
|
|
5
|
+
*/
|
|
6
|
+
export interface UseElevationOptions {
|
|
7
|
+
base?: number;
|
|
8
|
+
hover?: number;
|
|
9
|
+
active?: number;
|
|
10
|
+
disabled?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface UseElevationReturn {
|
|
13
|
+
elevation: number;
|
|
14
|
+
isHovered: boolean;
|
|
15
|
+
isActive: boolean;
|
|
16
|
+
elevationProps: {
|
|
17
|
+
onMouseEnter: () => void;
|
|
18
|
+
onMouseLeave: () => void;
|
|
19
|
+
onMouseDown: () => void;
|
|
20
|
+
onMouseUp: () => void;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export declare function useElevation(options?: UseElevationOptions): UseElevationReturn;
|
|
24
|
+
export default useElevation;
|
|
25
|
+
//# sourceMappingURL=useElevation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useElevation.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useElevation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE;QACd,YAAY,EAAE,MAAM,IAAI,CAAC;QACzB,YAAY,EAAE,MAAM,IAAI,CAAC;QACzB,WAAW,EAAE,MAAM,IAAI,CAAC;QACxB,SAAS,EAAE,MAAM,IAAI,CAAC;KACvB,CAAC;CACH;AAED,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,kBAAkB,CA+BlF;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { LiftedBox, LiftedCard, LiftedButton, LiftedModal } from './LiftedBox';
|
|
2
|
+
export { LiftedProvider, useLiftedContext, useLifted } from './LiftedProvider';
|
|
3
|
+
export { useDarkMode } from './hooks/useDarkMode';
|
|
4
|
+
export { useElevation } from './hooks/useElevation';
|
|
5
|
+
export type { LiftedBoxProps, LiftedConfig, LiftedContextValue } from '../core/types';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG/E,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './react/index'
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { jsx as x } from "react/jsx-runtime";
|
|
2
|
+
import A, { useState as m, useEffect as M, forwardRef as E, useRef as H, useMemo as L, createContext as X, useContext as N, useCallback as y } from "react";
|
|
3
|
+
import { g as Y, a as j, n as Q } from "./index-G-GHoQdJ.js";
|
|
4
|
+
function S(e = {}) {
|
|
5
|
+
const { defaultValue: t = !1 } = e, [o, s] = m(t);
|
|
6
|
+
return M(() => {
|
|
7
|
+
if (typeof window > "u") return;
|
|
8
|
+
const n = window.matchMedia("(prefers-color-scheme: dark)");
|
|
9
|
+
s(n.matches);
|
|
10
|
+
const i = (u) => {
|
|
11
|
+
s(u.matches);
|
|
12
|
+
};
|
|
13
|
+
return n.addEventListener("change", i), () => n.removeEventListener("change", i);
|
|
14
|
+
}, []), o;
|
|
15
|
+
}
|
|
16
|
+
const g = E(
|
|
17
|
+
({
|
|
18
|
+
elevation: e = 0.3,
|
|
19
|
+
as: t = "div",
|
|
20
|
+
lightSource: o = -45,
|
|
21
|
+
background: s,
|
|
22
|
+
shadowColor: n,
|
|
23
|
+
shadowColorDark: i,
|
|
24
|
+
intensity: u = 1,
|
|
25
|
+
animated: d = !0,
|
|
26
|
+
transitionDuration: c = 150,
|
|
27
|
+
children: l,
|
|
28
|
+
style: a,
|
|
29
|
+
...w
|
|
30
|
+
}, v) => {
|
|
31
|
+
const h = H(null), B = v || h, [R, z] = m(null), [C, I] = m(null), b = S(), p = Q(o);
|
|
32
|
+
M(() => {
|
|
33
|
+
if (p.type !== "mouse") return;
|
|
34
|
+
const r = () => {
|
|
35
|
+
if (B.current) {
|
|
36
|
+
const f = B.current.getBoundingClientRect();
|
|
37
|
+
I({
|
|
38
|
+
x: f.left,
|
|
39
|
+
y: f.top,
|
|
40
|
+
width: f.width,
|
|
41
|
+
height: f.height
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
return r(), window.addEventListener("scroll", r, { passive: !0 }), window.addEventListener("resize", r, { passive: !0 }), () => {
|
|
46
|
+
window.removeEventListener("scroll", r), window.removeEventListener("resize", r);
|
|
47
|
+
};
|
|
48
|
+
}, [p.type]), M(() => {
|
|
49
|
+
if (p.type !== "mouse") return;
|
|
50
|
+
const r = (f) => {
|
|
51
|
+
z({ x: f.clientX, y: f.clientY });
|
|
52
|
+
};
|
|
53
|
+
return window.addEventListener("mousemove", r, { passive: !0 }), () => window.removeEventListener("mousemove", r);
|
|
54
|
+
}, [p.type]);
|
|
55
|
+
const k = L(() => Y(
|
|
56
|
+
{
|
|
57
|
+
elevation: e,
|
|
58
|
+
lightSource: o,
|
|
59
|
+
background: s,
|
|
60
|
+
shadowColor: n,
|
|
61
|
+
shadowColorDark: i,
|
|
62
|
+
intensity: u,
|
|
63
|
+
isDarkMode: b
|
|
64
|
+
},
|
|
65
|
+
C ?? void 0,
|
|
66
|
+
R
|
|
67
|
+
), [
|
|
68
|
+
e,
|
|
69
|
+
o,
|
|
70
|
+
s,
|
|
71
|
+
n,
|
|
72
|
+
i,
|
|
73
|
+
u,
|
|
74
|
+
b,
|
|
75
|
+
C,
|
|
76
|
+
R
|
|
77
|
+
]), V = L(() => {
|
|
78
|
+
const r = {
|
|
79
|
+
boxShadow: k.boxShadow,
|
|
80
|
+
...a
|
|
81
|
+
};
|
|
82
|
+
return s && (r.backgroundColor = s), d && (r.transition = j(c)), r;
|
|
83
|
+
}, [k.boxShadow, s, d, c, a]);
|
|
84
|
+
return A.createElement(
|
|
85
|
+
t,
|
|
86
|
+
{
|
|
87
|
+
ref: B,
|
|
88
|
+
style: V,
|
|
89
|
+
...w
|
|
90
|
+
},
|
|
91
|
+
l
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
g.displayName = "LiftedBox";
|
|
96
|
+
const U = E(
|
|
97
|
+
(e, t) => /* @__PURE__ */ x(g, { ref: t, elevation: 0.3, ...e })
|
|
98
|
+
);
|
|
99
|
+
U.displayName = "LiftedCard";
|
|
100
|
+
const W = E(
|
|
101
|
+
({ elevation: e = 0.25, ...t }, o) => /* @__PURE__ */ x(g, { ref: o, as: "button", elevation: e, ...t })
|
|
102
|
+
);
|
|
103
|
+
W.displayName = "LiftedButton";
|
|
104
|
+
const q = E(
|
|
105
|
+
(e, t) => /* @__PURE__ */ x(g, { ref: t, elevation: 0.8, ...e })
|
|
106
|
+
);
|
|
107
|
+
q.displayName = "LiftedModal";
|
|
108
|
+
const P = X(null);
|
|
109
|
+
function J() {
|
|
110
|
+
return N(P);
|
|
111
|
+
}
|
|
112
|
+
function K() {
|
|
113
|
+
const e = N(P);
|
|
114
|
+
if (!e)
|
|
115
|
+
throw new Error(
|
|
116
|
+
"useLifted must be used within a LiftedProvider. Wrap your app with <LiftedProvider> to use this hook."
|
|
117
|
+
);
|
|
118
|
+
return e;
|
|
119
|
+
}
|
|
120
|
+
function O({
|
|
121
|
+
children: e,
|
|
122
|
+
autoDetectDarkMode: t = !0,
|
|
123
|
+
defaultElevation: o = 0.3,
|
|
124
|
+
defaultLightSource: s = -45,
|
|
125
|
+
colorScheme: n = "auto",
|
|
126
|
+
disableTransitions: i = !1,
|
|
127
|
+
customColorMapping: u
|
|
128
|
+
}) {
|
|
129
|
+
const [d, c] = m(null), l = S({ defaultValue: !1 }), a = L(() => n === "light" ? !1 : n === "dark" ? !0 : t ? l : !1, [n, t, l]);
|
|
130
|
+
M(() => {
|
|
131
|
+
const v = (h) => {
|
|
132
|
+
c({ x: h.clientX, y: h.clientY });
|
|
133
|
+
};
|
|
134
|
+
return window.addEventListener("mousemove", v, { passive: !0 }), () => window.removeEventListener("mousemove", v);
|
|
135
|
+
}, []);
|
|
136
|
+
const w = L(
|
|
137
|
+
() => ({
|
|
138
|
+
autoDetectDarkMode: t,
|
|
139
|
+
defaultElevation: o,
|
|
140
|
+
defaultLightSource: s,
|
|
141
|
+
colorScheme: n,
|
|
142
|
+
disableTransitions: i,
|
|
143
|
+
isDarkMode: a,
|
|
144
|
+
mousePosition: d,
|
|
145
|
+
customColorMapping: u
|
|
146
|
+
}),
|
|
147
|
+
[
|
|
148
|
+
t,
|
|
149
|
+
o,
|
|
150
|
+
s,
|
|
151
|
+
n,
|
|
152
|
+
i,
|
|
153
|
+
a,
|
|
154
|
+
d,
|
|
155
|
+
u
|
|
156
|
+
]
|
|
157
|
+
);
|
|
158
|
+
return /* @__PURE__ */ x(P.Provider, { value: w, children: e });
|
|
159
|
+
}
|
|
160
|
+
function T(e = {}) {
|
|
161
|
+
const { base: t = 0.3, hover: o = 0.5, active: s = 0.15 } = e, [n, i] = m(!1), [u, d] = m(!1), c = L(() => u ? s : n ? o : t, [n, u, t, o, s]), l = y(() => i(!0), []), a = y(() => {
|
|
162
|
+
i(!1), d(!1);
|
|
163
|
+
}, []), w = y(() => d(!0), []), v = y(() => d(!1), []);
|
|
164
|
+
return {
|
|
165
|
+
elevation: c,
|
|
166
|
+
isHovered: n,
|
|
167
|
+
isActive: u,
|
|
168
|
+
elevationProps: {
|
|
169
|
+
onMouseEnter: l,
|
|
170
|
+
onMouseLeave: a,
|
|
171
|
+
onMouseDown: w,
|
|
172
|
+
onMouseUp: v
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
export {
|
|
177
|
+
g as LiftedBox,
|
|
178
|
+
W as LiftedButton,
|
|
179
|
+
U as LiftedCard,
|
|
180
|
+
q as LiftedModal,
|
|
181
|
+
O as LiftedProvider,
|
|
182
|
+
S as useDarkMode,
|
|
183
|
+
T as useElevation,
|
|
184
|
+
K as useLifted,
|
|
185
|
+
J as useLiftedContext
|
|
186
|
+
};
|
package/dist/react.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),e=require("react"),y=require("./index-4W01YOTU.cjs");function E(t={}){const{defaultValue:s=!1}=t,[r,o]=e.useState(s);return e.useEffect(()=>{if(typeof window>"u")return;const n=window.matchMedia("(prefers-color-scheme: dark)");o(n.matches);const u=d=>{o(d.matches)};return n.addEventListener("change",u),()=>n.removeEventListener("change",u)},[]),r}const L=e.forwardRef(({elevation:t=.3,as:s="div",lightSource:r=-45,background:o,shadowColor:n,shadowColorDark:u,intensity:d=1,animated:a=!0,transitionDuration:l=150,children:v,style:f,...w},m)=>{const M=e.useRef(null),p=m||M,[R,j]=e.useState(null),[S,N]=e.useState(null),b=E(),x=y.normalizeLightSource(r);e.useEffect(()=>{if(x.type!=="mouse")return;const i=()=>{if(p.current){const c=p.current.getBoundingClientRect();N({x:c.left,y:c.top,width:c.width,height:c.height})}};return i(),window.addEventListener("scroll",i,{passive:!0}),window.addEventListener("resize",i,{passive:!0}),()=>{window.removeEventListener("scroll",i),window.removeEventListener("resize",i)}},[x.type]),e.useEffect(()=>{if(x.type!=="mouse")return;const i=c=>{j({x:c.clientX,y:c.clientY})};return window.addEventListener("mousemove",i,{passive:!0}),()=>window.removeEventListener("mousemove",i)},[x.type]);const B=e.useMemo(()=>y.generateShadow({elevation:t,lightSource:r,background:o,shadowColor:n,shadowColorDark:u,intensity:d,isDarkMode:b},S??void 0,R),[t,r,o,n,u,d,b,S,R]),q=e.useMemo(()=>{const i={boxShadow:B.boxShadow,...f};return o&&(i.backgroundColor=o),a&&(i.transition=y.generateTransition(l)),i},[B.boxShadow,o,a,l,f]);return e.createElement(s,{ref:p,style:q,...w},v)});L.displayName="LiftedBox";const P=e.forwardRef((t,s)=>h.jsx(L,{ref:s,elevation:.3,...t}));P.displayName="LiftedCard";const g=e.forwardRef(({elevation:t=.25,...s},r)=>h.jsx(L,{ref:r,as:"button",elevation:t,...s}));g.displayName="LiftedButton";const k=e.forwardRef((t,s)=>h.jsx(L,{ref:s,elevation:.8,...t}));k.displayName="LiftedModal";const C=e.createContext(null);function z(){return e.useContext(C)}function I(){const t=e.useContext(C);if(!t)throw new Error("useLifted must be used within a LiftedProvider. Wrap your app with <LiftedProvider> to use this hook.");return t}function V({children:t,autoDetectDarkMode:s=!0,defaultElevation:r=.3,defaultLightSource:o=-45,colorScheme:n="auto",disableTransitions:u=!1,customColorMapping:d}){const[a,l]=e.useState(null),v=E({defaultValue:!1}),f=e.useMemo(()=>n==="light"?!1:n==="dark"?!0:s?v:!1,[n,s,v]);e.useEffect(()=>{const m=M=>{l({x:M.clientX,y:M.clientY})};return window.addEventListener("mousemove",m,{passive:!0}),()=>window.removeEventListener("mousemove",m)},[]);const w=e.useMemo(()=>({autoDetectDarkMode:s,defaultElevation:r,defaultLightSource:o,colorScheme:n,disableTransitions:u,isDarkMode:f,mousePosition:a,customColorMapping:d}),[s,r,o,n,u,f,a,d]);return h.jsx(C.Provider,{value:w,children:t})}function A(t={}){const{base:s=.3,hover:r=.5,active:o=.15}=t,[n,u]=e.useState(!1),[d,a]=e.useState(!1),l=e.useMemo(()=>d?o:n?r:s,[n,d,s,r,o]),v=e.useCallback(()=>u(!0),[]),f=e.useCallback(()=>{u(!1),a(!1)},[]),w=e.useCallback(()=>a(!0),[]),m=e.useCallback(()=>a(!1),[]);return{elevation:l,isHovered:n,isActive:d,elevationProps:{onMouseEnter:v,onMouseLeave:f,onMouseDown:w,onMouseUp:m}}}exports.LiftedBox=L;exports.LiftedButton=g;exports.LiftedCard=P;exports.LiftedModal=k;exports.LiftedProvider=V;exports.useDarkMode=E;exports.useElevation=A;exports.useLifted=I;exports.useLiftedContext=z;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lifted - Vanilla JavaScript Module
|
|
3
|
+
*/
|
|
4
|
+
export { initLiftedBox, initAllLiftedBoxes, applyLift, removeLift, getLiftCSS, } from './init';
|
|
5
|
+
export { generateShadow, generateBoxShadow, layersToCSS, ELEVATION_PRESETS, resolveElevation, } from '../core/css-generator';
|
|
6
|
+
export { calculateShadowLayers, calculateLightAngle, normalizeLightSource, } from '../core/calculations';
|
|
7
|
+
export { calculateShadowColor, parseColor, isLightColor, } from '../core/color';
|
|
8
|
+
export type { VanillaLiftedBoxOptions, VanillaLiftedBoxInstance, ShadowOptions, ShadowResult, LightSourceProp, LightSource, } from '../core/types';
|
|
9
|
+
export type { ElevationPreset } from '../core/css-generator';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vanilla/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,UAAU,GACX,MAAM,QAAQ,CAAC;AAEhB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,oBAAoB,EACpB,UAAU,EACV,YAAY,GACb,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,uBAAuB,EACvB,wBAAwB,EACxB,aAAa,EACb,YAAY,EACZ,eAAe,EACf,WAAW,GACZ,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { VanillaLiftedBoxOptions, VanillaLiftedBoxInstance } from '../core/types';
|
|
2
|
+
|
|
3
|
+
export declare function initLiftedBox(element: HTMLElement, options?: VanillaLiftedBoxOptions): VanillaLiftedBoxInstance;
|
|
4
|
+
export declare function initAllLiftedBoxes(selector?: string, defaultOptions?: VanillaLiftedBoxOptions): VanillaLiftedBoxInstance[];
|
|
5
|
+
export declare function applyLift(element: HTMLElement, elevation: number, options?: Partial<VanillaLiftedBoxOptions>): void;
|
|
6
|
+
export declare function removeLift(element: HTMLElement): void;
|
|
7
|
+
export declare function getLiftCSS(elevation: number, options?: Partial<VanillaLiftedBoxOptions>): string;
|
|
8
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/vanilla/init.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EAGzB,MAAM,eAAe,CAAC;AASvB,wBAAgB,aAAa,CAC3B,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,uBAA4B,GACpC,wBAAwB,CAwG1B;AAMD,wBAAgB,kBAAkB,CAChC,QAAQ,GAAE,MAAwB,EAClC,cAAc,GAAE,uBAA4B,GAC3C,wBAAwB,EAAE,CAU5B;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,OAAO,CAAC,uBAAuB,CAAM,GAAG,IAAI,CAGvH;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAErD;AAED,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,OAAO,CAAC,uBAAuB,CAAM,GAAG,MAAM,CAGpG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vanilla/index'
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { g as u, a as f, n as S, s as m } from "./index-G-GHoQdJ.js";
|
|
2
|
+
import { E as k, c as E, b as A, d as D, e as B, i as F, l as M, p as P, r as T } from "./index-G-GHoQdJ.js";
|
|
3
|
+
function w(e, a = {}) {
|
|
4
|
+
let o = { ...a }, i = null, n = null, r = null, d = !1;
|
|
5
|
+
const l = S(o.lightSource);
|
|
6
|
+
function h() {
|
|
7
|
+
const t = e.getBoundingClientRect();
|
|
8
|
+
return {
|
|
9
|
+
x: t.left,
|
|
10
|
+
y: t.top,
|
|
11
|
+
width: t.width,
|
|
12
|
+
height: t.height
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function s() {
|
|
16
|
+
if (d) return;
|
|
17
|
+
const t = u(
|
|
18
|
+
{
|
|
19
|
+
elevation: o.elevation ?? 0.3,
|
|
20
|
+
lightSource: o.lightSource,
|
|
21
|
+
background: o.background,
|
|
22
|
+
shadowColor: o.shadowColor,
|
|
23
|
+
shadowColorDark: o.shadowColorDark,
|
|
24
|
+
intensity: o.intensity ?? 1,
|
|
25
|
+
isDarkMode: o.isDarkMode ?? !1
|
|
26
|
+
},
|
|
27
|
+
h(),
|
|
28
|
+
n
|
|
29
|
+
);
|
|
30
|
+
e.style.boxShadow = t.boxShadow;
|
|
31
|
+
}
|
|
32
|
+
function c(t) {
|
|
33
|
+
if (i = { x: t.clientX, y: t.clientY }, l.type === "mouse") {
|
|
34
|
+
const g = l.smoothing ?? 0.1;
|
|
35
|
+
n ? n = m(n, i, g) : n = i, r && cancelAnimationFrame(r), r = requestAnimationFrame(s);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return o.background && (e.style.backgroundColor = o.background), o.animated !== !1 && (e.style.transition = f(o.transitionDuration ?? 150)), s(), l.type === "mouse" && window.addEventListener("mousemove", c, { passive: !0 }), {
|
|
39
|
+
setElevation(t) {
|
|
40
|
+
o.elevation = t, s();
|
|
41
|
+
},
|
|
42
|
+
setLightSource(t) {
|
|
43
|
+
o.lightSource = t, s();
|
|
44
|
+
},
|
|
45
|
+
update(t) {
|
|
46
|
+
o = { ...o, ...t }, t.background && (e.style.backgroundColor = t.background), s();
|
|
47
|
+
},
|
|
48
|
+
getShadowCSS() {
|
|
49
|
+
return e.style.boxShadow;
|
|
50
|
+
},
|
|
51
|
+
destroy() {
|
|
52
|
+
d = !0, r && cancelAnimationFrame(r), window.removeEventListener("mousemove", c), e.style.boxShadow = "", e.style.transition = "";
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function b(e = "[data-lifted]", a = {}) {
|
|
57
|
+
const o = document.querySelectorAll(e);
|
|
58
|
+
return Array.from(o).map((i) => {
|
|
59
|
+
const n = i.dataset.liftedElevation, r = {
|
|
60
|
+
...a,
|
|
61
|
+
elevation: n ? parseFloat(n) : a.elevation
|
|
62
|
+
};
|
|
63
|
+
return w(i, r);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function v(e, a, o = {}) {
|
|
67
|
+
const i = u({ elevation: a, ...o });
|
|
68
|
+
e.style.boxShadow = i.boxShadow;
|
|
69
|
+
}
|
|
70
|
+
function x(e) {
|
|
71
|
+
e.style.boxShadow = "";
|
|
72
|
+
}
|
|
73
|
+
function p(e, a = {}) {
|
|
74
|
+
return u({ elevation: e, ...a }).boxShadow;
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
k as ELEVATION_PRESETS,
|
|
78
|
+
v as applyLift,
|
|
79
|
+
E as calculateLightAngle,
|
|
80
|
+
A as calculateShadowColor,
|
|
81
|
+
D as calculateShadowLayers,
|
|
82
|
+
B as generateBoxShadow,
|
|
83
|
+
u as generateShadow,
|
|
84
|
+
p as getLiftCSS,
|
|
85
|
+
b as initAllLiftedBoxes,
|
|
86
|
+
w as initLiftedBox,
|
|
87
|
+
F as isLightColor,
|
|
88
|
+
M as layersToCSS,
|
|
89
|
+
S as normalizeLightSource,
|
|
90
|
+
P as parseColor,
|
|
91
|
+
x as removeLift,
|
|
92
|
+
T as resolveElevation
|
|
93
|
+
};
|
package/dist/vanilla.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-4W01YOTU.cjs");function h(a,i={}){let o={...i},n=null,r=null,l=null,d=!1;const u=t.normalizeLightSource(o.lightSource);function S(){const e=a.getBoundingClientRect();return{x:e.left,y:e.top,width:e.width,height:e.height}}function s(){if(d)return;const e=t.generateShadow({elevation:o.elevation??.3,lightSource:o.lightSource,background:o.background,shadowColor:o.shadowColor,shadowColorDark:o.shadowColorDark,intensity:o.intensity??1,isDarkMode:o.isDarkMode??!1},S(),r);a.style.boxShadow=e.boxShadow}function c(e){if(n={x:e.clientX,y:e.clientY},u.type==="mouse"){const g=u.smoothing??.1;r?r=t.smoothPosition(r,n,g):r=n,l&&cancelAnimationFrame(l),l=requestAnimationFrame(s)}}return o.background&&(a.style.backgroundColor=o.background),o.animated!==!1&&(a.style.transition=t.generateTransition(o.transitionDuration??150)),s(),u.type==="mouse"&&window.addEventListener("mousemove",c,{passive:!0}),{setElevation(e){o.elevation=e,s()},setLightSource(e){o.lightSource=e,s()},update(e){o={...o,...e},e.background&&(a.style.backgroundColor=e.background),s()},getShadowCSS(){return a.style.boxShadow},destroy(){d=!0,l&&cancelAnimationFrame(l),window.removeEventListener("mousemove",c),a.style.boxShadow="",a.style.transition=""}}}function f(a="[data-lifted]",i={}){const o=document.querySelectorAll(a);return Array.from(o).map(n=>{const r=n.dataset.liftedElevation,l={...i,elevation:r?parseFloat(r):i.elevation};return h(n,l)})}function w(a,i,o={}){const n=t.generateShadow({elevation:i,...o});a.style.boxShadow=n.boxShadow}function y(a){a.style.boxShadow=""}function m(a,i={}){return t.generateShadow({elevation:a,...i}).boxShadow}exports.ELEVATION_PRESETS=t.ELEVATION_PRESETS;exports.calculateLightAngle=t.calculateLightAngle;exports.calculateShadowColor=t.calculateShadowColor;exports.calculateShadowLayers=t.calculateShadowLayers;exports.generateBoxShadow=t.generateBoxShadow;exports.generateShadow=t.generateShadow;exports.isLightColor=t.isLightColor;exports.layersToCSS=t.layersToCSS;exports.normalizeLightSource=t.normalizeLightSource;exports.parseColor=t.parseColor;exports.resolveElevation=t.resolveElevation;exports.applyLift=w;exports.getLiftCSS=m;exports.initAllLiftedBoxes=f;exports.initLiftedBox=h;exports.removeLift=y;
|
package/package.json
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@juanlaria/lifted",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Beautiful, realistic CSS shadows with layered depth - inspired by Josh Comeau & Tobias Ahlin",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"css",
|
|
7
|
+
"shadows",
|
|
8
|
+
"box-shadow",
|
|
9
|
+
"elevation",
|
|
10
|
+
"react",
|
|
11
|
+
"design-system",
|
|
12
|
+
"ui",
|
|
13
|
+
"depth",
|
|
14
|
+
"lifted",
|
|
15
|
+
"inner-shadow",
|
|
16
|
+
"inset"
|
|
17
|
+
],
|
|
18
|
+
"author": "Juan Laria",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"type": "module",
|
|
21
|
+
"main": "./dist/index.js",
|
|
22
|
+
"module": "./dist/index.esm.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"import": "./dist/index.esm.js",
|
|
27
|
+
"require": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"./react": {
|
|
31
|
+
"import": "./dist/react.esm.js",
|
|
32
|
+
"require": "./dist/react.js",
|
|
33
|
+
"types": "./dist/react.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"./vanilla": {
|
|
36
|
+
"import": "./dist/vanilla.esm.js",
|
|
37
|
+
"require": "./dist/vanilla.js",
|
|
38
|
+
"types": "./dist/vanilla.d.ts"
|
|
39
|
+
},
|
|
40
|
+
"./styles": "./dist/styles/index.css"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"README.md"
|
|
45
|
+
],
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "https://github.com/juanlaria/lifted.git"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"dev": "vite",
|
|
52
|
+
"build": "tsc && vite build",
|
|
53
|
+
"preview": "vite preview",
|
|
54
|
+
"test": "vitest",
|
|
55
|
+
"lint": "eslint src --ext ts,tsx",
|
|
56
|
+
"type-check": "tsc --noEmit",
|
|
57
|
+
"prepublishOnly": "npm run build"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"react": ">=17.0.0",
|
|
61
|
+
"react-dom": ">=17.0.0"
|
|
62
|
+
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"react": {
|
|
65
|
+
"optional": true
|
|
66
|
+
},
|
|
67
|
+
"react-dom": {
|
|
68
|
+
"optional": true
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"devDependencies": {
|
|
72
|
+
"@types/react": "^18.2.0",
|
|
73
|
+
"@types/react-dom": "^18.2.0",
|
|
74
|
+
"@vitejs/plugin-react": "^4.2.0",
|
|
75
|
+
"react": "^18.2.0",
|
|
76
|
+
"react-dom": "^18.2.0",
|
|
77
|
+
"typescript": "^5.3.0",
|
|
78
|
+
"vite": "^5.0.0",
|
|
79
|
+
"vite-plugin-dts": "^3.7.0",
|
|
80
|
+
"vitest": "^1.2.0"
|
|
81
|
+
}
|
|
82
|
+
}
|