weasel-icons 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +65 -2
- package/THIRD_PARTY_NOTICES.md +93 -0
- package/dist/icons/bell/bell-icon.d.ts +5 -0
- package/dist/icons/bell/bell-icon.js +22 -0
- package/dist/icons/bell/bell-rig.d.ts +14 -0
- package/dist/icons/bell/bell-rig.js +21 -0
- package/dist/icons/dog/dog-icon.d.ts +7 -0
- package/dist/icons/dog/dog-icon.js +45 -0
- package/dist/icons/dog/dog-rig.d.ts +80 -0
- package/dist/icons/dog/dog-rig.js +285 -0
- package/dist/icons/download/download-icon.d.ts +5 -0
- package/dist/icons/download/download-icon.js +23 -0
- package/dist/icons/download/download-rig.d.ts +19 -0
- package/dist/icons/download/download-rig.js +71 -0
- package/dist/icons/heart/heart-art.d.ts +4 -0
- package/dist/icons/heart/heart-art.js +6 -0
- package/dist/icons/heart/heart-icon.d.ts +6 -0
- package/dist/icons/heart/heart-icon.js +36 -0
- package/dist/icons/heart/heart-rig.d.ts +21 -0
- package/dist/icons/heart/heart-rig.js +68 -0
- package/dist/icons/leaf/leaf-icon.d.ts +6 -0
- package/dist/icons/leaf/leaf-icon.js +29 -0
- package/dist/icons/leaf/leaf-rig.d.ts +25 -0
- package/dist/icons/leaf/leaf-rig.js +201 -0
- package/dist/icons/monkey/monkey-icon.d.ts +11 -0
- package/dist/icons/monkey/monkey-icon.js +44 -0
- package/dist/icons/monkey/monkey-rig.d.ts +77 -0
- package/dist/icons/monkey/monkey-rig.js +376 -0
- package/dist/icons/rocket/rocket-art.d.ts +7 -0
- package/dist/icons/rocket/rocket-art.js +8 -0
- package/dist/icons/rocket/rocket-icon.d.ts +5 -0
- package/dist/icons/rocket/rocket-icon.js +39 -0
- package/dist/icons/rocket/rocket-rig.d.ts +30 -0
- package/dist/icons/rocket/rocket-rig.js +116 -0
- package/dist/icons/search/search-icon.d.ts +5 -0
- package/dist/icons/search/search-icon.js +21 -0
- package/dist/icons/search/search-rig.d.ts +14 -0
- package/dist/icons/search/search-rig.js +22 -0
- package/dist/icons/ship/ship-art.d.ts +3 -0
- package/dist/icons/ship/ship-art.js +5 -0
- package/dist/icons/ship/ship-icon.d.ts +6 -0
- package/dist/icons/ship/ship-icon.js +42 -0
- package/dist/icons/ship/ship-rig.d.ts +65 -0
- package/dist/icons/ship/ship-rig.js +206 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +10 -0
- package/dist/shared/behavior-curves.d.ts +4 -0
- package/dist/shared/behavior-curves.js +17 -0
- package/dist/shared/behavior-runtime.d.ts +18 -0
- package/dist/shared/behavior-runtime.js +110 -0
- package/dist/shared/icon-colors.d.ts +34 -0
- package/dist/shared/icon-colors.js +1 -0
- package/dist/shared/icon-types.d.ts +13 -0
- package/dist/shared/icon-types.js +1 -0
- package/dist/shared/pose-spring.d.ts +9 -0
- package/dist/shared/pose-spring.js +13 -0
- package/dist/shared/use-icon-motion.d.ts +10 -0
- package/dist/shared/use-icon-motion.js +72 -0
- package/dist/shared/use-motion-preference.d.ts +1 -0
- package/dist/shared/use-motion-preference.js +32 -0
- package/package.json +91 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Weasel contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,66 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Weasel Icons
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Icons that overreact beautifully. Nine stateful React SVG icons with smooth transitions and optional continuous behavior.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install weasel-icons
|
|
9
|
+
# or
|
|
10
|
+
pnpm add weasel-icons
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Requires React 19 and React DOM 19. Motion is installed as a dependency. No stylesheet, provider, Tailwind, or Next.js dependency is required. The package is ESM with TypeScript declarations and per-icon exports.
|
|
14
|
+
|
|
15
|
+
## Use
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { DogIcon } from 'weasel-icons';
|
|
19
|
+
// Alternatively: import { DogIcon } from 'weasel-icons/dog';
|
|
20
|
+
|
|
21
|
+
export function HappyDog() {
|
|
22
|
+
return <DogIcon state="happy" alive size={32} color="#75002f" accentColor="#ff5ca3" />;
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Import only the icons you use. Compatible production bundlers can tree-shake the others.
|
|
27
|
+
|
|
28
|
+
## Change a state
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
'use client';
|
|
32
|
+
|
|
33
|
+
import { useState } from 'react';
|
|
34
|
+
import { HeartIcon } from 'weasel-icons';
|
|
35
|
+
|
|
36
|
+
export function LikeButton() {
|
|
37
|
+
const [liked, setLiked] = useState(false);
|
|
38
|
+
return (
|
|
39
|
+
<button aria-label="Like" aria-pressed={liked} onClick={() => setLiked(!liked)}>
|
|
40
|
+
<HeartIcon state={liked ? 'liked' : 'unliked'} size={24} />
|
|
41
|
+
</button>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The existing SVG smoothly transitions when `state` changes, including during an unfinished transition. Use your own button or wrapper for hover, click, keyboard, and sequence behavior. Next.js App Router client boundaries are preserved in the package.
|
|
47
|
+
|
|
48
|
+
## Icons and props
|
|
49
|
+
|
|
50
|
+
Exports: `DogIcon`, `MonkeyIcon`, `HeartIcon`, `ShipIcon`, `RocketIcon`, `LeafIcon`, `SearchIcon`, `BellIcon`, and `DownloadIcon`. Each exports its own state type and list, for example `DogState` and `dogStates`. TypeScript autocompletion shows the valid states for each icon.
|
|
51
|
+
|
|
52
|
+
Common optional props: `state`, `size`, `color`, `accentColor`, `strokeWidth`, `speed`, `alive`, `className`.
|
|
53
|
+
|
|
54
|
+
- `alive={false}` (default) transitions to the state, then settles.
|
|
55
|
+
- `alive` adds varied continuous in-state behavior. System reduced-motion preferences take precedence.
|
|
56
|
+
- `color` and `accentColor` default to `currentColor`.
|
|
57
|
+
- Dog, monkey, heart, ship, and leaf accept small icon-specific `colors` objects, with exported types such as `DogColors`.
|
|
58
|
+
- Dog and ship have neutral interiors using `--weasel-surface` (white by default). Set this CSS variable on their parent for other backgrounds. Monkey supports `colors.face`.
|
|
59
|
+
|
|
60
|
+
SVGs are decorative and hidden from screen readers. Label the containing control or adjacent status text. Do not communicate state using only color or animation.
|
|
61
|
+
|
|
62
|
+
This package installs into `node_modules`; it does not copy source into your components directory and does not expose an `npx` command. Upgrading the dependency brings new icons and fixes; it does not update already deployed websites until you rebuild and deploy them.
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
Original code is MIT licensed. Adapted source geometry retains its upstream notices in `THIRD_PARTY_NOTICES.md`, included with this package. The website, mascot, fonts, tests, and authoring tools are not part of this package.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
The animated components in this project use original Weasel motion design on top of the following source geometry.
|
|
4
|
+
|
|
5
|
+
## Lucide
|
|
6
|
+
|
|
7
|
+
Rocket, Leaf, Dog, Heart, Ship, Bell, Search, and Download base SVG geometry is adapted from [Lucide](https://github.com/lucide-icons/lucide), licensed under the ISC License, with the additional Feather notice below for Search and Download. The current front-facing ship replaces the earlier Fluent side-profile implementation. Source SVGs for Bell, Search, Download and their inspected state references are retained in `docs/references/lucide-*.svg`.
|
|
8
|
+
|
|
9
|
+
The retained Dog geometry carries the following [Lucide ISC notice](https://lucide.dev/license):
|
|
10
|
+
|
|
11
|
+
```text
|
|
12
|
+
ISC License
|
|
13
|
+
|
|
14
|
+
Copyright (c) 2026 Lucide Icons and Contributors
|
|
15
|
+
|
|
16
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
17
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
18
|
+
and this permission notice appear in all copies.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
21
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
22
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
23
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
24
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
25
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
26
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Feather-derived Lucide icons
|
|
30
|
+
|
|
31
|
+
Search and Download are listed by Lucide as derived from Feather. Their additional notice is retained from the [upstream license](https://github.com/lucide-icons/lucide/blob/main/LICENSE):
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
The MIT License (MIT)
|
|
35
|
+
|
|
36
|
+
Copyright (c) 2013-present Cole Bemis
|
|
37
|
+
|
|
38
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
39
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
40
|
+
in the Software without restriction, including without limitation the rights
|
|
41
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
42
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
43
|
+
furnished to do so, subject to the following conditions:
|
|
44
|
+
|
|
45
|
+
The above copyright notice and this permission notice shall be included in all
|
|
46
|
+
copies or substantial portions of the Software.
|
|
47
|
+
|
|
48
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
49
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
50
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
51
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
52
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
53
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
54
|
+
SOFTWARE.
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Microsoft Fluent Emoji
|
|
58
|
+
|
|
59
|
+
Monkey Face base SVG geometry is adapted from [Microsoft Fluent Emoji](https://github.com/microsoft/fluentui-emoji), licensed under the MIT License. Historical ship and dog references (not used by the current outline components), and the complete Microsoft copyright/permission notice are retained in `docs/references/`.
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
MIT License
|
|
63
|
+
|
|
64
|
+
Copyright (c) Microsoft Corporation.
|
|
65
|
+
|
|
66
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
67
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
68
|
+
in the Software without restriction, including without limitation the rights
|
|
69
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
70
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
71
|
+
furnished to do so, subject to the following conditions:
|
|
72
|
+
|
|
73
|
+
The above copyright notice and this permission notice shall be included in all
|
|
74
|
+
copies or substantial portions of the Software.
|
|
75
|
+
|
|
76
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
77
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
78
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
79
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
80
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
81
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
82
|
+
SOFTWARE
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
All animation choreography, state behavior, state effects, and playground presentation are original to this project.
|
|
86
|
+
|
|
87
|
+
## Motion study reference
|
|
88
|
+
|
|
89
|
+
The animation system was informed by the part-level motion principles demonstrated by [lucide-animated](https://github.com/pqoqubbw/icons), licensed under the MIT License. Weasel does not redistribute its React components; the state model and choreography in this project are independently authored.
|
|
90
|
+
|
|
91
|
+
## Website fonts
|
|
92
|
+
|
|
93
|
+
The playground self-hosts unmodified Latin WOFF2 assets for [Anton](https://github.com/google/fonts/tree/main/ofl/anton) and [DM Sans](https://github.com/google/fonts/tree/main/ofl/dmsans), distributed by Google Fonts under the SIL Open Font License 1.1. Their complete copyright and license notices are included alongside the assets at `public/fonts/anton/OFL.txt` and `public/fonts/dm-sans/OFL.txt`. These website assets are not included in the icon installation payloads.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { StatefulIconProps } from "../../shared/icon-types.js";
|
|
2
|
+
import { type BellState } from "./bell-rig.js";
|
|
3
|
+
export { bellStates, type BellState } from "./bell-rig.js";
|
|
4
|
+
export type BellIconProps = StatefulIconProps<BellState>;
|
|
5
|
+
export declare const BellIcon: import("react").NamedExoticComponent<BellIconProps>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { memo, useId, useRef } from 'react';
|
|
4
|
+
import { motion, useTransform } from 'motion/react';
|
|
5
|
+
import { useMotionPreference } from "../../shared/use-motion-preference.js";
|
|
6
|
+
import { usePoseWeight, useBehaviorClock } from "../../shared/use-icon-motion.js";
|
|
7
|
+
import { sampleBell, BELL_SHELL, BELL_CLAPPER } from "./bell-rig.js";
|
|
8
|
+
export { bellStates } from "./bell-rig.js";
|
|
9
|
+
const ORIGIN = { originX: 0, originY: 0, transformBox: 'view-box' };
|
|
10
|
+
export const BellIcon = memo(function BellIcon({ state = 'idle', size = 24, color = 'currentColor', accentColor = 'currentColor', strokeWidth = 1.8, speed = 1, alive = false, className, }) {
|
|
11
|
+
const reduced = useMotionPreference(), element = useRef(null), id = useId();
|
|
12
|
+
const pace = Number.isFinite(speed) ? Math.min(4, Math.max(0.1, speed)) : 1;
|
|
13
|
+
const idle = usePoseWeight(state === 'idle', pace, reduced), ringing = usePoseWeight(state === 'ringing', pace, reduced);
|
|
14
|
+
const unread = usePoseWeight(state === 'unread', pace, reduced), muted = usePoseWeight(state === 'muted', pace, reduced);
|
|
15
|
+
const performs = alive && !reduced && (state === 'ringing' || state === 'unread'), life = usePoseWeight(performs, pace, reduced);
|
|
16
|
+
const time = useBehaviorClock(element, performs, pace, life);
|
|
17
|
+
const rig = useTransform(() => sampleBell([idle.get(), ringing.get(), unread.get(), muted.get()], time.get(), life.get()));
|
|
18
|
+
const body = useTransform(rig, (r) => r.body), clapper = useTransform(rig, (r) => r.clapper), cut = useTransform(rig, (r) => r.cut);
|
|
19
|
+
const ringOpacity = useTransform(rig, (r) => r.ringing), badge = useTransform(rig, (r) => r.badge), mute = useTransform(rig, (r) => r.muted);
|
|
20
|
+
const badgeRadius = useTransform(rig, (r) => r.badgeScale * 1.65);
|
|
21
|
+
return (_jsxs("svg", { ref: element, className: className, width: size, height: size, viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", fill: "none", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", focusable: "false", pointerEvents: "none", style: { display: 'block', overflow: 'visible' }, children: [_jsx("defs", { children: _jsx("clipPath", { id: id, children: _jsx(motion.path, { "data-part": "mute-cut", d: cut }) }) }), _jsx(motion.path, { "data-layer": "bell-sound", d: "M2.5 6.5C2.7 5.2 3.2 4.2 4 3.2M20 3.2c.8 1 1.3 2 1.5 3.3", stroke: accentColor, strokeWidth: strokeWidth * 0.65, opacity: ringOpacity }), _jsxs(motion.g, { "data-layer": "bell-body", transform: body, style: ORIGIN, children: [_jsxs("g", { clipPath: `url(#${id})`, children: [_jsx("path", { "data-part": "shell", d: BELL_SHELL, stroke: color, strokeWidth: strokeWidth }), _jsx(motion.path, { "data-part": "clapper", d: BELL_CLAPPER, stroke: color, strokeWidth: strokeWidth, transform: clapper, style: ORIGIN })] }), _jsx(motion.path, { "data-layer": "bell-mute", d: "M3 3l18 18", stroke: color, strokeWidth: strokeWidth, opacity: mute })] }), _jsx(motion.circle, { "data-layer": "bell-badge", cx: "19", cy: "4", r: badgeRadius, fill: accentColor, opacity: badge })] }));
|
|
22
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const bellStates: readonly ["idle", "ringing", "unread", "muted"];
|
|
2
|
+
export type BellState = (typeof bellStates)[number];
|
|
3
|
+
export type BellWeights = readonly [number, number, number, number];
|
|
4
|
+
export declare const BELL_SHELL = "M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326";
|
|
5
|
+
export declare const BELL_CLAPPER = "M10.268 21a2 2 0 0 0 3.464 0";
|
|
6
|
+
export declare function sampleBell([, ringing, unread, muted]: BellWeights, time?: number, alive?: number): {
|
|
7
|
+
body: string;
|
|
8
|
+
clapper: string;
|
|
9
|
+
cut: string;
|
|
10
|
+
ringing: number;
|
|
11
|
+
badge: number;
|
|
12
|
+
muted: number;
|
|
13
|
+
badgeScale: number;
|
|
14
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const bellStates = ['idle', 'ringing', 'unread', 'muted'];
|
|
2
|
+
export const BELL_SHELL = 'M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326';
|
|
3
|
+
export const BELL_CLAPPER = 'M10.268 21a2 2 0 0 0 3.464 0';
|
|
4
|
+
const n = (v) => Number(v.toFixed(5));
|
|
5
|
+
export function sampleBell([, ringing, unread, muted], time = 0, alive = 0) {
|
|
6
|
+
const life = Math.max(0, Math.min(1, alive));
|
|
7
|
+
const ring = Math.max(0, behaviorBeat(time % 3.4, 0.12, 0.28, 0.9, 0.75));
|
|
8
|
+
const notify = Math.max(0, behaviorBeat(time % 4.8, 0.3, 0.4, 0.1, 0.8));
|
|
9
|
+
const angle = ringing * (7 * (1 - life) + life * 10 * Math.sin(time * 10.6) * ring), gap = muted * 1.5;
|
|
10
|
+
const clapperAngle = ringing * life * -13 * Math.sin(time * 10.6 - 0.55) * ring;
|
|
11
|
+
return {
|
|
12
|
+
body: `translate(12px, 12px) scale(.86) translate(-12px, -12px) translate(12px, 4px) rotate(${n(angle)}deg) translate(-12px, -4px)`,
|
|
13
|
+
clapper: `translate(12px, 17px) rotate(${n(clapperAngle)}deg) translate(-12px, -17px)`,
|
|
14
|
+
cut: `M${n(gap)} 0H24V${n(24 - gap)}ZM0 ${n(gap)}V24H${n(24 - gap)}Z`,
|
|
15
|
+
ringing: ringing * (0.4 + life * 0.35 * ring),
|
|
16
|
+
badge: unread,
|
|
17
|
+
muted,
|
|
18
|
+
badgeScale: 1 + life * unread * 0.14 * notify,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
import { behaviorBeat } from "../../shared/behavior-curves.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DogColors } from "../../shared/icon-colors.js";
|
|
2
|
+
import type { StatefulIconProps } from "../../shared/icon-types.js";
|
|
3
|
+
import { type DogState } from "./dog-rig.js";
|
|
4
|
+
export { dogStates, type DogState } from "./dog-rig.js";
|
|
5
|
+
/** One Lucide-derived puppy, one owner per animated channel. No face replacement. */
|
|
6
|
+
export type DogIconProps = StatefulIconProps<DogState, DogColors>;
|
|
7
|
+
export declare const DogIcon: import("react").NamedExoticComponent<DogIconProps>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { memo, useId, useRef } from 'react';
|
|
4
|
+
import { motion, useTransform } from 'motion/react';
|
|
5
|
+
import { useFollowPose, useBehaviorClock, usePoseWeight } from "../../shared/use-icon-motion.js";
|
|
6
|
+
import { useMotionPreference } from "../../shared/use-motion-preference.js";
|
|
7
|
+
import { DOG_LEFT_EAR, DOG_RIGHT_EAR, DOG_OUTLINE, DOG_SURFACE, sampleDog, } from "./dog-rig.js";
|
|
8
|
+
export { dogStates } from "./dog-rig.js";
|
|
9
|
+
// Motion emits CSS transforms. The -3/-3 viewBox origin is offset back to
|
|
10
|
+
// SVG coordinate (0,0), so authored pivot coordinates remain exact.
|
|
11
|
+
const SVG_ORIGIN = { originX: '3px', originY: '3px', transformBox: 'view-box' };
|
|
12
|
+
export const DogIcon = memo(function DogIcon({ state = 'waiting', size = 24, color = 'currentColor', accentColor = 'currentColor', strokeWidth = 1.8, speed = 1, alive = false, className, colors, }) {
|
|
13
|
+
const reduced = useMotionPreference();
|
|
14
|
+
const element = useRef(null);
|
|
15
|
+
const mouthId = `puppy-mouth-${useId().replace(/:/g, '')}`;
|
|
16
|
+
const pace = Number.isFinite(speed) ? Math.min(4, Math.max(0.1, speed)) : 1;
|
|
17
|
+
const waiting = usePoseWeight(state === 'waiting', pace, reduced);
|
|
18
|
+
const sniffing = usePoseWeight(state === 'sniffing', pace, reduced);
|
|
19
|
+
const happy = usePoseWeight(state === 'happy', pace, reduced);
|
|
20
|
+
const guilty = usePoseWeight(state === 'guilty', pace, reduced);
|
|
21
|
+
const life = usePoseWeight(alive && !reduced, pace, reduced);
|
|
22
|
+
const time = useBehaviorClock(element, alive && !reduced, pace, life);
|
|
23
|
+
const rig = useTransform(() => sampleDog([waiting.get(), sniffing.get(), happy.get(), guilty.get()], time.get(), life.get()));
|
|
24
|
+
const leftEye = useTransform(rig, (r) => r.leftEye);
|
|
25
|
+
const rightEye = useTransform(rig, (r) => r.rightEye);
|
|
26
|
+
const mouth = useTransform(rig, (r) => r.mouth);
|
|
27
|
+
const leftEar = useTransform(rig, (r) => r.leftEar);
|
|
28
|
+
const rightEar = useTransform(rig, (r) => r.rightEar);
|
|
29
|
+
const nose = useTransform(rig, (r) => r.nose);
|
|
30
|
+
const tongueY = useTransform(rig, (r) => r.tongueY);
|
|
31
|
+
const tongueHeight = useTransform(rig, (r) => r.tongueHeight);
|
|
32
|
+
const tongueOpacity = useTransform(rig, (r) => r.tongueOpacity);
|
|
33
|
+
const blush = useTransform(rig, (r) => r.blush);
|
|
34
|
+
const scentPath = useTransform(rig, (r) => `M ${r.scentX} ${r.scentY - 0.7} q -.7 -.3 -1.15 .05 M ${r.scentX + 0.2} ${r.scentY + 0.75} q -.7 .3 -1.15 -.05`);
|
|
35
|
+
const scentOpacity = useTransform(rig, (r) => r.scentOpacity);
|
|
36
|
+
const sparkOpacity = useTransform(rig, (r) => r.sparkOpacity);
|
|
37
|
+
const tilt = useTransform(rig, (r) => r.tilt);
|
|
38
|
+
const height = useTransform(rig, (r) => r.headY);
|
|
39
|
+
const headTilt = useFollowPose(tilt, pace, reduced);
|
|
40
|
+
const headY = useFollowPose(height, pace, reduced);
|
|
41
|
+
const head = useTransform(() => `translate(12px, ${14 + headY.get()}px) rotate(${headTilt.get()}deg) translate(-12px, -14px)`);
|
|
42
|
+
const detailStroke = Math.max(0.35, strokeWidth * 0.38);
|
|
43
|
+
const surface = 'var(--weasel-surface, #fff)';
|
|
44
|
+
return (_jsxs("svg", { ref: element, className: className, width: size, height: size, viewBox: "-3 -3 30 30", xmlns: "http://www.w3.org/2000/svg", fill: "none", preserveAspectRatio: "xMidYMid meet", "aria-hidden": "true", focusable: "false", pointerEvents: "none", "data-dog-state": state, style: { display: 'block', overflow: 'visible' }, children: [_jsx("defs", { children: _jsx("clipPath", { id: mouthId, children: _jsx(motion.path, { d: mouth }) }) }), _jsxs(motion.g, { "data-layer": "face", style: SVG_ORIGIN, transform: head, strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("path", { d: DOG_SURFACE, fill: surface }), _jsx("path", { d: DOG_OUTLINE, stroke: color, strokeWidth: strokeWidth }), _jsx("path", { d: "M10.15 5.235Q12 4.6 14 5.277", stroke: color, strokeWidth: strokeWidth }), _jsx(motion.path, { "data-layer": "left-ear", style: SVG_ORIGIN, d: DOG_LEFT_EAR, transform: leftEar, stroke: color, fill: surface, strokeWidth: strokeWidth }), _jsx(motion.path, { "data-layer": "right-ear", style: SVG_ORIGIN, d: DOG_RIGHT_EAR, transform: rightEar, stroke: color, fill: surface, strokeWidth: strokeWidth }), _jsxs(motion.g, { "data-layer": "cheeks", opacity: blush, fill: accentColor, children: [_jsx("ellipse", { cx: "7.1", cy: "16.3", rx: ".8", ry: ".38" }), _jsx("ellipse", { cx: "16.9", cy: "16.3", rx: ".8", ry: ".38" })] }), _jsx(motion.path, { "data-layer": "left-eye", d: leftEye, fill: colors?.eyes ?? color }), _jsx(motion.path, { "data-layer": "right-eye", d: rightEye, fill: colors?.eyes ?? color }), _jsx(motion.path, { "data-layer": "nose", d: "M11.1 15.9Q12 15.55 12.9 15.9Q13.2 16.2 12 17Q10.8 16.2 11.1 15.9Z", style: SVG_ORIGIN, transform: nose, fill: colors?.nose ?? color }), _jsx(motion.path, { "data-layer": "mouth", d: mouth, fill: colors?.mouth ?? color, stroke: colors?.mouth ?? color, strokeWidth: detailStroke }), _jsx("g", { clipPath: `url(#${mouthId})`, children: _jsx(motion.rect, { "data-layer": "tongue", x: "11.2", y: tongueY, width: "1.6", height: tongueHeight, rx: ".65", opacity: tongueOpacity, fill: accentColor }) })] }), _jsx(motion.g, { "data-layer": "scent", opacity: scentOpacity, stroke: accentColor, strokeWidth: detailStroke, strokeLinecap: "round", children: _jsx(motion.path, { d: scentPath }) }), _jsx(motion.path, { "data-layer": "spark", opacity: sparkOpacity, d: "M.1 1.3v2M-.9 2.3h2M24.1 .5v1.4M23.4 1.2h1.4", stroke: accentColor, strokeWidth: detailStroke, strokeLinecap: "round" })] }));
|
|
45
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export declare const dogStates: readonly ["waiting", "sniffing", "happy", "guilty"];
|
|
2
|
+
export type DogState = (typeof dogStates)[number];
|
|
3
|
+
export type DogWeights = readonly [number, number, number, number];
|
|
4
|
+
export declare const DOG_LEFT_EAR = "M8.5 8.5c-.384 1.05-1.083 2.028-2.344 2.5-1.931.722-3.576-.297-3.656-1-.113-.994 1.177-6.53 4-7 1.923-.321 3.651.845 3.651 2.235";
|
|
5
|
+
export declare const DOG_RIGHT_EAR = "M14 5.277c0-1.39 1.844-2.598 3.767-2.277 2.823.47 4.113 6.006 4 7-.08.703-1.725 1.722-3.656 1-1.261-.472-1.855-1.45-2.239-2.5";
|
|
6
|
+
export declare const DOG_OUTLINE = "M4.42 11.247A13.152 13.152 0 0 0 4 14.556C4 18.728 7.582 21 12 21s8-2.272 8-6.444a11.702 11.702 0 0 0-.493-3.309";
|
|
7
|
+
export declare const DOG_SURFACE = "M4.42 11.247L8.5 5.4Q12 4.5 15.5 5.4L19.507 11.247A11.702 11.702 0 0 1 20 14.556C20 18.728 16.418 21 12 21S4 18.728 4 14.556A13.152 13.152 0 0 1 4.42 11.247Z";
|
|
8
|
+
interface DogPose {
|
|
9
|
+
gazeX: number;
|
|
10
|
+
gazeY: number;
|
|
11
|
+
eyeOpen: number;
|
|
12
|
+
eyeCurve: number;
|
|
13
|
+
eyeWidth: number;
|
|
14
|
+
mouthWidth: number;
|
|
15
|
+
mouthY: number;
|
|
16
|
+
top: number;
|
|
17
|
+
bottom: number;
|
|
18
|
+
earLeft: number;
|
|
19
|
+
earRight: number;
|
|
20
|
+
tilt: number;
|
|
21
|
+
headY: number;
|
|
22
|
+
nose: number;
|
|
23
|
+
noseX: number;
|
|
24
|
+
noseY: number;
|
|
25
|
+
tongue: number;
|
|
26
|
+
blush: number;
|
|
27
|
+
scent: number;
|
|
28
|
+
scentX: number;
|
|
29
|
+
scentY: number;
|
|
30
|
+
spark: number;
|
|
31
|
+
}
|
|
32
|
+
export declare const DOG_POSES: Record<DogState, DogPose>;
|
|
33
|
+
export declare const dogBehaviors: Record<DogState, readonly string[]>;
|
|
34
|
+
export declare const dogSceneDuration: (state: DogState) => 6 | 8;
|
|
35
|
+
export declare function sampleDogBehavior(state: DogState, time: number): {
|
|
36
|
+
pose: {
|
|
37
|
+
gazeX: number;
|
|
38
|
+
gazeY: number;
|
|
39
|
+
eyeOpen: number;
|
|
40
|
+
eyeCurve: number;
|
|
41
|
+
eyeWidth: number;
|
|
42
|
+
mouthWidth: number;
|
|
43
|
+
mouthY: number;
|
|
44
|
+
top: number;
|
|
45
|
+
bottom: number;
|
|
46
|
+
earLeft: number;
|
|
47
|
+
earRight: number;
|
|
48
|
+
tilt: number;
|
|
49
|
+
headY: number;
|
|
50
|
+
nose: number;
|
|
51
|
+
noseX: number;
|
|
52
|
+
noseY: number;
|
|
53
|
+
tongue: number;
|
|
54
|
+
blush: number;
|
|
55
|
+
scent: number;
|
|
56
|
+
scentX: number;
|
|
57
|
+
scentY: number;
|
|
58
|
+
spark: number;
|
|
59
|
+
};
|
|
60
|
+
scene: number;
|
|
61
|
+
};
|
|
62
|
+
export declare function sampleDog(weights: DogWeights, time?: number, alive?: number): {
|
|
63
|
+
leftEye: string;
|
|
64
|
+
rightEye: string;
|
|
65
|
+
mouth: string;
|
|
66
|
+
tilt: number;
|
|
67
|
+
headY: number;
|
|
68
|
+
leftEar: string;
|
|
69
|
+
rightEar: string;
|
|
70
|
+
nose: string;
|
|
71
|
+
tongueY: number;
|
|
72
|
+
tongueHeight: number;
|
|
73
|
+
tongueOpacity: number;
|
|
74
|
+
blush: number;
|
|
75
|
+
scentX: number;
|
|
76
|
+
scentY: number;
|
|
77
|
+
scentOpacity: number;
|
|
78
|
+
sparkOpacity: number;
|
|
79
|
+
};
|
|
80
|
+
export {};
|