0 && count > maxcount)}
+ class:disabled={isDisabled}
style={`
${calculateMargin(mt, mr, mb, ml)};
--width: ${width};
+ --char-count-padding: ${showCount || maxcount > 0 ? "2rem" : "0"};
`}
>
- {#if showCounter}
- {#if maxcharcount > 0}
-
maxcharcount}>
- {value.length}{`/${maxcharcount}`}
-
- {:else if value.length > 0}
-
- {value.length}
-
- {/if}
+
+ {#if maxcount > 0 && !isDisabled}
+
maxcount}>
+ {#if count > maxcount}
+ {count - maxcount} {pluralize(countby, count - maxcount)} too many
+ {:else if count < maxcount}
+ {maxcount - count} {pluralize(countby, maxcount - count)} remaining
+ {/if}
+
+ {/if}
+
+ {#if showCount && count > 0 && !isDisabled}
+
+ {count} {pluralize(countby, count)}
+
{/if}
@@ -106,23 +121,33 @@
font-family: var(--goa-font-family-sans);
}
- .container {
+ .root {
position: relative;
width: 100%;
+ padding-bottom: var(--char-count-padding);
+ border: var(--goa-border-width-s) solid var(--goa-color-greyscale-700);
+ border-radius: 3px;
}
+
+ .root:has(textarea:disabled) {
+ background-color: var(--goa-color-greyscale-100);
+ border-color: var(--goa-color-greyscale-200);
+ cursor: default;
+ box-shadow: none;
+ }
+
@media not (--mobile) {
- .container {
+ .root {
max-width: var(--width);
}
}
- .goa-textarea {
+ textarea {
display: block;
width: 100%;
box-sizing: border-box;
outline: none;
- border: 1px solid var(--goa-color-greyscale-700);
- border-radius: 3px;
+ border: none;
color: var(--goa-color-greyscale-black, #ccc);
padding: var(--textarea-padding-vertical) var(--textarea-padding-horizontal);
font-size: var(--goa-font-size-4);
@@ -142,44 +167,53 @@
cursor: pointer;
}
- .goa-textarea:hover {
+ .root:hover {
box-shadow: 0 0 0 var(--goa-border-width-m) var(--goa-color-interactive-hover);
}
- .goa-textarea:active,
- .goa-textarea:focus,
- .goa-textarea:focus-within {
+
+ .root:focus-within {
box-shadow: 0 0 0 var(--goa-border-width-l) var(--goa-color-interactive-focus);
}
- .goa-textarea:disabled,
- .goa-textarea:disabled:hover,
- .goa-textarea:disabled:active,
- .goa-textarea:disabled:focus {
- background-color: var(--goa-color-greyscale-100);
- border-color: var(--goa-color-greyscale-200);
- cursor: default;
- box-shadow: none;
+ .counter-error {
+ color: var(--goa-color-interactive-error)
}
.counter {
position: absolute;
- right: 0;
- padding-top: 0.25rem;
+ right: 0.75rem;
font-size: var(--goa-font-size-2);
}
- .counter-error {
- color: var(--goa-color-interactive-error)
+ textarea {
+ resize: none;
+ scroll-behavior: smooth;
+ max-height: calc(100vh * var(--max-height, 100) / 100);
}
+ textarea::-webkit-scrollbar {
+ width: 6px;
+ }
+
+ textarea::-webkit-scrollbar-track {
+ background: #f1f1f1;
+ }
+
+ textarea::-webkit-scrollbar-thumb {
+ background: #888;
+ }
+
+ textarea::-webkit-scrollbar-thumb:hover {
+ background: #555;
+ }
+
.error {
- border: var(--goa-border-width-m) solid var(--goa-color-interactive-error);
- box-shadow: 0 0 0 var(--goa-border-width-s) var(--goa-color-interactive-error);
+ border-color: var(--goa-color-interactive-error);
+ box-shadow: 0 0 0 var(--goa-border-width-m) var(--goa-color-interactive-error);
}
.error:hover {
box-shadow: 0 0 0 var(--goa-border-width-m) var(--goa-color-interactive-error);
}
-
.error:active,
.error:focus {
box-shadow: 0 0 0 var(--goa-border-width-l) var(--goa-color-interactive-focus);