Skip to content

Commit ccf3cd6

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

File tree

1 file changed

+12
-39
lines changed

1 file changed

+12
-39
lines changed

src/components/NcTextArea/NcTextArea.vue

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ It extends and styles an HTMLTextAreaElement.
9191
<div
9292
class="textarea"
9393
:class="{
94+
'textarea--dark': isDarkTheme,
9495
'textarea--disabled': disabled,
9596
'textarea--legacy': isLegacy32,
9697
}">
@@ -141,6 +142,7 @@ It extends and styles an HTMLTextAreaElement.
141142
<script>
142143
import AlertCircle from 'vue-material-design-icons/AlertCircleOutline.vue'
143144
import Check from 'vue-material-design-icons/Check.vue'
145+
import { useIsDarkTheme } from '../../composables/useIsDarkTheme/index.ts'
144146
import { useModelMigration } from '../../composables/useModelMigration.ts'
145147
import GenRandomId from '../../utils/GenRandomId.js'
146148
import { isLegacy32 } from '../../utils/legacy.ts'
@@ -281,9 +283,12 @@ export default {
281283
282284
setup() {
283285
const model = useModelMigration('value', 'update:value', true)
286+
const isDarkTheme = useIsDarkTheme()
287+
284288
return {
285289
isLegacy32,
286290
model,
291+
isDarkTheme,
287292
}
288293
},
289294
@@ -357,6 +362,8 @@ export default {
357362
</script>
358363

359364
<style lang="scss" scoped>
365+
@use '../../assets/input-border.scss' as border;
366+
360367
.textarea {
361368
--input-border-color: var(--color-border-maxcontrast);
362369
--input-border-width-offset: calc(var(--border-width-input-focused, 2px) - var(--border-width-input, 2px));
@@ -373,42 +380,27 @@ export default {
373380
374381
&__main-wrapper {
375382
height: calc(var(--default-clickable-area) * 2);
376-
padding: var(--border-width-input, 2px);
383+
padding: var(--border-width-input-focused, 2px);
377384
position: relative;
378-
379-
&:not(:has([disabled])):has(textarea:focus),
380-
&:not(:has([disabled])):has(textarea:active) {
381-
padding: 0;
382-
}
383385
}
384386
385387
&__input {
386388
margin: 0;
387-
padding-block: calc(10px + var(--input-border-width-offset));
388-
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
389+
padding-block: var(--border-radius-element);
390+
padding-inline: 10px; // align with label 8px margin label + 4px padding label - 2px border input
389391
width: 100%;
390392
font-size: var(--default-font-size);
391393
text-overflow: ellipsis;
392394
cursor: pointer;
393395
394396
background-color: var(--color-main-background);
395397
color: var(--color-main-text);
396-
// we use box shadow to create a border as this allows use to have a nice gradient
397-
border: none;
398-
border-radius: var(--border-radius-element, var(--border-radius-large));
399-
box-shadow:
400-
0 -1px var(--input-border-color),
401-
0 0 0 1px color-mix(in srgb, var(--input-border-color), 65% transparent);
402-
403-
&:hover:not([disabled]) {
404-
box-shadow: 0 0 0 1px var(--input-border-color);
405-
}
398+
@include border.inputBorder('.textarea--dark', '.textarea--legacy', var(--input-border-color));
399+
406400
&:active:not([disabled]),
407401
&:focus:not([disabled]) {
408402
--input-border-width-offset: 0px;
409403
--input-border-color: var(--color-main-text);
410-
border: var(--border-width-input-focused, 2px) solid var(--input-border-color);
411-
box-shadow: 0 0 0 2px var(--color-main-background) !important;
412404
}
413405
414406
// Hide placeholder while not focussed -> show label instead (only if internal label is used)
@@ -492,24 +484,5 @@ export default {
492484
color: var(--color-success-text);
493485
}
494486
}
495-
496-
// for Nextcloud 31 and older we need the old design with only one color
497-
&--legacy {
498-
.textarea__input {
499-
box-shadow: 0 0 0 1px var(--input-border-color);
500-
}
501-
502-
.textarea__main-wrapper:hover:not(:has([disabled])) {
503-
padding: 0;
504-
505-
.textarea__input {
506-
--input-border-color: var(--color-main-text);
507-
// Reset padding offset when focused
508-
--input-border-width-offset: 0px;
509-
border: var(--border-width-input-focused, 2px) solid var(--input-border-color);
510-
box-shadow: 0 0 0 2px var(--color-main-background) !important;
511-
}
512-
}
513-
}
514487
}
515488
</style>

0 commit comments

Comments
 (0)