diff --git a/routes/_components/compose/LiteComposeBox.html b/routes/_components/compose/LiteComposeBox.html index f0347d1a..81e1a6d2 100644 --- a/routes/_components/compose/LiteComposeBox.html +++ b/routes/_components/compose/LiteComposeBox.html @@ -13,6 +13,14 @@ ref:textarea bind:value=inputText > +
+ + {{inputLengthToDisplay}} + @@ -31,10 +39,11 @@ grid-template-areas: "avatar display-name handle" "avatar input input" + "avatar gauge gauge" + "avatar length length" "avatar button button"; grid-template-columns: min-content minmax(0, max-content) 1fr; grid-template-rows: min-content min-content min-content; - grid-row-gap: 10px; border-bottom: 1px solid var(--main-border); width: 560px; max-width: calc(100vw - 40px); @@ -77,13 +86,40 @@ padding: 5px; border: 1px solid var(--input-border); min-height: 75px; + margin-top: 10px; resize: none; + overflow: hidden; } .compose-profile-button { grid-area: button; justify-self: right; text-transform: uppercase; + margin-top: 10px; + } + + .compose-profile-length-gauge { + grid-area: gauge; + height: 2px; + background: var(--main-theme-color); + margin-left: 5px; + transform-origin: left; + } + + .compose-profile-length { + grid-area: length; + margin-top: 5px; + justify-self: right; + color: var(--main-theme-color); + font-size: 1.1em; + } + + .compose-profile-length.over-char-limit { + color: var(--warning-color); + } + + .compose-profile-length-gauge.over-char-limit { + background: var(--warning-color); } @media (max-width: 767px) { @@ -107,6 +143,8 @@ import debounce from 'lodash/debounce' import { mark, stop } from '../../_utils/marks' + const CHAR_LIMIT = 500 + export default { oncreate() { this.set({inputText: store.get('currentInputTextInCompose')}) @@ -137,7 +175,18 @@ }, store: () => store, computed: { - currentInputTextInCompose: ($currentInputTextInCompose) => $currentInputTextInCompose + currentInputTextInCompose: ($currentInputTextInCompose) => $currentInputTextInCompose, + inputLength: (inputText) => inputText ? inputText.length : 0, + inputLengthToDisplay: (inputLength) => (inputLength <= CHAR_LIMIT ? inputLength : CHAR_LIMIT - inputLength), + inputLengthAsFractionOfMax: (inputLength) => (Math.min(CHAR_LIMIT, inputLength)) / CHAR_LIMIT, + overLimit: (inputLength) => inputLength > CHAR_LIMIT, + inputLengthLabel: (overLimit, inputLengthToDisplay) => { + if (overLimit) { + return `${inputLengthToDisplay} characters over limit` + } else { + return `${inputLengthToDisplay} characters` + } + } } } \ No newline at end of file diff --git a/scss/themes/_base.scss b/scss/themes/_base.scss index 21db38b2..6c3a0892 100644 --- a/scss/themes/_base.scss +++ b/scss/themes/_base.scss @@ -67,4 +67,6 @@ --very-deemphasized-text-color: rgba(#666, 0.6); --status-direct-background: darken($body-bg-color, 5%); + --main-theme-color: $main-theme-color; + --warning-color: #e01f19; } diff --git a/templates/2xx.html b/templates/2xx.html index c5944c6d..9c751383 100644 --- a/templates/2xx.html +++ b/templates/2xx.html @@ -10,9 +10,9 @@