Skip to content

Commit

Permalink
Merge pull request #4 from jouni/v0.3
Browse files Browse the repository at this point in the history
v0.3
  • Loading branch information
jouni authored Sep 13, 2019
2 parents ab0f603 + 951bbc9 commit b7217b4
Show file tree
Hide file tree
Showing 69 changed files with 9,260 additions and 4,057 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# j-elements
# JElements

> Proof-of-concept helpers and prototype web components
Expand All @@ -9,7 +9,7 @@

## Proof-of-concept helper elements and mixins

See the documentation for `StylableMixin` and `TeleportingElement`.
See the documentation for `LightStyleElement`, `StylableMixin` and `PortalElement`.



Expand Down
2 changes: 1 addition & 1 deletion docs/app-layout.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# App Layout <maturity-badge proto>(Prototype)</maturity-badge>
# App Layout <maturity-badge preview>(Preview)</maturity-badge>

The `<j-app-layout>` is a responsive application layout that covers multiple common application layout patterns.

Expand Down
2 changes: 1 addition & 1 deletion docs/avatar.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Avatar <maturity-badge rfc>(Request for feedback)</maturity-badge>
# Avatar <maturity-badge beta>(Beta)</maturity-badge>

### Default avatar

Expand Down
2 changes: 1 addition & 1 deletion docs/card.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Card <maturity-badge proto>(Prototype)</maturity-badge>
# Card <maturity-badge preview>(Preview)</maturity-badge>

### Simple card
```html,live
Expand Down
8 changes: 4 additions & 4 deletions docs/dialog.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Dialog <maturity-badge poc>(Proof of concept)</maturity-badge>

A dialog is created using the `<j-dialog>` element. It is based on [Teleporting Element](/teleporting-element), and because of that will always show on top of other content, escaping any parent stacking contexts.
A dialog is created using the `<j-dialog>` element. It is based on [Portal Element](/portal-element), and because of that will always show on top of other content, escaping any parent stacking contexts.

Place any content you wish to show inside the dialog as the children, and use the `visible` attribute/property or the `show()` and `hide()` methods for opening and closing it.
Place any content you wish to show inside the dialog as the children, and use the `show()` and `hide()` methods for opening and closing it.

```html
<j-dialog visible>
Expand All @@ -17,12 +17,12 @@ Place any content you wish to show inside the dialog as the children, and use th
Demonstrating how you can toggle the visibility of a dialog which has been created declaratively with HTML.

```html,live
<button class="show-declarative">Open</button>
<j-button class="show-declarative">Open</j-button>
<j-dialog class="declarative">
<h3>Declarative dialog</h3>
<p>Dialog content.</p>
<button class="hide">Close</button>
<j-button class="hide">Close</j-button>
</j-dialog>
<script>
Expand Down
72 changes: 34 additions & 38 deletions docs/field.md
Original file line number Diff line number Diff line change
@@ -1,76 +1,72 @@
# Field <maturity-badge proto>(Prototype)</maturity-badge>
# Field <maturity-badge preview>(Preview)</maturity-badge>

```javascript
import {JField} from 'j-elements';
```

`<j-field>` is a wrapper element that allows you to add a label and an error message to any input element.

### Text field
It handles accessibility for you automatically, without the need to manually use `id` and `for` attributes to bind the label and the field, as well as showing validation error messages (and making them accessible as well).

> The label is currently announces twice on VoiceOver on macOS Safari.
## Label
```html,live
<j-field>
<label>Label</label>
<input type="text" required>
<p error-message>Error message</p>
<j-input></j-input>
</j-field>
```

### Text field (no label)
## Required validation
```html,live
<j-field>
<input type="text" required>
<p error-message>Error message</p>
<label>Label</label>
<j-input required minlength="3"></j-input>
</j-field>
```

### Text area
## Pattern validation
```html,live
<j-field>
<label slot="label">Label</label>
<textarea required></textarea>
<p error-message>Error message</p>
<label>Label</label>
<j-input pattern="[0-9]+"></j-input>
</j-field>
```

### Date field
```html,live
<j-field>
<label slot="label">Label</label>
<input type="date" required>
<p error-message>Error message</p>
</j-field>
```

### Checkbox group
## Custom error message
```html,live
<j-field>
<label slot="label">Label</label>
<label><input type="checkbox"> Option</label>
<label><input type="checkbox" required> Option</label>
<p error-message>Error message</p>
<label>Label</label>
<j-input required error-message="You should really type something here"></j-input>
</j-field>
```

### Radio button group
## Native text input
```html,live
<j-field>
<label slot="label">Label</label>
<label><input type="radio" required> Option</label>
<label><input type="radio"> Option</label>
<label><input type="radio"> Option</label>
<p error-message>Error message</p>
<label>Label</label>
<input type="text" required pattern="[0-9]+">
</j-field>
```

### Slider
## Native date input
```html,live
<j-field>
<label slot="label">Label</label>
<input type="range">
<label>Choose a date</label>
<input type="date" required>
</j-field>
```

### Vaadin Text Field
## Native select
```html,live
<j-field>
<label slot="label">Label</label>
<vaadin-text-field required></vaadin-text-field>
<p error-message>Error message</p>
<label>Select an option</label>
<select required>
<option></option>
<option>Option one</option>
<option>Option two</option>
<option>Option three</option>
</select>
</j-field>
```
2 changes: 1 addition & 1 deletion docs/howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Install

j-elements is installable with [npm](https://npmjs.org) or any alternative npm client, like [Yarn](https://yarnpkg.com/en/):
JElements is installable with [npm](https://npmjs.org) or any alternative npm client, like [Yarn](https://yarnpkg.com/en/):

```
npm install j-elements
Expand Down
2 changes: 1 addition & 1 deletion docs/icon.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Icon <maturity-badge rfc>(Request for feedback)</maturity-badge>
# Icon <maturity-badge beta>(Beta)</maturity-badge>

