Skip to content

Commit a520eef

Browse files
authored
refactor(editors/cleanup): show edit button on hover (openscd#747)
* Show edit button using CSS instead of JS, partially closes openscd#746 * Add hover css to dataset container, update snapshot for control blocks
1 parent 528db27 commit a520eef

File tree

3 files changed

+71
-49
lines changed

3 files changed

+71
-49
lines changed

src/editors/cleanup/control-blocks-container.ts

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,18 @@ export class CleanupControlBlocks extends LitElement {
170170
><span class="unreferencedControl"
171171
>${controlBlock.getAttribute('name')!}
172172
</span>
173+
<span>
174+
<mwc-icon-button
175+
label="warning"
176+
icon="warning_amber"
177+
class="cautionItem"
178+
title="${translate(
179+
'cleanup.unreferencedControls.addressDefinitionTooltip'
180+
)}"
181+
?disabled="${!(getCommAddress(controlBlock) !== null)}"
182+
>
183+
</mwc-icon-button>
184+
</span>
173185
<span>
174186
<mwc-icon-button
175187
label="Edit"
@@ -196,18 +208,6 @@ export class CleanupControlBlocks extends LitElement {
196208
}}
197209
></mwc-icon-button>
198210
</span>
199-
<span>
200-
<mwc-icon-button
201-
label="warning"
202-
icon="warning_amber"
203-
class="cautionItem"
204-
title="${translate(
205-
'cleanup.unreferencedControls.addressDefinitionTooltip'
206-
)}"
207-
?disabled="${!(getCommAddress(controlBlock) !== null)}"
208-
>
209-
</mwc-icon-button>
210-
</span>
211211
<span slot="secondary"
212212
>${controlBlock.tagName} -
213213
${controlBlock.closest('IED')?.getAttribute('name')}
@@ -352,6 +352,17 @@ export class CleanupControlBlocks extends LitElement {
352352
--mdc-icon-size: 16px;
353353
}
354354
355+
.editItem {
356+
visibility: hidden;
357+
opacity: 0;
358+
}
359+
360+
.cleanupListItem:hover .editItem {
361+
visibility: visible;
362+
opacity: 1;
363+
transition: visibility 0s, opacity 0.5s linear;
364+
}
365+
355366
.cautionItem {
356367
color: var(--yellow);
357368
}

src/editors/cleanup/datasets-container.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,17 @@ export class CleanupDatasets extends LitElement {
206206
--mdc-icon-size: 16px;
207207
}
208208
209+
.editItem {
210+
visibility: hidden;
211+
opacity: 0;
212+
}
213+
214+
.checkListItem:hover .editItem {
215+
visibility: visible;
216+
opacity: 1;
217+
transition: visibility 0s, opacity 0.5s linear;
218+
}
219+
209220
.cleanupDeleteButton {
210221
float: right;
211222
}

test/unit/editors/cleanup/__snapshots__/control-blocks-container.test.snap.js

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,6 @@ snapshots["Cleanup: Control Blocks Container With a test file loaded looks like
132132
<span class="unreferencedControl">
133133
GCB2_NP
134134
</span>
135-
<span>
136-
<mwc-icon-button
137-
class="editItem"
138-
icon="edit"
139-
label="Edit"
140-
>
141-
</mwc-icon-button>
142-
</span>
143135
<span>
144136
<mwc-icon-button
145137
class="cautionItem"
@@ -150,6 +142,14 @@ snapshots["Cleanup: Control Blocks Container With a test file loaded looks like
150142
>
151143
</mwc-icon-button>
152144
</span>
145+
<span>
146+
<mwc-icon-button
147+
class="editItem"
148+
icon="edit"
149+
label="Edit"
150+
>
151+
</mwc-icon-button>
152+
</span>
153153
<span slot="secondary">
154154
GSEControl -
155155
IED1
@@ -174,18 +174,18 @@ snapshots["Cleanup: Control Blocks Container With a test file loaded looks like
174174
</span>
175175
<span>
176176
<mwc-icon-button
177-
class="editItem"
178-
icon="edit"
179-
label="Edit"
177+
class="cautionItem"
178+
icon="warning_amber"
179+
label="warning"
180+
title="[cleanup.unreferencedControls.addressDefinitionTooltip]"
180181
>
181182
</mwc-icon-button>
182183
</span>
183184
<span>
184185
<mwc-icon-button
185-
class="cautionItem"
186-
icon="warning_amber"
187-
label="warning"
188-
title="[cleanup.unreferencedControls.addressDefinitionTooltip]"
186+
class="editItem"
187+
icon="edit"
188+
label="Edit"
189189
>
190190
</mwc-icon-button>
191191
</span>
@@ -213,20 +213,20 @@ snapshots["Cleanup: Control Blocks Container With a test file loaded looks like
213213
</span>
214214
<span>
215215
<mwc-icon-button
216-
class="editItem"
216+
class="cautionItem"
217217
disabled=""
218-
icon="edit"
219-
label="Edit"
218+
icon="warning_amber"
219+
label="warning"
220+
title="[cleanup.unreferencedControls.addressDefinitionTooltip]"
220221
>
221222
</mwc-icon-button>
222223
</span>
223224
<span>
224225
<mwc-icon-button
225-
class="cautionItem"
226+
class="editItem"
226227
disabled=""
227-
icon="warning_amber"
228-
label="warning"
229-
title="[cleanup.unreferencedControls.addressDefinitionTooltip]"
228+
icon="edit"
229+
label="Edit"
230230
>
231231
</mwc-icon-button>
232232
</span>
@@ -252,14 +252,6 @@ snapshots["Cleanup: Control Blocks Container With a test file loaded looks like
252252
<span class="unreferencedControl">
253253
ReportCb
254254
</span>
255-
<span>
256-
<mwc-icon-button
257-
class="editItem"
258-
icon="edit"
259-
label="Edit"
260-
>
261-
</mwc-icon-button>
262-
</span>
263255
<span>
264256
<mwc-icon-button
265257
class="cautionItem"
@@ -270,6 +262,14 @@ snapshots["Cleanup: Control Blocks Container With a test file loaded looks like
270262
>
271263
</mwc-icon-button>
272264
</span>
265+
<span>
266+
<mwc-icon-button
267+
class="editItem"
268+
icon="edit"
269+
label="Edit"
270+
>
271+
</mwc-icon-button>
272+
</span>
273273
<span slot="secondary">
274274
ReportControl -
275275
IED2
@@ -294,18 +294,18 @@ snapshots["Cleanup: Control Blocks Container With a test file loaded looks like
294294
</span>
295295
<span>
296296
<mwc-icon-button
297-
class="editItem"
298-
icon="edit"
299-
label="Edit"
297+
class="cautionItem"
298+
icon="warning_amber"
299+
label="warning"
300+
title="[cleanup.unreferencedControls.addressDefinitionTooltip]"
300301
>
301302
</mwc-icon-button>
302303
</span>
303304
<span>
304305
<mwc-icon-button
305-
class="cautionItem"
306-
icon="warning_amber"
307-
label="warning"
308-
title="[cleanup.unreferencedControls.addressDefinitionTooltip]"
306+
class="editItem"
307+
icon="edit"
308+
label="Edit"
309309
>
310310
</mwc-icon-button>
311311
</span>

0 commit comments

Comments
 (0)