takibi-design-system 0.1.0 → 0.2.1
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/LICENSES/CC-BY-SA-4.0.txt +428 -0
- package/README.md +13 -1
- package/dist/tokens.css +94 -52
- package/dist/tokens.json +269 -120
- package/package.json +17 -4
- package/src/components/accordion.tsx +1 -1
- package/src/components/alert-dialog.tsx +1 -1
- package/src/components/animated-number.tsx +4 -4
- package/src/components/avatar.tsx +1 -1
- package/src/components/banner.tsx +1 -1
- package/src/components/button.tsx +8 -31
- package/src/components/calendar.tsx +4 -4
- package/src/components/collapsible.tsx +1 -1
- package/src/components/combobox.tsx +3 -3
- package/src/components/command.tsx +1 -1
- package/src/components/dialog.tsx +1 -1
- package/src/components/drawer.tsx +4 -4
- package/src/components/empty-state.tsx +1 -1
- package/src/components/file-drop.tsx +2 -2
- package/src/components/interactive-card.tsx +21 -8
- package/src/components/link.tsx +1 -1
- package/src/components/list.tsx +3 -3
- package/src/components/meter.tsx +3 -1
- package/src/components/nav-list.tsx +1 -1
- package/src/components/navigation-menu.tsx +5 -5
- package/src/components/number-field.tsx +31 -5
- package/src/components/otp-field.tsx +1 -1
- package/src/components/preview-card.tsx +1 -1
- package/src/components/progress.tsx +1 -1
- package/src/components/radio-group.tsx +1 -1
- package/src/components/rating.tsx +3 -3
- package/src/components/scroll-area.tsx +1 -1
- package/src/components/select.tsx +1 -1
- package/src/components/skip-link.tsx +2 -2
- package/src/components/slider.tsx +7 -7
- package/src/components/sparks.tsx +110 -0
- package/src/components/steps.tsx +1 -1
- package/src/components/table.tsx +1 -1
- package/src/components/tag.tsx +3 -3
- package/src/components/theme-toggle.tsx +43 -15
- package/src/components/tree-view.tsx +2 -2
- package/src/embers.d.ts +3 -5
- package/src/embers.js +138 -247
- package/src/fire/base-day.webp +0 -0
- package/src/fire/base-night.webp +0 -0
- package/src/fire/engine.js +1067 -0
- package/src/fire/flame-still.webp +0 -0
- package/src/fire/flame.mp4 +0 -0
- package/src/fire/lit.webp +0 -0
- package/src/fire.d.ts +108 -0
- package/src/fire.js +618 -0
- package/src/index.ts +13 -1
- package/src/lib/daylight.ts +80 -0
- package/src/lib/glide.tsx +1 -1
- package/src/lib/motion.ts +21 -14
- package/src/lib/theme.ts +11 -4
- package/src/lib/warmth.ts +12 -0
- package/src/motion.css +370 -58
- package/src/stars-data.js +14 -0
- package/src/stars.d.ts +21 -0
- package/src/stars.js +181 -0
- package/src/tokens.css +275 -135
|
@@ -16,7 +16,7 @@ export type SliderProps = React.ComponentProps<typeof BaseSlider.Root> & {
|
|
|
16
16
|
/**
|
|
17
17
|
* 範囲の中から値を選ぶ。おおよその値でよいときに使い、正確な数を入れさせるときは NumberField を使う。
|
|
18
18
|
* `defaultValue` に配列を渡すと、ハンドルが 2 つの範囲の選択になる。
|
|
19
|
-
*
|
|
19
|
+
* ハンドルは押すと少し膨らみ、離すと載る曲線で戻る。値の帯はブランドカラーで塗る。
|
|
20
20
|
*/
|
|
21
21
|
export function Slider({
|
|
22
22
|
className,
|
|
@@ -64,7 +64,7 @@ export function Slider({
|
|
|
64
64
|
"rounded-full bg-brand select-none",
|
|
65
65
|
"group-hover/slider:not-group-data-disabled/slider:bg-brand-hover",
|
|
66
66
|
// キーで動かすと帯の端が滑って追う。指で動かしている間は遅れずに付いてくる
|
|
67
|
-
"transition-[inset-inline-start,width,height,background-color] duration-(--duration-
|
|
67
|
+
"transition-[inset-inline-start,width,height,background-color] duration-(--duration-sway) ease-sway group-data-dragging/slider:transition-[background-color]",
|
|
68
68
|
"group-data-invalid/slider:bg-danger",
|
|
69
69
|
)}
|
|
70
70
|
/>
|
|
@@ -101,7 +101,7 @@ function SliderThumb({
|
|
|
101
101
|
index={index}
|
|
102
102
|
className={cn(
|
|
103
103
|
"group/thumb relative flex size-5 items-center justify-center rounded-full outline-none select-none data-disabled:cursor-not-allowed",
|
|
104
|
-
"transition-[inset-inline-start,bottom] duration-(--duration-
|
|
104
|
+
"transition-[inset-inline-start,bottom] duration-(--duration-sway) ease-sway group-data-dragging/slider:transition-none",
|
|
105
105
|
)}
|
|
106
106
|
render={(thumbProps, state) => {
|
|
107
107
|
const active = state.dragging && state.activeThumbIndex === index;
|
|
@@ -113,18 +113,18 @@ function SliderThumb({
|
|
|
113
113
|
aria-hidden
|
|
114
114
|
className={cn(
|
|
115
115
|
"pointer-events-none absolute inset-0 rounded-full bg-brand-soft opacity-0 scale-50",
|
|
116
|
-
"transition-[opacity,scale] duration-(--duration-
|
|
116
|
+
"transition-[opacity,scale] duration-(--duration-ignite) ease-ignite",
|
|
117
117
|
"group-hover/thumb:not-group-data-disabled/slider:scale-150 group-hover/thumb:not-group-data-disabled/slider:opacity-100",
|
|
118
118
|
"group-has-focus-visible/thumb:scale-175 group-has-focus-visible/thumb:opacity-100",
|
|
119
119
|
"group-data-active/thumb:scale-200 group-data-active/thumb:opacity-100",
|
|
120
120
|
)}
|
|
121
121
|
/>
|
|
122
|
-
{/*
|
|
122
|
+
{/* ハンドル本体。押すと膨らみ、離すと載る曲線で戻る */}
|
|
123
123
|
<span
|
|
124
124
|
aria-hidden
|
|
125
125
|
className={cn(
|
|
126
126
|
"pointer-events-none relative size-4 rounded-full border-2 border-brand bg-thumb shadow-[0_1px_3px_rgb(0_0_0/0.35)]",
|
|
127
|
-
"transition-[scale,border-color] duration-(--duration-
|
|
127
|
+
"transition-[scale,border-color] duration-(--duration-land) ease-land",
|
|
128
128
|
"group-active/thumb:not-group-data-disabled/slider:scale-125 group-data-active/thumb:scale-125",
|
|
129
129
|
"group-has-focus-visible/thumb:outline-2 group-has-focus-visible/thumb:outline-offset-2 group-has-focus-visible/thumb:outline-focus",
|
|
130
130
|
"group-data-invalid/slider:border-danger",
|
|
@@ -137,7 +137,7 @@ function SliderThumb({
|
|
|
137
137
|
className={cn(
|
|
138
138
|
"pointer-events-none absolute bottom-full left-1/2 mb-2 -translate-x-1/2 origin-bottom",
|
|
139
139
|
"rounded-sm border border-line bg-surface-overlay px-1.5 py-0.5 text-xs font-medium whitespace-nowrap text-fg-strong tabular-nums shadow-card",
|
|
140
|
-
"transition-[opacity,scale,translate] duration-(--duration-
|
|
140
|
+
"transition-[opacity,scale,translate] duration-(--duration-ignite) ease-ignite",
|
|
141
141
|
showValue === "drag" && [
|
|
142
142
|
"translate-y-1 scale-90 opacity-0",
|
|
143
143
|
"group-data-active/thumb:translate-y-0 group-data-active/thumb:scale-100 group-data-active/thumb:opacity-100",
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "../lib/cn";
|
|
3
|
+
|
|
4
|
+
type Spark = {
|
|
5
|
+
left: string;
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
sway: number;
|
|
9
|
+
delay: number;
|
|
10
|
+
duration: number;
|
|
11
|
+
size: number;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const between = (min: number, max: number) => min + Math.random() * (max - min);
|
|
15
|
+
const side = () => (Math.random() < 0.5 ? -1 : 1);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 火の粉を count 個ばらまく。3 割は小さい粒で、速く高く飛んで 280〜460ms で消える。残りは大きい粒で、低くゆっくり上がって 520〜830ms で消える。
|
|
19
|
+
* 長さは、焚き火の計算モデルで火の粉の明るさが 1% になるまでの時間から取った(小さい粒 0.28 秒、大きい粒 0.83 秒)。
|
|
20
|
+
* 位置は横に等分した区画の中でずらすので、1 か所に固まらない。
|
|
21
|
+
*/
|
|
22
|
+
function scatter(count: number): Spark[] {
|
|
23
|
+
return Array.from({ length: count }, (_, i) => {
|
|
24
|
+
const pop = Math.random() < 0.3;
|
|
25
|
+
const x = side() * (pop ? between(6, 16) : between(2, 8));
|
|
26
|
+
return {
|
|
27
|
+
left: `${8 + ((i + Math.random()) / count) * 84}%`,
|
|
28
|
+
x,
|
|
29
|
+
y: -(pop ? between(26, 44) : between(14, 26)),
|
|
30
|
+
sway: -Math.sign(x) * between(1, 4),
|
|
31
|
+
delay: pop ? between(0, 40) : between(20, 160),
|
|
32
|
+
duration: pop ? between(280, 460) : between(520, 830),
|
|
33
|
+
size: pop ? between(2, 2.8) : between(2.4, 3.6),
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 右上の角の 1 点から、火の粉を count 個飛ばす。真上から右へ 60 度、左へ 35 度までの扇形に広がる。
|
|
40
|
+
* 薪の 1 か所がはぜたときと同じで、出どころは 1 点、飛ぶ先はばらばらになる。
|
|
41
|
+
*/
|
|
42
|
+
function burst(count: number): Spark[] {
|
|
43
|
+
return Array.from({ length: count }, () => {
|
|
44
|
+
const pop = Math.random() < 0.4;
|
|
45
|
+
const angle = between(-0.6, 1.05);
|
|
46
|
+
const reach = pop ? between(30, 46) : between(14, 28);
|
|
47
|
+
const x = Math.sin(angle) * reach;
|
|
48
|
+
return {
|
|
49
|
+
left: `calc(100% - ${between(7, 11)}px)`,
|
|
50
|
+
x,
|
|
51
|
+
y: -Math.cos(angle) * reach - 4,
|
|
52
|
+
sway: -Math.sign(x) * between(1, 4),
|
|
53
|
+
delay: pop ? between(0, 30) : between(10, 110),
|
|
54
|
+
duration: pop ? between(280, 460) : between(520, 830),
|
|
55
|
+
size: pop ? between(2, 2.8) : between(2.4, 3.4),
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type SparksProps = Omit<React.ComponentProps<"span">, "children"> & {
|
|
61
|
+
/** 火の粉の数。既定は 7。5〜9 に収める */
|
|
62
|
+
count?: number;
|
|
63
|
+
/** 縁から外へ広がる光(motion-flare)を一緒に出す。既定は true */
|
|
64
|
+
flare?: boolean;
|
|
65
|
+
/** 火の粉の出どころ。"edge" は上の縁の全体、"corner" は右上の角の 1 点。既定は "edge" */
|
|
66
|
+
from?: "edge" | "corner";
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* はぜる。完了の瞬間に、親の上の縁(from="corner" では右上の角の 1 点)から火の粉が数個だけ飛び、縁から光が外へ広がって消える。
|
|
71
|
+
* 親を position: relative にして、完了したときだけ描画する。飛ぶ先、速さ、大きさは描画のたびに変わる。
|
|
72
|
+
* 1 つの操作につき、主役の 1 か所だけに使う。動きを減らす設定では何も見えない。
|
|
73
|
+
*/
|
|
74
|
+
export function Sparks({ count = 7, flare = true, from = "edge", className, ...props }: SparksProps) {
|
|
75
|
+
// 乱数はサーバーとブラウザで値が変わるので、表示したあとに決める
|
|
76
|
+
const [sparks, setSparks] = React.useState<Spark[]>([]);
|
|
77
|
+
React.useEffect(() => setSparks(from === "corner" ? burst(count) : scatter(count)), [count, from]);
|
|
78
|
+
return (
|
|
79
|
+
<span
|
|
80
|
+
aria-hidden
|
|
81
|
+
data-slot="sparks"
|
|
82
|
+
className={cn(
|
|
83
|
+
"pointer-events-none absolute inset-0 rounded-[inherit]",
|
|
84
|
+
flare && "motion-flare",
|
|
85
|
+
className,
|
|
86
|
+
)}
|
|
87
|
+
{...props}
|
|
88
|
+
>
|
|
89
|
+
{sparks.map((s, i) => (
|
|
90
|
+
<span
|
|
91
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: 火の粉は描画のたびに作り直し、並べ替えない
|
|
92
|
+
key={i}
|
|
93
|
+
className="motion-spark absolute top-0 rounded-full shadow-[0_0_6px_var(--color-heat-ember)]"
|
|
94
|
+
style={
|
|
95
|
+
{
|
|
96
|
+
left: s.left,
|
|
97
|
+
width: s.size,
|
|
98
|
+
height: s.size,
|
|
99
|
+
"--spark-x": `${s.x}px`,
|
|
100
|
+
"--spark-y": `${s.y}px`,
|
|
101
|
+
"--spark-sway": `${s.sway}px`,
|
|
102
|
+
"--spark-delay": `${s.delay}ms`,
|
|
103
|
+
"--spark-duration": `${s.duration}ms`,
|
|
104
|
+
} as React.CSSProperties
|
|
105
|
+
}
|
|
106
|
+
/>
|
|
107
|
+
))}
|
|
108
|
+
</span>
|
|
109
|
+
);
|
|
110
|
+
}
|
package/src/components/steps.tsx
CHANGED
|
@@ -178,7 +178,7 @@ function StepConnector({ filled, orientation }: { filled: boolean; orientation:
|
|
|
178
178
|
{/* 導火線の先端。伸びている間の 0.7 秒だけ明るい点が出る */}
|
|
179
179
|
<motion.span
|
|
180
180
|
className={cn(
|
|
181
|
-
"absolute size-1.5 rounded-full bg-
|
|
181
|
+
"absolute size-1.5 rounded-full bg-heat-core shadow-[0_0_8px_2px_color-mix(in_oklab,var(--color-heat-flame)_70%,transparent)]",
|
|
182
182
|
horizontal
|
|
183
183
|
? "top-1/2 right-0 translate-x-1/2 -translate-y-1/2"
|
|
184
184
|
: "bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2",
|
package/src/components/table.tsx
CHANGED
|
@@ -118,7 +118,7 @@ export function TableHead({ className, sort, onSort, children, ...props }: Table
|
|
|
118
118
|
<ArrowUp
|
|
119
119
|
aria-hidden
|
|
120
120
|
className={cn(
|
|
121
|
-
"size-3.5 transition-
|
|
121
|
+
"size-3.5 [transition:rotate_var(--duration-sway)_var(--ease-sway),opacity_var(--duration-fast)_var(--ease-standard),color_var(--duration-fast)_var(--ease-standard)]",
|
|
122
122
|
sort === "descending" && "rotate-180",
|
|
123
123
|
sort === "none"
|
|
124
124
|
? "opacity-0 group-hover/sort:opacity-50 group-focus-visible/sort:opacity-50"
|
package/src/components/tag.tsx
CHANGED
|
@@ -86,7 +86,7 @@ export function Tag({ className, size, children, onRemove, removeLabel, ...props
|
|
|
86
86
|
initial={grouped && !reduce ? { opacity: 0, scale: 0.85, filter: "blur(2px)" } : false}
|
|
87
87
|
animate={{ opacity: 1, scale: 1, y: 0, filter: "blur(0px)" }}
|
|
88
88
|
exit={reduce ? { opacity: 0, transition: { duration: 0.12 } } : smoke}
|
|
89
|
-
transition={springs.
|
|
89
|
+
transition={springs.pop}
|
|
90
90
|
// 消えている最中のタグは操作させず、隣のタグを探すときにも数えない
|
|
91
91
|
data-exiting={present ? undefined : ""}
|
|
92
92
|
inert={!present}
|
|
@@ -150,7 +150,7 @@ export function SelectableTag({ className, size, children, ...props }: Selectabl
|
|
|
150
150
|
<span
|
|
151
151
|
aria-hidden
|
|
152
152
|
className={cn(
|
|
153
|
-
"-mr-1 grid grid-cols-[0fr] transition-[grid-template-columns,margin] duration-(--duration-
|
|
153
|
+
"-mr-1 grid grid-cols-[0fr] transition-[grid-template-columns,margin] duration-(--duration-sway) ease-sway",
|
|
154
154
|
"group-data-pressed/tag:mr-0 group-data-pressed/tag:grid-cols-[1fr]",
|
|
155
155
|
)}
|
|
156
156
|
>
|
|
@@ -158,7 +158,7 @@ export function SelectableTag({ className, size, children, ...props }: Selectabl
|
|
|
158
158
|
<Check
|
|
159
159
|
className={cn(
|
|
160
160
|
"scale-50 opacity-0 transition-[opacity,scale] duration-(--duration-fast) ease-out-expo",
|
|
161
|
-
"group-data-pressed/tag:scale-100 group-data-pressed/tag:opacity-100 group-data-pressed/tag:duration-(--duration-
|
|
161
|
+
"group-data-pressed/tag:scale-100 group-data-pressed/tag:opacity-100 group-data-pressed/tag:duration-(--duration-pop) group-data-pressed/tag:ease-pop",
|
|
162
162
|
)}
|
|
163
163
|
/>
|
|
164
164
|
</span>
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { Monitor, Moon, Sun } from "lucide-react";
|
|
1
|
+
import { Clock, Monitor, Moon, Sun } from "lucide-react";
|
|
2
2
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { cn } from "../lib/cn";
|
|
5
|
-
import {
|
|
5
|
+
import { applySky, skyAt, startDaylight } from "../lib/daylight";
|
|
6
|
+
import { amplitude, springs } from "../lib/motion";
|
|
6
7
|
import { setTheme, type Theme } from "../lib/theme";
|
|
7
8
|
import { Button, type ButtonProps } from "./button";
|
|
8
9
|
import { ToggleGroup, ToggleGroupItem } from "./toggle-group";
|
|
9
10
|
|
|
10
|
-
/**
|
|
11
|
-
export type ThemePreference = Theme | "system";
|
|
11
|
+
/** 夜、昼、端末の設定に合わせる、時刻に合わせる、の 4 つ */
|
|
12
|
+
export type ThemePreference = Theme | "system" | "time";
|
|
12
13
|
|
|
13
14
|
const DEFAULT_STORAGE_KEY = "takibi-theme";
|
|
14
15
|
const LIGHT_QUERY = "(prefers-color-scheme: light)";
|
|
@@ -16,7 +17,7 @@ const LIGHT_QUERY = "(prefers-color-scheme: light)";
|
|
|
16
17
|
function readStored(key: string): ThemePreference | null {
|
|
17
18
|
try {
|
|
18
19
|
const value = window.localStorage.getItem(key);
|
|
19
|
-
return value === "dark" || value === "light" || value === "system" ? value : null;
|
|
20
|
+
return value === "dark" || value === "light" || value === "system" || value === "time" ? value : null;
|
|
20
21
|
} catch {
|
|
21
22
|
return null;
|
|
22
23
|
}
|
|
@@ -34,6 +35,12 @@ function systemTheme(): Theme {
|
|
|
34
35
|
return window.matchMedia(LIGHT_QUERY).matches ? "light" : "dark";
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
/** 今の時刻のテーマ。場所と日付は固定(src/lib/daylight.ts) */
|
|
39
|
+
function timeTheme(): Theme {
|
|
40
|
+
const now = new Date();
|
|
41
|
+
return skyAt(now.getHours() + now.getMinutes() / 60).theme;
|
|
42
|
+
}
|
|
43
|
+
|
|
37
44
|
function currentTheme(): Theme {
|
|
38
45
|
return document.documentElement.dataset.theme === "light" ? "light" : "dark";
|
|
39
46
|
}
|
|
@@ -45,6 +52,11 @@ function currentTheme(): Theme {
|
|
|
45
52
|
export function restoreTheme(storageKey = DEFAULT_STORAGE_KEY) {
|
|
46
53
|
const stored = readStored(storageKey);
|
|
47
54
|
if (!stored) return;
|
|
55
|
+
if (stored === "time") {
|
|
56
|
+
const now = new Date();
|
|
57
|
+
applySky(skyAt(now.getHours() + now.getMinutes() / 60));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
48
60
|
setTheme(stored === "system" ? systemTheme() : stored);
|
|
49
61
|
}
|
|
50
62
|
|
|
@@ -55,7 +67,8 @@ export function restoreTheme(storageKey = DEFAULT_STORAGE_KEY) {
|
|
|
55
67
|
export function useThemePreference(storageKey = DEFAULT_STORAGE_KEY) {
|
|
56
68
|
const [preference, setPreferenceState] = React.useState<ThemePreference>(() => {
|
|
57
69
|
if (typeof window === "undefined") return "dark";
|
|
58
|
-
|
|
70
|
+
const stored = readStored(storageKey);
|
|
71
|
+
return stored === "system" || stored === "time" ? stored : currentTheme();
|
|
59
72
|
});
|
|
60
73
|
const [theme, setThemeState] = React.useState<Theme>(() =>
|
|
61
74
|
typeof document === "undefined" ? "dark" : currentTheme(),
|
|
@@ -70,7 +83,8 @@ export function useThemePreference(storageKey = DEFAULT_STORAGE_KEY) {
|
|
|
70
83
|
const next = currentTheme();
|
|
71
84
|
setThemeState(next);
|
|
72
85
|
const pref = preferenceRef.current;
|
|
73
|
-
|
|
86
|
+
const expected = pref === "system" ? systemTheme() : pref === "time" ? timeTheme() : pref;
|
|
87
|
+
if (next !== expected) setPreferenceState(next);
|
|
74
88
|
};
|
|
75
89
|
sync();
|
|
76
90
|
const mo = new MutationObserver(sync);
|
|
@@ -87,12 +101,18 @@ export function useThemePreference(storageKey = DEFAULT_STORAGE_KEY) {
|
|
|
87
101
|
return () => mq.removeEventListener("change", onChange);
|
|
88
102
|
}, [preference]);
|
|
89
103
|
|
|
104
|
+
// 時刻に合わせている間は、1 分ごとにテーマと面の色を更新する
|
|
105
|
+
React.useEffect(() => {
|
|
106
|
+
if (preference !== "time") return;
|
|
107
|
+
return startDaylight();
|
|
108
|
+
}, [preference]);
|
|
109
|
+
|
|
90
110
|
const setPreference = React.useCallback(
|
|
91
111
|
(next: ThemePreference) => {
|
|
92
112
|
setPreferenceState(next);
|
|
93
113
|
preferenceRef.current = next;
|
|
94
114
|
writeStored(storageKey, next);
|
|
95
|
-
setTheme(next === "system" ? systemTheme() : next);
|
|
115
|
+
if (next !== "time") setTheme(next === "system" ? systemTheme() : next);
|
|
96
116
|
},
|
|
97
117
|
[storageKey],
|
|
98
118
|
);
|
|
@@ -106,7 +126,7 @@ export type ThemeToggleProps = Omit<ButtonProps, "onClick" | "children" | "statu
|
|
|
106
126
|
};
|
|
107
127
|
|
|
108
128
|
/**
|
|
109
|
-
*
|
|
129
|
+
* 夜と昼を切り替えるボタン。押すと、出ていたほうが右下へ沈み、次のほうが左下から昇る(ボタンの下の点を中心に 75 度回る)。画面全体は 720ms で切り替わる。昼へは新しい画面が下の端から上へ、夜へは上の端から下へ広がる。
|
|
110
130
|
* 端末の設定に合わせる選択肢も見せたいときは ThemeToggleGroup を使う。
|
|
111
131
|
*/
|
|
112
132
|
export function ThemeToggle({
|
|
@@ -122,10 +142,11 @@ export function ThemeToggle({
|
|
|
122
142
|
const motionProps = reduce
|
|
123
143
|
? { initial: false as const, transition: { duration: 0 } }
|
|
124
144
|
: {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
145
|
+
// 太陽と月は、ボタンの下にある点を中心に回る。左下から昇り、右下へ沈む
|
|
146
|
+
initial: { opacity: 0, rotate: -amplitude.orbitAngle },
|
|
147
|
+
animate: { opacity: 1, rotate: 0 },
|
|
148
|
+
exit: { opacity: 0, rotate: amplitude.orbitAngle },
|
|
149
|
+
transition: springs.sway,
|
|
129
150
|
};
|
|
130
151
|
return (
|
|
131
152
|
<Button
|
|
@@ -139,7 +160,12 @@ export function ThemeToggle({
|
|
|
139
160
|
{...props}
|
|
140
161
|
>
|
|
141
162
|
<AnimatePresence mode="popLayout" initial={false}>
|
|
142
|
-
<motion.span
|
|
163
|
+
<motion.span
|
|
164
|
+
key={theme}
|
|
165
|
+
className="inline-flex"
|
|
166
|
+
style={{ transformOrigin: amplitude.orbitOrigin }}
|
|
167
|
+
{...motionProps}
|
|
168
|
+
>
|
|
143
169
|
{theme === "dark" ? <Moon /> : <Sun />}
|
|
144
170
|
</motion.span>
|
|
145
171
|
</AnimatePresence>
|
|
@@ -160,11 +186,13 @@ const options: { value: ThemePreference; label: string; icon: React.ReactNode }[
|
|
|
160
186
|
{ value: "dark", label: "夜", icon: <Moon /> },
|
|
161
187
|
{ value: "light", label: "昼", icon: <Sun /> },
|
|
162
188
|
{ value: "system", label: "端末に合わせる", icon: <Monitor /> },
|
|
189
|
+
{ value: "time", label: "時刻に合わせる", icon: <Clock /> },
|
|
163
190
|
];
|
|
164
191
|
|
|
165
192
|
/**
|
|
166
|
-
*
|
|
193
|
+
* 夜、昼、端末に合わせる、時刻に合わせる、から選ぶ。選んだ面が溝の中を滑って移る。
|
|
167
194
|
* 端末に合わせる間は、OS の設定が変わると画面も追って変わる。
|
|
195
|
+
* 時刻に合わせる間は、5 時 45 分に昼、18 時 15 分に夜へ切り替わり、面の色が時刻で少しずつ変わる。
|
|
168
196
|
*/
|
|
169
197
|
export function ThemeToggleGroup({ storageKey, iconOnly, size = "sm", className }: ThemeToggleGroupProps) {
|
|
170
198
|
const { preference, setPreference } = useThemePreference(storageKey);
|
|
@@ -309,7 +309,7 @@ function TreeItem({
|
|
|
309
309
|
className="inline-flex"
|
|
310
310
|
initial={false}
|
|
311
311
|
animate={{ rotate: isOpen ? 90 : 0 }}
|
|
312
|
-
transition={reduce ? { duration: 0 } : springs.
|
|
312
|
+
transition={reduce ? { duration: 0 } : springs.pop}
|
|
313
313
|
>
|
|
314
314
|
<ChevronRight className="size-3.5" />
|
|
315
315
|
</motion.span>
|
|
@@ -342,7 +342,7 @@ function TreeItem({
|
|
|
342
342
|
opacity: 1,
|
|
343
343
|
transition: reduce
|
|
344
344
|
? { duration: 0 }
|
|
345
|
-
: { height: springs.
|
|
345
|
+
: { height: springs.sway, opacity: { duration: 0.2, ease: [0.2, 0.8, 0.2, 1] } },
|
|
346
346
|
}}
|
|
347
347
|
exit={{
|
|
348
348
|
height: 0,
|
package/src/embers.d.ts
CHANGED
|
@@ -3,13 +3,11 @@
|
|
|
3
3
|
import type * as React from "react";
|
|
4
4
|
|
|
5
5
|
type EmbersAttributes = React.HTMLAttributes<HTMLElement> & {
|
|
6
|
-
/**
|
|
6
|
+
/** 火の粉の多さ。既定 45。45 のとき、平均 0.4 秒に 1 回、1〜4 個が飛ぶ */
|
|
7
7
|
density?: number | string;
|
|
8
|
-
/**
|
|
8
|
+
/** 横方向の風。-1〜1、既定 0。1 で毎秒 0.6m */
|
|
9
9
|
wind?: number | string;
|
|
10
|
-
/**
|
|
11
|
-
hue?: number | string;
|
|
12
|
-
/** 背景のグロー。"off" で消す */
|
|
10
|
+
/** 下の端の淡い光。"off" で消す */
|
|
13
11
|
glow?: "on" | "off";
|
|
14
12
|
};
|
|
15
13
|
|