@newtonedev/editor 0.1.3 → 0.1.5

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.
@@ -1,76 +0,0 @@
1
- import { useState } from "react";
2
- import { useTokens } from "@newtonedev/components";
3
- import { srgbToHex } from "newtone";
4
- import type { ThemeName } from "../types";
5
-
6
- interface ThemeBarProps {
7
- readonly activeTheme: ThemeName;
8
- readonly onThemeChange: (theme: ThemeName) => void;
9
- }
10
-
11
- const THEME_CHIPS: readonly { id: ThemeName; label: string }[] = [
12
- { id: "neutral", label: "Neutral" },
13
- { id: "primary", label: "Primary" },
14
- { id: "secondary", label: "Secondary" },
15
- { id: "strong", label: "Strong" },
16
- ];
17
-
18
- export function ThemeBar({ activeTheme, onThemeChange }: ThemeBarProps) {
19
- const tokens = useTokens();
20
- const [hoveredChipId, setHoveredChipId] = useState<string | null>(null);
21
-
22
- const borderColor = srgbToHex(tokens.border.srgb);
23
- const interactiveColor = srgbToHex(tokens.interactive.srgb);
24
-
25
- return (
26
- <div
27
- style={{
28
- display: "flex",
29
- alignItems: "center",
30
- padding: "8px 24px",
31
- borderBottom: `1px solid ${borderColor}`,
32
- backgroundColor: srgbToHex(tokens.background.srgb),
33
- flexShrink: 0,
34
- }}
35
- >
36
- {/* Theme Chips */}
37
- <div style={{ display: "flex", gap: 8 }} role="group" aria-label="Theme">
38
- {THEME_CHIPS.map((chip) => {
39
- const isActive = chip.id === activeTheme;
40
- const isHovered = hoveredChipId === chip.id;
41
-
42
- return (
43
- <button
44
- key={chip.id}
45
- onClick={() => onThemeChange(chip.id)}
46
- onMouseEnter={() => setHoveredChipId(chip.id)}
47
- onMouseLeave={() => setHoveredChipId(null)}
48
- aria-pressed={isActive}
49
- style={{
50
- padding: "4px 12px",
51
- borderRadius: 16,
52
- border: `1px solid ${srgbToHex(
53
- isActive ? tokens.interactive.srgb : tokens.border.srgb,
54
- )}`,
55
- backgroundColor: isActive
56
- ? interactiveColor
57
- : isHovered
58
- ? `${interactiveColor}10`
59
- : "transparent",
60
- color: isActive
61
- ? "#fff"
62
- : srgbToHex(tokens.textPrimary.srgb),
63
- fontSize: 12,
64
- fontWeight: 500,
65
- cursor: "pointer",
66
- transition: "background-color 150ms ease",
67
- }}
68
- >
69
- {chip.label}
70
- </button>
71
- );
72
- })}
73
- </div>
74
- </div>
75
- );
76
- }