Skip to content

Commit 0f3b3c8

Browse files
author
mrmrs
committed
Consolidates layers and styles to one tab
1 parent e116b85 commit 0f3b3c8

File tree

3 files changed

+44
-28
lines changed

3 files changed

+44
-28
lines changed

packages/gui/src/components/html/Editor.tsx

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,21 @@ const TABS_TRIGGER_STYLES: any = {
3838
const TABS_CONTENT_STYLES: any = {
3939
width: 400,
4040
height: 'calc(100vh - 81px)',
41-
overflow: 'auto',
41+
maxHeight: '100%',
42+
overflow: 'hidden',
43+
resize: 'horizontal',
44+
borderRightWidth: '1px',
45+
borderRightStyle: 'solid',
46+
borderColor: 'border',
47+
'&::-webkit-scrollbar': { display: 'none' },
48+
scrollbarWidth: 0,
49+
}
50+
51+
const TABS_EDITOR_STYLES: any = {
52+
width: '400px',
53+
height: 'calc(100vh - 81px)',
54+
maxHeight: '100%',
55+
overflow: 'hidden',
4256
resize: 'horizontal',
4357
borderRightWidth: '1px',
4458
borderRightStyle: 'solid',
@@ -103,10 +117,7 @@ export function HtmlEditor() {
103117
}}
104118
>
105119
<Tabs.Trigger sx={TABS_TRIGGER_STYLES} value="node">
106-
<span>🎨</span> Styles
107-
</Tabs.Trigger>
108-
<Tabs.Trigger sx={TABS_TRIGGER_STYLES} value="tree">
109-
<Layers size={12} /> Layers
120+
<span>🎨</span> Editor
110121
</Tabs.Trigger>
111122
<Tabs.Trigger sx={TABS_TRIGGER_STYLES} value="import">
112123
<LogIn size={12} /> Import
@@ -115,8 +126,8 @@ export function HtmlEditor() {
115126
<Code size={12} /> Export
116127
</Tabs.Trigger>
117128
</Tabs.List>
118-
<Tabs.Content sx={TABS_CONTENT_STYLES} value="node">
119-
<div sx={{ pt: 3, px: 3 }}>
129+
<Tabs.Content sx={TABS_EDITOR_STYLES} value="node">
130+
<div sx={{ pt: 3, px: 3, resize: 'vertical', overflowY: 'scroll', height: '50vh' }}>
120131
<Editor
121132
key={selected.join('-')}
122133
theme={theme}
@@ -129,9 +140,7 @@ export function HtmlEditor() {
129140
showAddProperties
130141
/>
131142
</div>
132-
</Tabs.Content>
133-
<Tabs.Content sx={TABS_CONTENT_STYLES} value="tree">
134-
<div>
143+
<div sx={{ height: '50%', position: 'relative', }}>
135144
<NodeEditor
136145
value={nodeValue}
137146
onChange={(newItem) =>
@@ -150,13 +159,17 @@ export function HtmlEditor() {
150159
setSelected(newPath)
151160
}}
152161
/>
153-
<TreeNode
154-
value={value}
155-
onSelect={setSelected}
156-
path={[]}
157-
onChange={onChange}
158-
/>
159-
</div>
162+
<div sx={{ height: '100%', overflow: 'scroll', resize: 'vertical', borderBottomWidth: '1px', borderBottomStyle: 'solid', borderBottomColor: 'border' }}>
163+
<div sx={{ pb: '480px', minHeight: '100%' }}>
164+
<TreeNode
165+
value={value}
166+
onSelect={setSelected}
167+
path={[]}
168+
onChange={onChange}
169+
/>
170+
</div>
171+
</div>
172+
</div>
160173
</Tabs.Content>
161174
<Tabs.Content sx={TABS_CONTENT_STYLES} value="import">
162175
<Import onChange={onChange} />

packages/gui/src/components/html/Editors/NodeEditor.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,17 @@ export function NodeEditor({
4646
minHeight: '4px',
4747
height: 'auto',
4848
resize: 'vertical',
49-
position: 'sticky',
50-
top: 0,
5149
boxSizing: 'border-box',
52-
overflowX: 'hidden',
5350
borderBottomWidth: '1px',
5451
borderBottomStyle: 'solid',
5552
borderBottomColor: 'border',
56-
zIndex: 4,
53+
zIndex: 9999,
54+
position: 'sticky',
55+
top: 0,
56+
overflowY: 'scroll',
57+
borderTopWidth: '4px',
58+
borderTopStyle: 'solid',
59+
borderTopColor: 'border',
5760
}}
5861
>
5962
<div
@@ -171,14 +174,13 @@ function NodeSwitch({ value, onChange }: EditorProps) {
171174
const tagKey = [...(selected || []), value.tagName || ''].join('-')
172175

173176
return (
174-
<div>
175177
<article
176178
sx={{
177-
pb: 3,
179+
pb: 4,
178180
}}
179181
>
180-
<div sx={{ mb: 2, px: 3 }}>
181-
<Label>Tag name</Label>{' '}
182+
<div sx={{ px: 3, mb: 2 }}>
183+
<Label>Element</Label>{' '}
182184
<Combobox
183185
key={tagKey}
184186
onFilterItems={(filterValue) => {
@@ -223,6 +225,5 @@ function NodeSwitch({ value, onChange }: EditorProps) {
223225
/>
224226
</div>
225227
</article>
226-
</div>
227228
)
228229
}

packages/gui/src/components/html/TreeNode.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ export function TreeNode({ value, path, onSelect, onChange }: TreeNodeProps) {
4848
textAlign: 'start',
4949
fontSize: 0,
5050
width: '100%',
51+
whiteSpace: 'nowrap',
52+
overflow: 'hidden',
5153
}}
5254
onClick={() => {
5355
handleSelect()
@@ -173,7 +175,7 @@ export function TreeNode({ value, path, onSelect, onChange }: TreeNodeProps) {
173175
WebkitAppearance: 'none',
174176
cursor: 'pointer',
175177
border: 'none',
176-
backgroundColor: isSelected ? '#ff0' : 'background',
178+
backgroundColor: isSelected ? 'primary' : 'background',
177179
color: 'text',
178180
fontSize: '14px',
179181
fontFamily: 'monospace',
@@ -307,7 +309,7 @@ export function TreeNode({ value, path, onSelect, onChange }: TreeNodeProps) {
307309
px: 2,
308310
fontSize: '14px',
309311
fontFamily: 'monospace',
310-
bg: isSelected ? '#ff0' : 'background',
312+
bg: isSelected ? 'primary' : 'background',
311313
fontWeight: isSelected ? 700 : 400,
312314
borderRadius: '6px',
313315
transition: 'background-color .2s ease-in-out',

0 commit comments

Comments
 (0)