Skip to content

Commit

Permalink
fix error states
Browse files Browse the repository at this point in the history
  • Loading branch information
heapwolf committed Sep 17, 2023
1 parent bc9d833 commit 85cff6d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion input/index.js
Expand Up @@ -171,7 +171,7 @@ export class TonicInput extends Tonic {
bottom: 100%;
left: 50%;
width: fit-content;
transform: translateY(-10px);
transform: translate(-50%, -10px);
transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s ease 1s;
visibility: hidden;
opacity: 0;
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@socketsupply/components",
"version": "14.0.6",
"version": "14.0.7",
"description": "Example components",
"type": "module",
"scripts": {
Expand Down
15 changes: 9 additions & 6 deletions textarea/index.js
Expand Up @@ -44,7 +44,7 @@ export class TonicTextarea extends Tonic {
appearance: none;
}
tonic-textarea textarea:invalid {
tonic-textarea[edited] textarea:invalid {
border-color: var(--tonic-danger, #f66);
}
Expand Down Expand Up @@ -87,7 +87,7 @@ export class TonicTextarea extends Tonic {
}
tonic-textarea[label] .tonic--invalid {
margin-bottom: 13px;
margin-bottom: 0px;
}
tonic-textarea .tonic--invalid {
Expand All @@ -98,7 +98,7 @@ export class TonicTextarea extends Tonic {
bottom: 100%;
left: 50%;
width: fit-content;
transform: translateY(-10px);
transform: translate(-50%, -10px);
transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s ease 1s;
visibility: hidden;
opacity: 0;
Expand Down Expand Up @@ -127,7 +127,6 @@ export class TonicTextarea extends Tonic {
border-right: 6px solid transparent;
border-top: 6px solid var(--tonic-error, #f66);
}
`
}

Expand Down Expand Up @@ -214,6 +213,12 @@ export class TonicTextarea extends Tonic {
}

keyup (e) {
const value = e.target.value.trim()

if (this.props.required && !value) {
return this.setInvalid('Value Required')
}

if (!this.props.pattern) {
return
}
Expand All @@ -222,8 +227,6 @@ export class TonicTextarea extends Tonic {
this.regex = new RegExp(this.props.pattern)
}

const value = e.target.value.trim()

value.match(this.regex)
? this.setValid()
: this.setInvalid('Invalid')
Expand Down

0 comments on commit 85cff6d

Please sign in to comment.