@1889ca/ui 0.5.0 → 0.5.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/package.json +1 -1
- package/src/components/Panel.css +52 -0
- package/src/components/Panel.jsx +24 -4
package/package.json
CHANGED
package/src/components/Panel.css
CHANGED
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
overflow: hidden;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
/* ── Titlebar ── */
|
|
17
|
+
|
|
16
18
|
.ui-panel-titlebar {
|
|
17
19
|
display: flex;
|
|
18
20
|
align-items: center;
|
|
@@ -53,6 +55,56 @@
|
|
|
53
55
|
background: var(--ui-surface-raised);
|
|
54
56
|
}
|
|
55
57
|
|
|
58
|
+
/* ── Tabs ── */
|
|
59
|
+
|
|
60
|
+
.ui-panel-tabs {
|
|
61
|
+
display: flex;
|
|
62
|
+
flex-shrink: 0;
|
|
63
|
+
padding: 0 0.35rem;
|
|
64
|
+
gap: 2px;
|
|
65
|
+
border-bottom: 1px solid var(--ui-border);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.ui-panel-tab {
|
|
69
|
+
position: relative;
|
|
70
|
+
padding: 0.45rem 0.7rem;
|
|
71
|
+
background: none;
|
|
72
|
+
border: none;
|
|
73
|
+
color: var(--ui-text-subtle);
|
|
74
|
+
font-size: 0.7rem;
|
|
75
|
+
font-weight: 500;
|
|
76
|
+
text-transform: uppercase;
|
|
77
|
+
letter-spacing: 0.05em;
|
|
78
|
+
cursor: pointer;
|
|
79
|
+
transition: color 0.15s;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.ui-panel-tab::after {
|
|
83
|
+
content: '';
|
|
84
|
+
position: absolute;
|
|
85
|
+
left: 0.35rem;
|
|
86
|
+
right: 0.35rem;
|
|
87
|
+
bottom: -1px;
|
|
88
|
+
height: 2px;
|
|
89
|
+
border-radius: 1px;
|
|
90
|
+
background: transparent;
|
|
91
|
+
transition: background 0.2s var(--ui-ease);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.ui-panel-tab:hover {
|
|
95
|
+
color: var(--ui-text-muted);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.ui-panel-tab--active {
|
|
99
|
+
color: var(--ui-accent);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.ui-panel-tab--active::after {
|
|
103
|
+
background: var(--ui-accent);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* ── Body ── */
|
|
107
|
+
|
|
56
108
|
.ui-panel-body {
|
|
57
109
|
flex: 1;
|
|
58
110
|
min-height: 0;
|
package/src/components/Panel.jsx
CHANGED
|
@@ -4,25 +4,45 @@
|
|
|
4
4
|
* Static glass panel — same chrome as DraggablePanel but positioned in flow.
|
|
5
5
|
* Use for sidebar sections, inspector panels, toolboxes, etc.
|
|
6
6
|
*
|
|
7
|
-
* @param {string} title - Titlebar text
|
|
7
|
+
* @param {string} title - Titlebar text (optional)
|
|
8
|
+
* @param {Array} tabs - [{id, label}] tab definitions (optional)
|
|
9
|
+
* @param {string} activeTab - Currently active tab id
|
|
10
|
+
* @param {function} onTabChange - Called with tab id on click
|
|
8
11
|
* @param {ReactNode} children - Panel body content
|
|
9
12
|
* @param {ReactNode} actions - Extra elements in the titlebar (right side, before close)
|
|
10
13
|
* @param {function} onClose - Close button handler (omit to hide close button)
|
|
11
14
|
* @param {string} className - Additional class names
|
|
12
15
|
* @param {boolean} flush - If true, removes body padding (for custom layouts)
|
|
13
16
|
*/
|
|
14
|
-
export default function Panel({ title, children, actions, onClose, className, flush }) {
|
|
17
|
+
export default function Panel({ title, tabs, activeTab, onTabChange, children, actions, onClose, className, flush }) {
|
|
18
|
+
const hasHeader = title || actions || onClose;
|
|
19
|
+
const hasTabs = tabs && tabs.length > 0;
|
|
20
|
+
|
|
15
21
|
return (
|
|
16
22
|
<div className={`ui-panel${className ? ` ${className}` : ''}`}>
|
|
17
|
-
{
|
|
23
|
+
{hasHeader && (
|
|
18
24
|
<div className="ui-panel-titlebar">
|
|
19
|
-
<span className="ui-panel-title">{title}</span>
|
|
25
|
+
{title && <span className="ui-panel-title">{title}</span>}
|
|
20
26
|
<div className="ui-panel-actions">
|
|
21
27
|
{actions}
|
|
22
28
|
{onClose && <button className="ui-panel-close" type="button" onClick={onClose}>×</button>}
|
|
23
29
|
</div>
|
|
24
30
|
</div>
|
|
25
31
|
)}
|
|
32
|
+
{hasTabs && (
|
|
33
|
+
<nav className="ui-panel-tabs">
|
|
34
|
+
{tabs.map((tab) => (
|
|
35
|
+
<button
|
|
36
|
+
key={tab.id}
|
|
37
|
+
type="button"
|
|
38
|
+
className={`ui-panel-tab${activeTab === tab.id ? ' ui-panel-tab--active' : ''}`}
|
|
39
|
+
onClick={() => onTabChange?.(tab.id)}
|
|
40
|
+
>
|
|
41
|
+
{tab.label}
|
|
42
|
+
</button>
|
|
43
|
+
))}
|
|
44
|
+
</nav>
|
|
45
|
+
)}
|
|
26
46
|
<div className={`ui-panel-body${flush ? ' ui-panel-body--flush' : ''}`}>
|
|
27
47
|
{children}
|
|
28
48
|
</div>
|