## The problem

Expand Down
77 changes: 77 additions & 0 deletions docs/input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Input <maturity-badge preview>(Preview)</maturity-badge>

```javascript
import {JInput} from 'j-elements';
```

## Problem

The native `<input>` element is not styled consistently across different browsers and does not allow placing additional content inside it.

## Solution

`<j-input>` is a text input element which adds prefix and suffix element support, multi-line and autosizing (both horizontal and vertical) for the native `<input>` element.


## Examples

### Default configuration
```html,live
<j-input placeholder="Type here"></j-input>
```

### Autosize
```html,live
<j-input value="Auto width" autosize></j-input>
```

### Number input
With prefix and suffix elements.
```html,live
<j-input value="123" type="number" autosize>
<span slot="start">$</span>
<span slot="end" style="margin-left: 0;">.00</span>
</j-input>
```

### Multi-line
Multi-line inputs are user-resizable by default in both directions. You can control this with the `resize` CSS property.
```html,live
<j-input multiline placeholder="Type a lot here"></j-input>
```

### Multi-line, autosize
The autosizing multi-line input prevents user-resizing by default.
```html,live
<j-input multiline value="Auto\nheight" autosize></j-input>
```

## Styling

The input can be styled similarly as the native `<input>` element, using border, background, padding, box-shadow, display, etc.

The only exception is the `:focus` and `:focus-visible` pseudo-classes – use the `[focus]` and `[focus-visible]` state attributes instead.

```html,live
<j-input class="custom"></j-input>
<style>
j-input.custom {
border-width: 2px;
background-color: #eee;
font-weight: bold;
padding: 0.8em 1em;
border-radius: 1em;
}
j-input.custom:hover {
border-color: #666;
background-color: #fff;
}
j-input.custom[focus] {
border-color: orange;
box-shadow: 0 0 0 4px yellow;
}
</style>
```
10 changes: 7 additions & 3 deletions docs/maturity.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Maturity Levels

The components and utilities in this project are labelled with maturity level. The level indicates the varying goals and stages of development.
The components and utilities in this project are labelled with a maturity level. The level indicates the varying goals and stages of development.

### Give feedback

Expand All @@ -14,14 +14,18 @@ The component/utility is testing a concept, a solution to a specific problem, h

The component/utility is not recommended to be used directly in any production app, as it has not been thoroughly tested.

## Prototype <maturity-badge proto>Prototype</maturity-badge>
## Preview <maturity-badge preview>Preview</maturity-badge>

The component/utility is in early stage development, and likely to go through major changes. The idea is that it will eventually be suitable for production use, once it has gone through proper testing and feedback rounds. Feedback about the API, performance and user experience is welcomed.

## Request for feedback <maturity-badge rfc>Request for feedback</maturity-badge>
## Beta <maturity-badge beta>Beta</maturity-badge>

The component/utility seems to solve a specific problem and the solution looks like the right one. Now it’s time to try it out in a real application and provide feedback about any potential bugs or other smaller shortcomings.

## Stable <maturity-badge stable>Stable</maturity-badge>

The component/utility has been tested and found to be a good solution and suitable for production use. There are no large issues regarding it’s use.

## Deprecated <maturity-badge deprecated>Deprecated</maturity-badge>

The component/utility did not evolve into a really useful thing, and the development of it has been discontinued.
Loading

0 comments on commit b7217b4

Please sign in to comment.