0.3.13 • Published 5 years ago

tjb-input v0.3.13

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

tjb-input

Webcomponents input (optionally with labelfield).

Features

  • easy to use
  • accessible
  • time saving

Example

https://tjb-webcomponents.github.io/tjb-input/

Add to project

You might want to use a Polyfill for WebComponent:

<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.2.0/webcomponents-lite.js"></script>

Include via HTML

Include it:

<script
  src="https://tjb-webcomponents.github.io/tjb-input/tjb-input.min.js"
  type="module"
></script>

Include via JavaScript

import 'https://tjb-webcomponents.github.io/tjb-input/tjb-input.min.js'

Include via NPM

Console:

npm i -S tjb-input

Then in your code:

import 'tjb-input';

Useage

<tjb-input></tjb-input>

Attributes

Tiny Example:

<tjb-input
  label="Password"
  type="password"
  name="password"
  info="minimum 8 digits"
  pattern=".{8,}"
  errormessage="please check this input"
></tjb-input>

All attributes:

attributeexampledescription
labellabel="Password"the text of the corresponding label field.
typetype="password"type of the input field
namename="password"name of the input field
infoinfo="minimum 8 digitstiny info text shown besides the label
patternpattern=".{8,}"regex pattern to check if input is valid
errormessageerrormessage="please check your password"message to display if input is invalid
successmessagesuccessmessage="√"message to display if input is valid
requiredrequired="true"add required flag to input
nosubmitnosubmit="true"whether or not the nearest form feald should be submitted on enter key
valuevalue="foo"sets the value of the input field

Methods

methodpropertiesexampledescription
showMessage- type (@String) 'error' / 'success'tjbInput.showMessage("error")displays the respective border color and message text
hideMessage-tjbInput.hideMessage()hides border color and message text
checkValidity-tjbInput.checkValidity()checks whether or not the input field is valid. Displays the success message if so and the error message if not
submit-tjbInput.submit()submits the nearest form element if input is valid
focus-tjbInput.focus()focus the input node

events

eventdescription
changewhen the value of the input field is changed

Styling

Default public values:

:host {
  --input-color-error: #fa354c;
  --input-color-success: limegreen;
  --input-padding: 10px;
  --input-margin: 0 0 30px 0;
  --input-width: 100%;
  --input-border: 1px solid transparent;
  --input-border-bottom: 1px solid lightgrey;
  --input-border-radius: 0;
  --input-font-size: 1rem;
  --input-info-color: grey;
  --input-info-font-size: 0.8rem;
  --input-label-margin: 0 0 5px 0;
}

These can be overwritten easily by targetting the element. Example:

tjb-input {
  --input-width: 300px;
}

Enjoy

Typewriter Gif

0.3.13

5 years ago

0.3.12

5 years ago

0.3.11

5 years ago

0.3.10

5 years ago

0.3.9

5 years ago

0.3.8

5 years ago

0.3.7

5 years ago

0.3.6

5 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.11

5 years ago

0.2.10

5 years ago

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago