-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- platform specific character checks in notes; disallow emojis in iOS - add UI hints for number of characters used & max allowed - add textarea auto-resize as the user inputs increases in size
- Loading branch information
Showing
9 changed files
with
166 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
app/javascript/controllers/character_counter_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
|
||
const ERROR_CLASS = "text-rose-700" | ||
|
||
export default class extends Controller { | ||
static targets = ["input", "counter"] | ||
static values = { | ||
maxLength: {type: Number, default: 500}, | ||
} | ||
|
||
connect() { | ||
this.update() | ||
} | ||
|
||
update() { | ||
const value = this.inputTarget.value.length | ||
|
||
if (value > this.maxLengthValue) { | ||
this.counterTarget.classList.add(ERROR_CLASS) | ||
} else { | ||
this.counterTarget.classList.remove(ERROR_CLASS) | ||
} | ||
|
||
this.counterTarget.innerHTML = value | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<div data-controller="character-counter" data-character-counter-max-length-value="<%= max_length %>"> | ||
<%= form.labeled_textarea obj_method, label_text, data: { character_counter_target: "input", | ||
action: "input->character-counter#update", | ||
controller: "textarea-autogrow" } %> | ||
<p class="text-xs text-secondary"> | ||
Characters – | ||
<strong data-character-counter-target="counter"><%= existing_value&.length || 0 %></strong> | ||
/ <%= max_length %> | ||
</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,3 +44,4 @@ | |
pin "@sentry-internal/replay", to: "https://ga.jspm.io/npm:@sentry-internal/[email protected]/build/npm/esm/index.js" | ||
pin "@sentry-internal/replay-canvas", to: "https://ga.jspm.io/npm:@sentry-internal/[email protected]/build/npm/esm/index.js" | ||
pin "tom-select", to: "https://ga.jspm.io/npm:[email protected]/dist/js/tom-select.complete.js" | ||
pin "stimulus-textarea-autogrow", to: "https://ga.jspm.io/npm:[email protected]/dist/stimulus-textarea-autogrow.mjs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters