Skip to content

Commit bf19b15

Browse files
ShGKmebackportbot[bot]
authored andcommitted
fix(NcActions): migrate to custom icons in Checkbox and Radio actions
Signed-off-by: Grigorii K. Shartsev <me@shgk.me> [skip ci]
1 parent c673e9c commit bf19b15

File tree

2 files changed

+38
-102
lines changed

2 files changed

+38
-102
lines changed

src/components/NcActionCheckbox/NcActionCheckbox.vue

Lines changed: 21 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ import GenRandomId from '../../utils/GenRandomId.js'
6464
export default {
6565
name: 'NcActionCheckbox',
6666
67+
components: {
68+
NcIconSvgWrapper,
69+
},
70+
6771
mixins: [ActionGlobalMixin],
6872
6973
inject: {
@@ -125,8 +129,11 @@ export default {
125129
},
126130
127131
emits: [
132+
/** Native change event */
128133
'change',
134+
/** Checkbox is checked */
129135
'check',
136+
/** Checkbox is unchecked */
130137
'uncheck',
131138
/**
132139
* Removed in v9 - use `update:modelValue` (`v-model`) instead
@@ -189,20 +196,9 @@ export default {
189196
* @type {Event}
190197
*/
191198
this.$emit('change', event)
192-
193-
if (this.$refs.checkbox.checked) {
194-
/**
195-
* Emitted when the checkbox is checked
196-
*
197-
* @type {Event}
198-
*/
199+
if (event.target.checked) {
199200
this.$emit('check')
200201
} else {
201-
/**
202-
* Emitted when the checkbox is unchecked
203-
*
204-
* @type {Event}
205-
*/
206202
this.$emit('uncheck')
207203
}
208204
},
@@ -214,56 +210,24 @@ export default {
214210
@use '../../assets/action.scss' as *;
215211
@include action-active;
216212
@include action--disabled;
213+
@include action-item('checkbox');
217214
218-
.action-checkbox {
219-
display: flex;
220-
align-items: flex-start;
221-
222-
width: 100%;
223-
height: auto;
224-
margin: 0;
225-
padding: 0;
226-
227-
cursor: pointer;
228-
white-space: nowrap;
229-
230-
color: var(--color-main-text);
231-
border: 0;
232-
border-radius: 0; // otherwise Safari will cut the border-radius area
233-
background-color: transparent;
234-
box-shadow: none;
215+
.action:has(:focus-visible) {
216+
outline: 2px solid currentColor;
217+
}
235218
236-
font-weight: normal;
237-
line-height: var(--default-clickable-area);
219+
.action-checkbox {
220+
&__icon {
221+
color: var(--color-primary-element);
222+
}
238223
239-
/* checkbox/radio fixes */
240-
&__checkbox {
224+
&__input {
225+
width: 20px;
226+
height: 20px;
227+
margin: auto;
241228
position: absolute;
242-
inset-inline-start: 0 !important;
243229
z-index: -1;
244-
opacity: 0;
245-
}
246-
247-
&__label {
248-
display: flex;
249-
align-items: center; // align checkbox to text
250-
251-
width: 100%;
252-
padding: 0 !important;
253-
padding-inline-end: $icon-margin !important;
254-
255-
&::before {
256-
margin-block: 0 !important;
257-
margin-inline: calc((var(--default-clickable-area) - 14px) / 2) !important;
258-
}
259-
}
260-
261-
&--disabled {
262-
&,
263-
.action-checkbox__label {
264-
cursor: pointer;
265-
}
230+
opacity: 0 !important;
266231
}
267232
}
268-
269233
</style>

src/components/NcActionRadio/NcActionRadio.vue

Lines changed: 17 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ import GenRandomId from '../../utils/GenRandomId.js'
7474
export default {
7575
name: 'NcActionRadio',
7676
77+
components: {
78+
NcIconSvgWrapper,
79+
},
80+
7781
mixins: [ActionGlobalMixin],
7882
7983
inject: {
@@ -219,56 +223,24 @@ export default {
219223
@use '../../assets/action.scss' as *;
220224
@include action-active;
221225
@include action--disabled;
226+
@include action-item('radio');
222227
223-
.action-radio {
224-
display: flex;
225-
align-items: flex-start;
226-
227-
width: 100%;
228-
height: auto;
229-
margin: 0;
230-
padding: 0;
231-
232-
cursor: pointer;
233-
white-space: nowrap;
234-
235-
color: var(--color-main-text);
236-
border: 0;
237-
border-radius: 0; // otherwise Safari will cut the border-radius area
238-
background-color: transparent;
239-
box-shadow: none;
228+
.action:has(:focus-visible) {
229+
outline: 2px solid currentColor;
230+
}
240231
241-
font-weight: normal;
242-
line-height: var(--default-clickable-area);
232+
.action-radio {
233+
&__icon {
234+
color: var(--color-primary-element);
235+
}
243236
244-
/* checkbox/radio fixes */
245-
&__radio {
237+
&__input {
238+
width: 20px;
239+
height: 20px;
240+
margin: auto;
246241
position: absolute;
247-
inset-inline-start: 0 !important;
248242
z-index: -1;
249-
opacity: 0;
250-
}
251-
252-
&__label {
253-
display: flex;
254-
align-items: center; // align radio to text
255-
256-
width: 100%;
257-
padding: 0 !important;
258-
padding-inline-end: $icon-margin !important;
259-
260-
// (34 -14) / 2 = 10 same as ncactioncheckbox
261-
&::before {
262-
margin: calc((var(--default-clickable-area) - 14px) / 2) !important;
263-
}
264-
}
265-
266-
&--disabled {
267-
&,
268-
.action-radio__label {
269-
cursor: pointer;
270-
}
243+
opacity: 0 !important;
271244
}
272245
}
273-
274246
</style>

0 commit comments

Comments
 (0)