@protohiro/effects 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 +29 -0
- package/dist/index.cjs +195 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +28 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +166 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# @protohiro/effects
|
|
2
|
+
|
|
3
|
+
Zero-wrapper React hooks for composable CSS effects.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @protohiro/effects
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { useGradientBorderEffect } from '@protohiro/effects';
|
|
15
|
+
|
|
16
|
+
export function Button() {
|
|
17
|
+
const ref = useGradientBorderEffect({ thickness: 2, angle: 90 });
|
|
18
|
+
return <button ref={ref}>Click</button>;
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Hooks
|
|
23
|
+
|
|
24
|
+
- `useGradientBorderEffect`
|
|
25
|
+
- `useGlowEffect`
|
|
26
|
+
- `useNoiseEffect`
|
|
27
|
+
|
|
28
|
+
For full docs and demos, see:
|
|
29
|
+
https://github.com/snwol/protoeffects
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
useGlowEffect: () => useGlowEffect,
|
|
24
|
+
useGradientBorderEffect: () => useGradientBorderEffect,
|
|
25
|
+
useNoiseEffect: () => useNoiseEffect
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
|
|
29
|
+
// src/effects/useGradientBorderEffect.ts
|
|
30
|
+
var import_effects_core2 = require("@protohiro/effects-core");
|
|
31
|
+
var import_react2 = require("react");
|
|
32
|
+
|
|
33
|
+
// src/shared/effectStyles.ts
|
|
34
|
+
var EFFECT_STYLES = `
|
|
35
|
+
.pe-gradient-border {
|
|
36
|
+
position: relative;
|
|
37
|
+
border-radius: var(--pe-gb-radius, inherit);
|
|
38
|
+
border: var(--pe-gb-thickness, 2px) solid transparent;
|
|
39
|
+
background:
|
|
40
|
+
linear-gradient(var(--pe-bg-fill, transparent), var(--pe-bg-fill, transparent)) padding-box,
|
|
41
|
+
linear-gradient(var(--pe-gb-angle, 120deg), var(--pe-gb-colors, #5eead4, #0ea5e9)) border-box;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.pe-glow {
|
|
45
|
+
box-shadow:
|
|
46
|
+
0 0 var(--pe-glow-blur, 24px)
|
|
47
|
+
color-mix(in srgb, var(--pe-glow-color, #38bdf8) calc(var(--pe-glow-opacity, 0.4) * 100%), transparent),
|
|
48
|
+
0 0 var(--pe-glow-spread, 2px)
|
|
49
|
+
color-mix(in srgb, var(--pe-glow-color, #38bdf8) calc(var(--pe-glow-opacity, 0.2) * 100%), transparent);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.pe-noise {
|
|
53
|
+
position: relative;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.pe-noise::after {
|
|
57
|
+
content: '';
|
|
58
|
+
position: absolute;
|
|
59
|
+
inset: 0;
|
|
60
|
+
border-radius: inherit;
|
|
61
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.95' numOctaves='2' seed='13' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
|
|
62
|
+
background-size: var(--pe-noise-size, 80px) var(--pe-noise-size, 80px);
|
|
63
|
+
background-repeat: repeat;
|
|
64
|
+
image-rendering: pixelated;
|
|
65
|
+
filter: contrast(190%) brightness(110%);
|
|
66
|
+
opacity: var(--pe-noise-opacity, 0.28);
|
|
67
|
+
pointer-events: none;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@media (prefers-reduced-motion: reduce) {
|
|
71
|
+
.pe-noise::after {
|
|
72
|
+
opacity: calc(var(--pe-noise-opacity, 0.28) * 0.9);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
|
|
77
|
+
// src/shared/useCssEffect.ts
|
|
78
|
+
var import_effects_core = require("@protohiro/effects-core");
|
|
79
|
+
var import_react = require("react");
|
|
80
|
+
function useCssEffect(input) {
|
|
81
|
+
const [node, setNode] = (0, import_react.useState)(null);
|
|
82
|
+
(0, import_react.useEffect)(() => {
|
|
83
|
+
if (!node || input.disabled) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
(0, import_effects_core.ensureGlobalStyle)(input.styleId, input.styleText);
|
|
87
|
+
const cleanups = [];
|
|
88
|
+
cleanups.push((0, import_effects_core.applyEffectClass)(node, input.className));
|
|
89
|
+
if (input.userClassName) {
|
|
90
|
+
cleanups.push((0, import_effects_core.applyEffectClass)(node, input.userClassName));
|
|
91
|
+
}
|
|
92
|
+
cleanups.push((0, import_effects_core.applyCssVars)(node, input.vars));
|
|
93
|
+
return () => {
|
|
94
|
+
for (const cleanup of cleanups.reverse()) {
|
|
95
|
+
cleanup();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}, [
|
|
99
|
+
node,
|
|
100
|
+
input.className,
|
|
101
|
+
input.userClassName,
|
|
102
|
+
input.disabled,
|
|
103
|
+
input.styleId,
|
|
104
|
+
input.styleText,
|
|
105
|
+
input.vars
|
|
106
|
+
]);
|
|
107
|
+
return (0, import_react.useCallback)((next) => {
|
|
108
|
+
setNode(next);
|
|
109
|
+
}, []);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src/effects/useGradientBorderEffect.ts
|
|
113
|
+
var STYLE_ID = "protohiro-effects-base";
|
|
114
|
+
function useGradientBorderEffect(options = {}) {
|
|
115
|
+
const vars = (0, import_react2.useMemo)(
|
|
116
|
+
() => ({
|
|
117
|
+
"--pe-gb-thickness": (0, import_effects_core2.toCssLength)(options.thickness),
|
|
118
|
+
"--pe-gb-radius": (0, import_effects_core2.toCssLength)(options.radius),
|
|
119
|
+
"--pe-gb-colors": options.colors,
|
|
120
|
+
"--pe-gb-angle": (0, import_effects_core2.toCssAngle)(options.angle)
|
|
121
|
+
}),
|
|
122
|
+
[options.thickness, options.radius, options.colors, options.angle]
|
|
123
|
+
);
|
|
124
|
+
return useCssEffect({
|
|
125
|
+
className: "pe-gradient-border",
|
|
126
|
+
userClassName: options.className,
|
|
127
|
+
vars,
|
|
128
|
+
disabled: options.disabled,
|
|
129
|
+
styleId: STYLE_ID,
|
|
130
|
+
styleText: EFFECT_STYLES
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// src/effects/useGlowEffect.ts
|
|
135
|
+
var import_effects_core3 = require("@protohiro/effects-core");
|
|
136
|
+
var import_react3 = require("react");
|
|
137
|
+
var STYLE_ID2 = "protohiro-effects-base";
|
|
138
|
+
function useGlowEffect(options = {}) {
|
|
139
|
+
const vars = (0, import_react3.useMemo)(
|
|
140
|
+
() => ({
|
|
141
|
+
"--pe-glow-color": options.color,
|
|
142
|
+
"--pe-glow-blur": (0, import_effects_core3.toCssLength)(options.blur),
|
|
143
|
+
"--pe-glow-spread": (0, import_effects_core3.toCssLength)(options.spread),
|
|
144
|
+
"--pe-glow-opacity": (0, import_effects_core3.toCssNumber)(options.opacity)
|
|
145
|
+
}),
|
|
146
|
+
[options.color, options.blur, options.spread, options.opacity]
|
|
147
|
+
);
|
|
148
|
+
return useCssEffect({
|
|
149
|
+
className: "pe-glow",
|
|
150
|
+
userClassName: options.className,
|
|
151
|
+
vars,
|
|
152
|
+
disabled: options.disabled,
|
|
153
|
+
styleId: STYLE_ID2,
|
|
154
|
+
styleText: EFFECT_STYLES
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// src/effects/useNoiseEffect.ts
|
|
159
|
+
var import_effects_core4 = require("@protohiro/effects-core");
|
|
160
|
+
var import_react4 = require("react");
|
|
161
|
+
var STYLE_ID3 = "protohiro-effects-base";
|
|
162
|
+
function clampUnit(value) {
|
|
163
|
+
if (value === void 0) {
|
|
164
|
+
return void 0;
|
|
165
|
+
}
|
|
166
|
+
if (Number.isNaN(value)) {
|
|
167
|
+
return void 0;
|
|
168
|
+
}
|
|
169
|
+
return Math.max(0, Math.min(1, value));
|
|
170
|
+
}
|
|
171
|
+
function useNoiseEffect(options = {}) {
|
|
172
|
+
const intensity = clampUnit(options.intensity);
|
|
173
|
+
const vars = (0, import_react4.useMemo)(
|
|
174
|
+
() => ({
|
|
175
|
+
"--pe-noise-size": (0, import_effects_core4.toCssLength)(options.size ?? 120),
|
|
176
|
+
"--pe-noise-opacity": (0, import_effects_core4.toCssNumber)(intensity ?? 0.2)
|
|
177
|
+
}),
|
|
178
|
+
[options.size, intensity]
|
|
179
|
+
);
|
|
180
|
+
return useCssEffect({
|
|
181
|
+
className: "pe-noise",
|
|
182
|
+
userClassName: options.className,
|
|
183
|
+
vars,
|
|
184
|
+
disabled: options.disabled,
|
|
185
|
+
styleId: STYLE_ID3,
|
|
186
|
+
styleText: EFFECT_STYLES
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
190
|
+
0 && (module.exports = {
|
|
191
|
+
useGlowEffect,
|
|
192
|
+
useGradientBorderEffect,
|
|
193
|
+
useNoiseEffect
|
|
194
|
+
});
|
|
195
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/effects/useGradientBorderEffect.ts","../src/shared/effectStyles.ts","../src/shared/useCssEffect.ts","../src/effects/useGlowEffect.ts","../src/effects/useNoiseEffect.ts"],"sourcesContent":["export { useGradientBorderEffect } from './effects/useGradientBorderEffect';\nexport { useGlowEffect } from './effects/useGlowEffect';\nexport { useNoiseEffect } from './effects/useNoiseEffect';\n\nexport type { EffectBaseOptions, GlowOptions, GradientBorderOptions, NoiseOptions } from './types';\n","import { toCssAngle, toCssLength } from '@protohiro/effects-core';\nimport { useMemo } from 'react';\n\nimport type { GradientBorderOptions } from '../types';\nimport { EFFECT_STYLES } from '../shared/effectStyles';\nimport { useCssEffect } from '../shared/useCssEffect';\n\nconst STYLE_ID = 'protohiro-effects-base';\n\nexport function useGradientBorderEffect<T extends HTMLElement = HTMLElement>(\n options: GradientBorderOptions = {},\n) {\n const vars = useMemo(\n () => ({\n '--pe-gb-thickness': toCssLength(options.thickness),\n '--pe-gb-radius': toCssLength(options.radius),\n '--pe-gb-colors': options.colors,\n '--pe-gb-angle': toCssAngle(options.angle),\n }),\n [options.thickness, options.radius, options.colors, options.angle],\n );\n\n return useCssEffect<T>({\n className: 'pe-gradient-border',\n userClassName: options.className,\n vars,\n disabled: options.disabled,\n styleId: STYLE_ID,\n styleText: EFFECT_STYLES,\n });\n}\n","export const EFFECT_STYLES = `\n.pe-gradient-border {\n position: relative;\n border-radius: var(--pe-gb-radius, inherit);\n border: var(--pe-gb-thickness, 2px) solid transparent;\n background:\n linear-gradient(var(--pe-bg-fill, transparent), var(--pe-bg-fill, transparent)) padding-box,\n linear-gradient(var(--pe-gb-angle, 120deg), var(--pe-gb-colors, #5eead4, #0ea5e9)) border-box;\n}\n\n.pe-glow {\n box-shadow:\n 0 0 var(--pe-glow-blur, 24px)\n color-mix(in srgb, var(--pe-glow-color, #38bdf8) calc(var(--pe-glow-opacity, 0.4) * 100%), transparent),\n 0 0 var(--pe-glow-spread, 2px)\n color-mix(in srgb, var(--pe-glow-color, #38bdf8) calc(var(--pe-glow-opacity, 0.2) * 100%), transparent);\n}\n\n.pe-noise {\n position: relative;\n}\n\n.pe-noise::after {\n content: '';\n position: absolute;\n inset: 0;\n border-radius: inherit;\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.95' numOctaves='2' seed='13' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E\");\n background-size: var(--pe-noise-size, 80px) var(--pe-noise-size, 80px);\n background-repeat: repeat;\n image-rendering: pixelated;\n filter: contrast(190%) brightness(110%);\n opacity: var(--pe-noise-opacity, 0.28);\n pointer-events: none;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .pe-noise::after {\n opacity: calc(var(--pe-noise-opacity, 0.28) * 0.9);\n }\n}\n`;\n","import { applyCssVars, applyEffectClass, ensureGlobalStyle } from '@protohiro/effects-core';\nimport { useCallback, useEffect, useState } from 'react';\n\ntype UseCssEffectInput = {\n className: string;\n userClassName?: string;\n vars: Record<string, string | undefined>;\n disabled?: boolean;\n styleId: string;\n styleText: string;\n};\n\nexport function useCssEffect<T extends HTMLElement>(input: UseCssEffectInput) {\n const [node, setNode] = useState<T | null>(null);\n\n useEffect(() => {\n if (!node || input.disabled) {\n return;\n }\n\n ensureGlobalStyle(input.styleId, input.styleText);\n\n const cleanups: Array<() => void> = [];\n cleanups.push(applyEffectClass(node, input.className));\n\n if (input.userClassName) {\n cleanups.push(applyEffectClass(node, input.userClassName));\n }\n\n cleanups.push(applyCssVars(node, input.vars));\n\n return () => {\n for (const cleanup of cleanups.reverse()) {\n cleanup();\n }\n };\n }, [\n node,\n input.className,\n input.userClassName,\n input.disabled,\n input.styleId,\n input.styleText,\n input.vars,\n ]);\n\n return useCallback((next: T | null) => {\n setNode(next);\n }, []);\n}\n","import { toCssLength, toCssNumber } from '@protohiro/effects-core';\nimport { useMemo } from 'react';\n\nimport type { GlowOptions } from '../types';\nimport { EFFECT_STYLES } from '../shared/effectStyles';\nimport { useCssEffect } from '../shared/useCssEffect';\n\nconst STYLE_ID = 'protohiro-effects-base';\n\nexport function useGlowEffect<T extends HTMLElement = HTMLElement>(options: GlowOptions = {}) {\n const vars = useMemo(\n () => ({\n '--pe-glow-color': options.color,\n '--pe-glow-blur': toCssLength(options.blur),\n '--pe-glow-spread': toCssLength(options.spread),\n '--pe-glow-opacity': toCssNumber(options.opacity),\n }),\n [options.color, options.blur, options.spread, options.opacity],\n );\n\n return useCssEffect<T>({\n className: 'pe-glow',\n userClassName: options.className,\n vars,\n disabled: options.disabled,\n styleId: STYLE_ID,\n styleText: EFFECT_STYLES,\n });\n}\n","import { toCssLength, toCssNumber } from '@protohiro/effects-core';\nimport { useMemo } from 'react';\n\nimport type { NoiseOptions } from '../types';\nimport { EFFECT_STYLES } from '../shared/effectStyles';\nimport { useCssEffect } from '../shared/useCssEffect';\n\nconst STYLE_ID = 'protohiro-effects-base';\n\nfunction clampUnit(value: number | undefined): number | undefined {\n if (value === undefined) {\n return undefined;\n }\n\n if (Number.isNaN(value)) {\n return undefined;\n }\n\n return Math.max(0, Math.min(1, value));\n}\n\nexport function useNoiseEffect<T extends HTMLElement = HTMLElement>(options: NoiseOptions = {}) {\n const intensity = clampUnit(options.intensity);\n\n const vars = useMemo(\n () => ({\n '--pe-noise-size': toCssLength(options.size ?? 120),\n '--pe-noise-opacity': toCssNumber(intensity ?? 0.2),\n }),\n [options.size, intensity],\n );\n\n return useCssEffect<T>({\n className: 'pe-noise',\n userClassName: options.className,\n vars,\n disabled: options.disabled,\n styleId: STYLE_ID,\n styleText: EFFECT_STYLES,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,uBAAwC;AACxC,IAAAC,gBAAwB;;;ACDjB,IAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACA7B,0BAAkE;AAClE,mBAAiD;AAW1C,SAAS,aAAoC,OAA0B;AAC5E,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAmB,IAAI;AAE/C,8BAAU,MAAM;AACd,QAAI,CAAC,QAAQ,MAAM,UAAU;AAC3B;AAAA,IACF;AAEA,+CAAkB,MAAM,SAAS,MAAM,SAAS;AAEhD,UAAM,WAA8B,CAAC;AACrC,aAAS,SAAK,sCAAiB,MAAM,MAAM,SAAS,CAAC;AAErD,QAAI,MAAM,eAAe;AACvB,eAAS,SAAK,sCAAiB,MAAM,MAAM,aAAa,CAAC;AAAA,IAC3D;AAEA,aAAS,SAAK,kCAAa,MAAM,MAAM,IA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AAgB;AAAA,IACrB,WAAW;AAAA,IACX,eAAe,QAAQ;AAAA,IACvB;AAAA,IACA,UAAU,QAAQ;AAAA,IAClB,SAASA;AAAA,IACT,WAAW;AAAA,EACb,CAAC;AACH;;;AC5BA,IAAAC,uBAAyC;AACzC,IAAAC,gBAAwB;AAMxB,IAAMC,YAAW;AAEjB,SAAS,UAAU,OAA+C;AAChE,MAAI,UAAU,QAAW;AACvB,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,MAAM,KAAK,GAAG;AACvB,WAAO;AAAA,EACT;AAEA,SAAO,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC;AACvC;AAEO,SAAS,eAAoD,UAAwB,CAAC,GAAG;AAC9F,QAAM,YAAY,UAAU,QAAQ,SAAS;AAE7C,QAAM,WAAO;AAAA,IACX,OAAO;AAAA,MACL,uBAAmB,kCAAY,QAAQ,QAAQ,GAAG;AAAA,MAClD,0BAAsB,kCAAY,aAAa,GAAG;AAAA,IACpD;AAAA,IACA,CAAC,QAAQ,MAAM,SAAS;AAAA,EAC1B;AAEA,SAAO,aAAgB;AAAA,IACrB,WAAW;AAAA,IACX,eAAe,QAAQ;AAAA,IACvB;AAAA,IACA,UAAU,QAAQ;AAAA,IAClB,SAASA;AAAA,IACT,WAAW;AAAA,EACb,CAAC;AACH;","names":["import_effects_core","import_react","import_effects_core","import_react","STYLE_ID","import_effects_core","import_react","STYLE_ID"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
interface EffectBaseOptions {
|
|
2
|
+
disabled?: boolean;
|
|
3
|
+
className?: string;
|
|
4
|
+
}
|
|
5
|
+
interface GradientBorderOptions extends EffectBaseOptions {
|
|
6
|
+
thickness?: string | number;
|
|
7
|
+
radius?: string | number;
|
|
8
|
+
colors?: string;
|
|
9
|
+
angle?: string | number;
|
|
10
|
+
}
|
|
11
|
+
interface GlowOptions extends EffectBaseOptions {
|
|
12
|
+
color?: string;
|
|
13
|
+
blur?: string | number;
|
|
14
|
+
spread?: string | number;
|
|
15
|
+
opacity?: number;
|
|
16
|
+
}
|
|
17
|
+
interface NoiseOptions extends EffectBaseOptions {
|
|
18
|
+
size?: string | number;
|
|
19
|
+
intensity?: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare function useGradientBorderEffect<T extends HTMLElement = HTMLElement>(options?: GradientBorderOptions): (next: T | null) => void;
|
|
23
|
+
|
|
24
|
+
declare function useGlowEffect<T extends HTMLElement = HTMLElement>(options?: GlowOptions): (next: T | null) => void;
|
|
25
|
+
|
|
26
|
+
declare function useNoiseEffect<T extends HTMLElement = HTMLElement>(options?: NoiseOptions): (next: T | null) => void;
|
|
27
|
+
|
|
28
|
+
export { type EffectBaseOptions, type GlowOptions, type GradientBorderOptions, type NoiseOptions, useGlowEffect, useGradientBorderEffect, useNoiseEffect };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
interface EffectBaseOptions {
|
|
2
|
+
disabled?: boolean;
|
|
3
|
+
className?: string;
|
|
4
|
+
}
|
|
5
|
+
interface GradientBorderOptions extends EffectBaseOptions {
|
|
6
|
+
thickness?: string | number;
|
|
7
|
+
radius?: string | number;
|
|
8
|
+
colors?: string;
|
|
9
|
+
angle?: string | number;
|
|
10
|
+
}
|
|
11
|
+
interface GlowOptions extends EffectBaseOptions {
|
|
12
|
+
color?: string;
|
|
13
|
+
blur?: string | number;
|
|
14
|
+
spread?: string | number;
|
|
15
|
+
opacity?: number;
|
|
16
|
+
}
|
|
17
|
+
interface NoiseOptions extends EffectBaseOptions {
|
|
18
|
+
size?: string | number;
|
|
19
|
+
intensity?: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare function useGradientBorderEffect<T extends HTMLElement = HTMLElement>(options?: GradientBorderOptions): (next: T | null) => void;
|
|
23
|
+
|
|
24
|
+
declare function useGlowEffect<T extends HTMLElement = HTMLElement>(options?: GlowOptions): (next: T | null) => void;
|
|
25
|
+
|
|
26
|
+
declare function useNoiseEffect<T extends HTMLElement = HTMLElement>(options?: NoiseOptions): (next: T | null) => void;
|
|
27
|
+
|
|
28
|
+
export { type EffectBaseOptions, type GlowOptions, type GradientBorderOptions, type NoiseOptions, useGlowEffect, useGradientBorderEffect, useNoiseEffect };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// src/effects/useGradientBorderEffect.ts
|
|
2
|
+
import { toCssAngle, toCssLength } from "@protohiro/effects-core";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
|
|
5
|
+
// src/shared/effectStyles.ts
|
|
6
|
+
var EFFECT_STYLES = `
|
|
7
|
+
.pe-gradient-border {
|
|
8
|
+
position: relative;
|
|
9
|
+
border-radius: var(--pe-gb-radius, inherit);
|
|
10
|
+
border: var(--pe-gb-thickness, 2px) solid transparent;
|
|
11
|
+
background:
|
|
12
|
+
linear-gradient(var(--pe-bg-fill, transparent), var(--pe-bg-fill, transparent)) padding-box,
|
|
13
|
+
linear-gradient(var(--pe-gb-angle, 120deg), var(--pe-gb-colors, #5eead4, #0ea5e9)) border-box;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.pe-glow {
|
|
17
|
+
box-shadow:
|
|
18
|
+
0 0 var(--pe-glow-blur, 24px)
|
|
19
|
+
color-mix(in srgb, var(--pe-glow-color, #38bdf8) calc(var(--pe-glow-opacity, 0.4) * 100%), transparent),
|
|
20
|
+
0 0 var(--pe-glow-spread, 2px)
|
|
21
|
+
color-mix(in srgb, var(--pe-glow-color, #38bdf8) calc(var(--pe-glow-opacity, 0.2) * 100%), transparent);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.pe-noise {
|
|
25
|
+
position: relative;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.pe-noise::after {
|
|
29
|
+
content: '';
|
|
30
|
+
position: absolute;
|
|
31
|
+
inset: 0;
|
|
32
|
+
border-radius: inherit;
|
|
33
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.95' numOctaves='2' seed='13' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
|
|
34
|
+
background-size: var(--pe-noise-size, 80px) var(--pe-noise-size, 80px);
|
|
35
|
+
background-repeat: repeat;
|
|
36
|
+
image-rendering: pixelated;
|
|
37
|
+
filter: contrast(190%) brightness(110%);
|
|
38
|
+
opacity: var(--pe-noise-opacity, 0.28);
|
|
39
|
+
pointer-events: none;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@media (prefers-reduced-motion: reduce) {
|
|
43
|
+
.pe-noise::after {
|
|
44
|
+
opacity: calc(var(--pe-noise-opacity, 0.28) * 0.9);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
// src/shared/useCssEffect.ts
|
|
50
|
+
import { applyCssVars, applyEffectClass, ensureGlobalStyle } from "@protohiro/effects-core";
|
|
51
|
+
import { useCallback, useEffect, useState } from "react";
|
|
52
|
+
function useCssEffect(input) {
|
|
53
|
+
const [node, setNode] = useState(null);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (!node || input.disabled) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
ensureGlobalStyle(input.styleId, input.styleText);
|
|
59
|
+
const cleanups = [];
|
|
60
|
+
cleanups.push(applyEffectClass(node, input.className));
|
|
61
|
+
if (input.userClassName) {
|
|
62
|
+
cleanups.push(applyEffectClass(node, input.userClassName));
|
|
63
|
+
}
|
|
64
|
+
cleanups.push(applyCssVars(node, input.vars));
|
|
65
|
+
return () => {
|
|
66
|
+
for (const cleanup of cleanups.reverse()) {
|
|
67
|
+
cleanup();
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}, [
|
|
71
|
+
node,
|
|
72
|
+
input.className,
|
|
73
|
+
input.userClassName,
|
|
74
|
+
input.disabled,
|
|
75
|
+
input.styleId,
|
|
76
|
+
input.styleText,
|
|
77
|
+
input.vars
|
|
78
|
+
]);
|
|
79
|
+
return useCallback((next) => {
|
|
80
|
+
setNode(next);
|
|
81
|
+
}, []);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// src/effects/useGradientBorderEffect.ts
|
|
85
|
+
var STYLE_ID = "protohiro-effects-base";
|
|
86
|
+
function useGradientBorderEffect(options = {}) {
|
|
87
|
+
const vars = useMemo(
|
|
88
|
+
() => ({
|
|
89
|
+
"--pe-gb-thickness": toCssLength(options.thickness),
|
|
90
|
+
"--pe-gb-radius": toCssLength(options.radius),
|
|
91
|
+
"--pe-gb-colors": options.colors,
|
|
92
|
+
"--pe-gb-angle": toCssAngle(options.angle)
|
|
93
|
+
}),
|
|
94
|
+
[options.thickness, options.radius, options.colors, options.angle]
|
|
95
|
+
);
|
|
96
|
+
return useCssEffect({
|
|
97
|
+
className: "pe-gradient-border",
|
|
98
|
+
userClassName: options.className,
|
|
99
|
+
vars,
|
|
100
|
+
disabled: options.disabled,
|
|
101
|
+
styleId: STYLE_ID,
|
|
102
|
+
styleText: EFFECT_STYLES
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// src/effects/useGlowEffect.ts
|
|
107
|
+
import { toCssLength as toCssLength2, toCssNumber } from "@protohiro/effects-core";
|
|
108
|
+
import { useMemo as useMemo2 } from "react";
|
|
109
|
+
var STYLE_ID2 = "protohiro-effects-base";
|
|
110
|
+
function useGlowEffect(options = {}) {
|
|
111
|
+
const vars = useMemo2(
|
|
112
|
+
() => ({
|
|
113
|
+
"--pe-glow-color": options.color,
|
|
114
|
+
"--pe-glow-blur": toCssLength2(options.blur),
|
|
115
|
+
"--pe-glow-spread": toCssLength2(options.spread),
|
|
116
|
+
"--pe-glow-opacity": toCssNumber(options.opacity)
|
|
117
|
+
}),
|
|
118
|
+
[options.color, options.blur, options.spread, options.opacity]
|
|
119
|
+
);
|
|
120
|
+
return useCssEffect({
|
|
121
|
+
className: "pe-glow",
|
|
122
|
+
userClassName: options.className,
|
|
123
|
+
vars,
|
|
124
|
+
disabled: options.disabled,
|
|
125
|
+
styleId: STYLE_ID2,
|
|
126
|
+
styleText: EFFECT_STYLES
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// src/effects/useNoiseEffect.ts
|
|
131
|
+
import { toCssLength as toCssLength3, toCssNumber as toCssNumber2 } from "@protohiro/effects-core";
|
|
132
|
+
import { useMemo as useMemo3 } from "react";
|
|
133
|
+
var STYLE_ID3 = "protohiro-effects-base";
|
|
134
|
+
function clampUnit(value) {
|
|
135
|
+
if (value === void 0) {
|
|
136
|
+
return void 0;
|
|
137
|
+
}
|
|
138
|
+
if (Number.isNaN(value)) {
|
|
139
|
+
return void 0;
|
|
140
|
+
}
|
|
141
|
+
return Math.max(0, Math.min(1, value));
|
|
142
|
+
}
|
|
143
|
+
function useNoiseEffect(options = {}) {
|
|
144
|
+
const intensity = clampUnit(options.intensity);
|
|
145
|
+
const vars = useMemo3(
|
|
146
|
+
() => ({
|
|
147
|
+
"--pe-noise-size": toCssLength3(options.size ?? 120),
|
|
148
|
+
"--pe-noise-opacity": toCssNumber2(intensity ?? 0.2)
|
|
149
|
+
}),
|
|
150
|
+
[options.size, intensity]
|
|
151
|
+
);
|
|
152
|
+
return useCssEffect({
|
|
153
|
+
className: "pe-noise",
|
|
154
|
+
userClassName: options.className,
|
|
155
|
+
vars,
|
|
156
|
+
disabled: options.disabled,
|
|
157
|
+
styleId: STYLE_ID3,
|
|
158
|
+
styleText: EFFECT_STYLES
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
export {
|
|
162
|
+
useGlowEffect,
|
|
163
|
+
useGradientBorderEffect,
|
|
164
|
+
useNoiseEffect
|
|
165
|
+
};
|
|
166
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/effects/useGradientBorderEffect.ts","../src/shared/effectStyles.ts","../src/shared/useCssEffect.ts","../src/effects/useGlowEffect.ts","../src/effects/useNoiseEffect.ts"],"sourcesContent":["import { toCssAngle, toCssLength } from '@protohiro/effects-core';\nimport { useMemo } from 'react';\n\nimport type { GradientBorderOptions } from '../types';\nimport { EFFECT_STYLES } from '../shared/effectStyles';\nimport { useCssEffect } from '../shared/useCssEffect';\n\nconst STYLE_ID = 'protohiro-effects-base';\n\nexport function useGradientBorderEffect<T extends HTMLElement = HTMLElement>(\n options: GradientBorderOptions = {},\n) {\n const vars = useMemo(\n () => ({\n '--pe-gb-thickness': toCssLength(options.thickness),\n '--pe-gb-radius': toCssLength(options.radius),\n '--pe-gb-colors': options.colors,\n '--pe-gb-angle': toCssAngle(options.angle),\n }),\n [options.thickness, options.radius, options.colors, options.angle],\n );\n\n return useCssEffect<T>({\n className: 'pe-gradient-border',\n userClassName: options.className,\n vars,\n disabled: options.disabled,\n styleId: STYLE_ID,\n styleText: EFFECT_STYLES,\n });\n}\n","export const EFFECT_STYLES = `\n.pe-gradient-border {\n position: relative;\n border-radius: var(--pe-gb-radius, inherit);\n border: var(--pe-gb-thickness, 2px) solid transparent;\n background:\n linear-gradient(var(--pe-bg-fill, transparent), var(--pe-bg-fill, transparent)) padding-box,\n linear-gradient(var(--pe-gb-angle, 120deg), var(--pe-gb-colors, #5eead4, #0ea5e9)) border-box;\n}\n\n.pe-glow {\n box-shadow:\n 0 0 var(--pe-glow-blur, 24px)\n color-mix(in srgb, var(--pe-glow-color, #38bdf8) calc(var(--pe-glow-opacity, 0.4) * 100%), transparent),\n 0 0 var(--pe-glow-spread, 2px)\n color-mix(in srgb, var(--pe-glow-color, #38bdf8) calc(var(--pe-glow-opacity, 0.2) * 100%), transparent);\n}\n\n.pe-noise {\n position: relative;\n}\n\n.pe-noise::after {\n content: '';\n position: absolute;\n inset: 0;\n border-radius: inherit;\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.95' numOctaves='2' seed='13' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E\");\n background-size: var(--pe-noise-size, 80px) var(--pe-noise-size, 80px);\n background-repeat: repeat;\n image-rendering: pixelated;\n filter: contrast(190%) brightness(110%);\n opacity: var(--pe-noise-opacity, 0.28);\n pointer-events: none;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .pe-noise::after {\n opacity: calc(var(--pe-noise-opacity, 0.28) * 0.9);\n }\n}\n`;\n","import { applyCssVars, applyEffectClass, ensureGlobalStyle } from '@protohiro/effects-core';\nimport { useCallback, useEffect, useState } from 'react';\n\ntype UseCssEffectInput = {\n className: string;\n userClassName?: string;\n vars: Record<string, string | undefined>;\n disabled?: boolean;\n styleId: string;\n styleText: string;\n};\n\nexport function useCssEffect<T extends HTMLElement>(input: UseCssEffectInput) {\n const [node, setNode] = useState<T | null>(null);\n\n useEffect(() => {\n if (!node || input.disabled) {\n return;\n }\n\n ensureGlobalStyle(input.styleId, input.styleText);\n\n const cleanups: Array<() => void> = [];\n cleanups.push(applyEffectClass(node, input.className));\n\n if (input.userClassName) {\n cleanups.push(applyEffectClass(node, input.userClassName));\n }\n\n cleanups.push(applyCssVars(node, input.vars));\n\n return () => {\n for (const cleanup of cleanups.reverse()) {\n cleanup();\n }\n };\n }, [\n node,\n input.className,\n input.userClassName,\n input.disabled,\n input.styleId,\n input.styleText,\n input.vars,\n ]);\n\n return useCallback((next: T | null) => {\n setNode(next);\n }, []);\n}\n","import { toCssLength, toCssNumber } from '@protohiro/effects-core';\nimport { useMemo } from 'react';\n\nimport type { GlowOptions } from '../types';\nimport { EFFECT_STYLES } from '../shared/effectStyles';\nimport { useCssEffect } from '../shared/useCssEffect';\n\nconst STYLE_ID = 'protohiro-effects-base';\n\nexport function useGlowEffect<T extends HTMLElement = HTMLElement>(options: GlowOptions = {}) {\n const vars = useMemo(\n () => ({\n '--pe-glow-color': options.color,\n '--pe-glow-blur': toCssLength(options.blur),\n '--pe-glow-spread': toCssLength(options.spread),\n '--pe-glow-opacity': toCssNumber(options.opacity),\n }),\n [options.color, options.blur, options.spread, options.opacity],\n );\n\n return useCssEffect<T>({\n className: 'pe-glow',\n userClassName: options.className,\n vars,\n disabled: options.disabled,\n styleId: STYLE_ID,\n styleText: EFFECT_STYLES,\n });\n}\n","import { toCssLength, toCssNumber } from '@protohiro/effects-core';\nimport { useMemo } from 'react';\n\nimport type { NoiseOptions } from '../types';\nimport { EFFECT_STYLES } from '../shared/effectStyles';\nimport { useCssEffect } from '../shared/useCssEffect';\n\nconst STYLE_ID = 'protohiro-effects-base';\n\nfunction clampUnit(value: number | undefined): number | undefined {\n if (value === undefined) {\n return undefined;\n }\n\n if (Number.isNaN(value)) {\n return undefined;\n }\n\n return Math.max(0, Math.min(1, value));\n}\n\nexport function useNoiseEffect<T extends HTMLElement = HTMLElement>(options: NoiseOptions = {}) {\n const intensity = clampUnit(options.intensity);\n\n const vars = useMemo(\n () => ({\n '--pe-noise-size': toCssLength(options.size ?? 120),\n '--pe-noise-opacity': toCssNumber(intensity ?? 0.2),\n }),\n [options.size, intensity],\n );\n\n return useCssEffect<T>({\n className: 'pe-noise',\n userClassName: options.className,\n vars,\n disabled: options.disabled,\n styleId: STYLE_ID,\n styleText: EFFECT_STYLES,\n });\n}\n"],"mappings":";AAAA,SAAS,YAAY,mBAAmB;AACxC,SAAS,eAAe;;;ACDjB,IAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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AW;AAAA,IACX,eAAe,QAAQ;AAAA,IACvB;AAAA,IACA,UAAU,QAAQ;AAAA,IAClB,SAASH;AAAA,IACT,WAAW;AAAA,EACb,CAAC;AACH;","names":["toCssLength","useMemo","STYLE_ID","useMemo","toCssLength","toCssLength","toCssNumber","useMemo","STYLE_ID","useMemo","toCssLength","toCssNumber"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@protohiro/effects",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Zero-wrapper React hooks for composable CSS effects.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/snwol/protoeffects.git",
|
|
13
|
+
"directory": "packages/react"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/snwol/protoeffects#readme",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/snwol/protoeffects/issues"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"protoeffects",
|
|
21
|
+
"react",
|
|
22
|
+
"hooks",
|
|
23
|
+
"css",
|
|
24
|
+
"effects"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/index.js",
|
|
33
|
+
"require": "./dist/index.cjs"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"README.md"
|
|
39
|
+
],
|
|
40
|
+
"sideEffects": false,
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@protohiro/effects-core": "0.1.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"react": "^18.0.0",
|
|
46
|
+
"react-dom": "^18.0.0"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsup",
|
|
50
|
+
"clean": "rm -rf dist",
|
|
51
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
52
|
+
}
|
|
53
|
+
}
|