Skip to content

Commit 2316593

Browse files
WEBDEV-7287 Add character counter to review form (#22)
* Tidy up styles to match original form * Switch to ia-styles package and continue tidying styles * Build out char counter * Update copy * Add localization * Extract submit button disabling logic * Remove unused if-check * Also disable submisison if subject or review is empty * Tidy up following CR * Move font size declaration out of component * TEMP - remove new tests to identify failure point * Appease linter * Re-add new tests
1 parent 9184f17 commit 2316593

File tree

6 files changed

+318
-144
lines changed

6 files changed

+318
-144
lines changed

demo/app-root.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ export class AppRoot extends LitElement {
4444
@state()
4545
private showErrors: boolean = false;
4646

47+
@state()
48+
private useCharCounts: boolean = true;
49+
4750
render() {
4851
return html`${!this.recaptchaManager
4952
? html`<button
@@ -61,14 +64,19 @@ export class AppRoot extends LitElement {
6164
${!this.bypassRecaptcha ? 'Bypass' : 'Enable'} ReCaptcha
6265
</button>
6366
<button @click=${() => (this.showErrors = !this.showErrors)}>
64-
${this.showErrors ? 'Hide' : 'Show'} Pre-filled Errors
67+
${this.showErrors ? 'Hide' : 'Show'} pre-filled errors
68+
</button>
69+
<button @click=${() => (this.useCharCounts = !this.useCharCounts)}>
70+
${this.useCharCounts ? 'Remove' : 'Use'} char count limits
6571
</button>
6672
<div class="container">
6773
<ia-review-form
6874
.identifier=${'goody'}
6975
.oldReview=${this.mockOldReview}
7076
.recaptchaManager=${this.recaptchaManager}
7177
.prefilledErrors=${this.showErrors ? this.errors : []}
78+
.maxSubjectLength=${this.useCharCounts ? 100 : undefined}
79+
.maxBodyLength=${this.useCharCounts ? 1000 : undefined}
7280
?bypassRecaptcha=${this.bypassRecaptcha}
7381
></ia-review-form>
7482
</div>`;
@@ -78,6 +86,7 @@ export class AppRoot extends LitElement {
7886
.container {
7987
max-width: 750px;
8088
margin: 10px auto;
89+
font-size: 1.4rem;
8190
}
8291
`;
8392
}

package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
]
6969
},
7070
"dependencies": {
71+
"@internetarchive/ia-styles": "^1.0.0",
7172
"@internetarchive/metadata-service": "^1.0.3",
7273
"@internetarchive/recaptcha-manager": "^1.0.0",
7374
"@lit/localize": "^0.12.2",

0 commit comments

Comments
 (0)