Skip to content

Commit 6470d43

Browse files
committed
feat: properties panel styling - is edited indication
1 parent 3978c2b commit 6470d43

File tree

2 files changed

+69
-13
lines changed

2 files changed

+69
-13
lines changed

packages/webui/src/client/styles/propertiesPanel.scss

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@
8585
display: block;
8686
margin: 10px auto;
8787

88+
&:active {
89+
transform: scale(0.95);
90+
top: 2px;
91+
}
92+
8893
> svg {
8994
margin-top: -0.1em;
9095
vertical-align: middle;
@@ -121,9 +126,7 @@
121126
flex-wrap: wrap;
122127
margin-top: 0.5em;
123128
margin-bottom: 0.5em;
124-
125-
126-
129+
127130
> .propertiespanel-pop-up__groupselector__button {
128131
@include item-type-colors();
129132

@@ -153,8 +156,22 @@
153156
> .propertiespanel-pop-up__action {
154157
margin-top: 15px;
155158
color: #ddd;
159+
padding: 4px;
160+
}
161+
162+
> .properties-panel-pop-up__form {
163+
margin-top: 15px;
164+
color: #ddd;
165+
padding: 4px;
166+
}
167+
168+
> .properties-panel-pop-up__has-been-edited {
169+
background-color: #8a2929c0;
170+
border-radius: 8px;
171+
padding: 4px
156172
}
157173

174+
158175
> .propertiespanel-pop-up__label {
159176
color: #ddd;
160177
}
@@ -178,6 +195,11 @@
178195
border: 1px solid #7F7F7F;
179196
color: #ddd;
180197

198+
&:active {
199+
transform: scale(0.95);
200+
top: 2px;
201+
}
202+
181203
> svg {
182204
margin-top: -0.1em;
183205
vertical-align: middle;

packages/webui/src/client/ui/UserEditOperations/PropertiesPanel.tsx

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -279,14 +279,22 @@ function EditingTypeAction(props: {
279279
pendingChanges: PendingChange[]
280280
setPendingChanges: React.Dispatch<React.SetStateAction<PendingChange[]>>
281281
}) {
282-
if (!props.userEditOperation.buttonType) return null
283-
284-
const getPendingState = (operationId: string) => {
285-
const pendingChange = props.pendingChanges.find((change) => change.operationId === operationId)
282+
const getPendingState = () => {
283+
const pendingChange = props.pendingChanges.find((change) => change.operationId === props.userEditOperation.id)
286284
return pendingChange?.switchState
287285
}
288286

287+
const [hasBeenEdited, setHasBeenEdited] = React.useState<boolean>(
288+
getPendingState() !== undefined && getPendingState() !== props.userEditOperation.isActive
289+
)
290+
291+
React.useEffect(() => {
292+
setHasBeenEdited(getPendingState() !== undefined && getPendingState() !== props.userEditOperation.isActive)
293+
}, [props.userEditOperation.id, props.pendingChanges])
294+
295+
if (!props.userEditOperation.buttonType) return null
289296
const addPendingChange = () => {
297+
setHasBeenEdited(!hasBeenEdited)
290298
props.setPendingChanges((prev) => {
291299
// Find if there's an existing pending change for this operation
292300
const existingChangeIndex = prev.findIndex((change) => change.operationId === props.userEditOperation.id)
@@ -328,10 +336,15 @@ function EditingTypeAction(props: {
328336
)
329337
case UserEditingButtonType.SWITCH:
330338
return (
331-
<div className="propertiespanel-pop-up__action">
339+
<div
340+
className={classNames(
341+
'propertiespanel-pop-up__action',
342+
hasBeenEdited ? 'properties-panel-pop-up__has-been-edited' : ''
343+
)}
344+
>
332345
<a
333346
className={classNames('propertiespanel-pop-up__switchbutton', 'switch-button', {
334-
'sb-on': getPendingState(props.userEditOperation.id) ?? (props.userEditOperation.isActive || false),
347+
'sb-on': getPendingState() ?? (props.userEditOperation.isActive || false),
335348
})}
336349
role="button"
337350
onClick={addPendingChange}
@@ -409,6 +422,21 @@ function EditingTypeChangeSourceLayerSource(props: {
409422
props.userEditOperation.currentValues.value
410423
)
411424

425+
const getPendingState = () => {
426+
const pendingChange = props.pendingChanges.find((change) => change.operationId === props.userEditOperation.id)
427+
return pendingChange?.value
428+
}
429+
430+
const [hasBeenEdited, setHasBeenEdited] = React.useState<boolean>(
431+
getPendingState() !== undefined && getPendingState() !== props.userEditOperation.currentValues.value
432+
)
433+
434+
React.useEffect(() => {
435+
setHasBeenEdited(
436+
getPendingState() !== undefined && getPendingState() !== props.userEditOperation.currentValues.value
437+
)
438+
}, [props.userEditOperation.id, props.pendingChanges])
439+
412440
const jsonSchema = Object.values<UserEditingSourceLayer>(props.userEditOperation.schemas).find(
413441
(layer) => layer.sourceLayerType === selectedSourceGroup
414442
)?.schema
@@ -424,6 +452,7 @@ function EditingTypeChangeSourceLayerSource(props: {
424452

425453
const handleSourceChange = () => {
426454
setSelectedValues(selectedValues)
455+
setHasBeenEdited(true)
427456
// Add to pending changes instead of executing immediately
428457
props.setPendingChanges((prev) => {
429458
const filtered = prev.filter(
@@ -474,19 +503,24 @@ function EditingTypeChangeSourceLayerSource(props: {
474503
})}
475504
</div>
476505
{selectedGroupSchema && (
477-
<>
506+
<div
507+
className={classNames(
508+
'properties-panel-pop-up__form',
509+
hasBeenEdited ? 'properties-panel-pop-up__has-been-edited' : ''
510+
)}
511+
>
478512
<a className="propertiespanel-pop-up__label">{t('Source')}:</a>
513+
<br />
479514
<div onChange={handleSourceChange}>
480515
<SchemaFormInPlace
481516
schema={selectedGroupSchema}
482517
object={selectedValues}
483518
translationNamespaces={props.userEditOperation.translationNamespaces}
484519
/>
485-
<br />
486-
<hr />
487520
</div>
488-
</>
521+
</div>
489522
)}
523+
<hr />
490524
</>
491525
)
492526
}

0 commit comments

Comments
 (0)