@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.
- package/dist/Editor.d.ts.map +1 -1
- package/dist/components/sections/DynamicRangeSection.d.ts.map +1 -1
- package/dist/hooks/useEditorState.d.ts +1 -3
- package/dist/hooks/useEditorState.d.ts.map +1 -1
- package/dist/index.cjs +222 -109
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +225 -111
- package/dist/index.js.map +1 -1
- package/dist/preview/ComponentRenderer.d.ts.map +1 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Editor.tsx +15 -8
- package/src/components/CodeBlock.tsx +1 -1
- package/src/components/EditorHeader.tsx +4 -4
- package/src/components/EditorShell.tsx +2 -2
- package/src/components/FontPicker.tsx +1 -1
- package/src/components/PresetSelector.tsx +3 -3
- package/src/components/RightSidebar.tsx +2 -2
- package/src/components/TableOfContents.tsx +1 -1
- package/src/components/sections/ColorsSection.tsx +2 -2
- package/src/components/sections/DynamicRangeSection.tsx +226 -3
- package/src/hooks/useEditorState.ts +0 -16
- package/src/index.ts +0 -2
- package/src/preview/CategoryView.tsx +1 -1
- package/src/preview/ComponentDetailView.tsx +1 -1
- package/src/preview/ComponentRenderer.tsx +51 -0
- package/src/preview/OverviewView.tsx +1 -1
- package/src/types.ts +0 -2
- package/dist/components/ThemeBar.d.ts +0 -8
- package/dist/components/ThemeBar.d.ts.map +0 -1
- package/src/components/ThemeBar.tsx +0 -76
|
@@ -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
|
-
}
|