Skip to content

Commit 16ff9bf

Browse files
committed
refactor(NcTextArea): use shared scss mixin for input border
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 481da4a commit 16ff9bf

File tree

1 file changed

+12
-41
lines changed

1 file changed

+12
-41
lines changed

src/components/NcTextArea/NcTextArea.vue

Lines changed: 12 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ import type { VueClassType } from '../../utils/VueTypes.ts'
7777
import { mdiAlertCircleOutline, mdiCheck } from '@mdi/js'
7878
import { computed, useAttrs, useTemplateRef, watch } from 'vue'
7979
import NcIconSvgWrapper from '../NcIconSvgWrapper/NcIconSvgWrapper.vue'
80+
import { useIsDarkTheme } from '../../composables/useIsDarkTheme/index.ts'
8081
import { createElementId } from '../../utils/createElementId.ts'
8182
import { isLegacy } from '../../utils/legacy.ts'
8283
import { logger } from '../../utils/logger.ts'
@@ -163,13 +164,14 @@ defineExpose({
163164
select,
164165
})
165166
167+
const attrs = useAttrs()
168+
166169
/**
167170
* The native text area component instance
168171
*/
169172
const textAreaElement = useTemplateRef('input')
170173
171-
// needs to be a getter as attrs are not reactive
172-
const attrs = useAttrs()
174+
const isDarkTheme = useIsDarkTheme()
173175
174176
const internalPlaceholder = computed(() => props.placeholder || (isLegacy ? props.label : undefined))
175177
@@ -227,6 +229,7 @@ function select() {
227229
:class="[
228230
$attrs.class,
229231
{
232+
'textarea--dark': isDarkTheme,
230233
'textarea--disabled': disabled,
231234
'textarea--legacy': isLegacy,
232235
},
@@ -285,6 +288,8 @@ function select() {
285288
</template>
286289

287290
<style lang="scss" scoped>
291+
@use '../../assets/input-border.scss' as border;
292+
288293
.textarea {
289294
--input-border-color: var(--color-border-maxcontrast);
290295
--input-border-width-offset: calc(var(--border-width-input-focused, 2px) - var(--border-width-input, 2px));
@@ -301,42 +306,27 @@ function select() {
301306
302307
&__main-wrapper {
303308
height: calc(var(--default-clickable-area) * 2);
304-
padding: var(--border-width-input, 2px);
309+
padding: var(--border-width-input-focused, 2px);
305310
position: relative;
306-
307-
&:not(:has([disabled])):has(textarea:focus),
308-
&:not(:has([disabled])):has(textarea:active) {
309-
padding: 0;
310-
}
311311
}
312312
313313
&__input {
314314
margin: 0;
315-
padding-block: calc(10px + var(--input-border-width-offset));
316-
padding-inline: calc(12px - var(--border-width-input, 2px) + var(--input-border-width-offset)); // align with label 8px margin label + 4px padding label - 2px border input
315+
padding-block: var(--border-radius-element);
316+
padding-inline: 10px; // align with label 8px margin label + 4px padding label - 2px border input
317317
width: 100%;
318318
font-size: var(--default-font-size);
319319
text-overflow: ellipsis;
320320
cursor: pointer;
321321
322322
background-color: var(--color-main-background);
323323
color: var(--color-main-text);
324-
// we use box shadow to create a border as this allows use to have a nice gradient
325-
border: none;
326-
border-radius: var(--border-radius-element);
327-
box-shadow:
328-
0 -1px var(--input-border-color),
329-
0 0 0 1px color-mix(in srgb, var(--input-border-color), 65% transparent);
330-
331-
&:hover:not([disabled]) {
332-
box-shadow: 0 0 0 1px var(--input-border-color);
333-
}
324+
@include border.inputBorder('.textarea--dark', '.textarea--legacy', var(--input-border-color));
325+
334326
&:active:not([disabled]),
335327
&:focus:not([disabled]) {
336328
--input-border-width-offset: 0px;
337329
--input-border-color: var(--color-main-text);
338-
border: var(--border-width-input-focused, 2px) solid var(--input-border-color);
339-
box-shadow: 0 0 0 2px var(--color-main-background) !important;
340330
}
341331
342332
// Hide placeholder while not focussed -> show label instead (only if internal label is used)
@@ -420,24 +410,5 @@ function select() {
420410
color: var(--color-success-text);
421411
}
422412
}
423-
424-
// for Nextcloud 31 and older we need the old design with only one color
425-
&--legacy {
426-
.textarea__input {
427-
box-shadow: 0 0 0 1px var(--input-border-color);
428-
}
429-
430-
.textarea__main-wrapper:hover:not(:has([disabled])) {
431-
padding: 0;
432-
433-
.textarea__input {
434-
--input-border-color: var(--color-main-text);
435-
// Reset padding offset when focused
436-
--input-border-width-offset: 0px;
437-
border: var(--border-width-input-focused, 2px) solid var(--input-border-color);
438-
box-shadow: 0 0 0 2px var(--color-main-background) !important;
439-
}
440-
}
441-
}
442413
}
443414
</style>

0 commit comments

Comments
 (0)