Skip to content
JavaScript HTML
Branch: master
Clone or download

Latest commit

CircleCI
CircleCI chore: release new versions
 - @lion/dialog@0.4.15
 - @lion/form-system@0.7.3
 - @lion/input-datepicker@0.11.3
 - @lion/overlays@0.13.0
 - @lion/select-rich@0.14.2
 - @lion/tooltip@0.8.10
Latest commit 41ac853 Apr 7, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci chore: add bundlesize checks Dec 5, 2019
.github/ISSUE_TEMPLATE chore: add issue template Oct 15, 2019
.storybook chore: announcement blog Feb 12, 2020
bundlesize chore: move radio, checkbox and option Mar 4, 2020
demo chore: Make pronouns consistent Mar 2, 2020
docs chore: docs Subclasser conventions Mar 2, 2020
packages chore: release new versions Apr 7, 2020
scripts fix: use strict versions to get correct deps on older versions Dec 2, 2019
.editorconfig chore: announcement blog Feb 12, 2020
.eslintignore chore: add bundlesize checks Dec 5, 2019
.eslintrc.js chore: move all devDependencies to the root Apr 2, 2020
.gitignore chore: add bundlesize checks Dec 5, 2019
.markdownlint.json chore: support linting and formatting of markdown files Jul 24, 2019
.prettierignore chore: add bundlesize checks Dec 5, 2019
CONTRIBUTING.md chore: update docs for closing feature requests Nov 13, 2019
LICENSE feat: release inital public lion version Apr 26, 2019
README.md feat: update to stable @open-wc/scoped-elements Mar 25, 2020
commitlint.config.js feat: release inital public lion version Apr 26, 2019
husky.config.js fix: improve yarn lock scan, always run Jan 9, 2020
karma.bs.config.js chore: enable circleci Apr 26, 2019
karma.conf.js feat(helpers): add handling duplicate consecutive logs to action logger Jan 17, 2020
lerna.json chore: mdx changes should not trigger releases Feb 10, 2020
package.json chore: move all devDependencies to the root Apr 2, 2020
prettier.config.js feat: release inital public lion version Apr 26, 2019
wallaby.js chore: update linting Aug 21, 2019
yarn.lock feat: update to stable @open-wc/scoped-elements Mar 25, 2020

README.md

Lion Web Components

Lion web components is a set of highly performant, accessible and flexible Web Components. They provide an unopinionated, white label layer that can be extended to your own layer of components.

For some more details see the announcement blog post.

TODOs

Demos

We do have a live Storybook which shows all our components.

Please note: This project uses Yarn Workspaces. If you want to run all demos locally you need to get Yarn and install all depencies by executing yarn install.

How to install

npm i @lion/<package-name>

Content

The accessibility column indicates whether the functionality is accessible in its core. Aspects like styling and content determine actual accessibility in usage.

Package Version Description Accessibility
-- Buttons --
button button Button ✔️
switch switch Switch ✔️
-- Forms --
form form Wrapper for multiple form elements ✔️
field field Base Class for all inputs ✔️
fieldset fieldset Group for form inputs ✔️
validate validate Validation for form components n/a
checkbox checkbox Checkbox form element ✔️
checkbox-group checkbox-group Group of checkboxes ✔️
input input Input element for strings ✔️
input-amount input-amount Input element for amounts ✔️
input-date input-date Input element for dates ✔️
input-datepicker input-datepicker Input element for dates with a datepicker ✔️
input-email input-email Input element for e-mails ✔️
input-iban input-iban Input element for IBANs ✔️
input-range input-range Input element for a range of values ✔️
radio radio Radio from element ✔️
radio-group radio-group Group of radios ✔️
select select Simple native dropdown element ✔️
textarea textarea Multiline text input ✔️
-- Overlays --
overlays overlays Overlay System ✔️
dialog dialog Dialog element ✔️
tooltip tooltip Tooltip element #175
-- Icons --
icon icon Display our svg icons #173, #172
-- Navigation --
steps steps Multi Step System n/a
tabs tBS Move between a small number of equally important views n/a
-- Others --
core core Core System (exports LitElement, lit-html) n/a
calendar calendar Standalone calendar #195, #194
localize localize Localize and translate your application/components n/a
ajax ajax Fetching data via ajax request n/a

How to use

Use a Web Component

<script type="module">
  import '@lion/input/lion-input.js';
</script>

<lion-input name="firstName"></lion-input>

Use a JavaScript system

<script type="module">
  import { ajax } from '@lion/ajax';

  ajax.get('data.json').then(response => {
    // most likely you will use response.data
  });
</script>

Extend a Web Component

import { LionInput } from '@lion/input';

class MyInput extends LionInput {}
customElements.define('my-input', MyInput);

Key Features

  • High Performance - Focused on great performance in all relevant browsers with a minimal number of dependencies
  • Accessibility - Aimed at compliance with the WCAG 2.0 AA standard to create components that are accessible for everybody
  • Flexibility - Provides solutions through Web Components and JavaScript classes which can be used, adopted and extended to fit all needs

Technologies

Lion Web Components aims to be future proof and use well-supported proven technology. The stack we have chosen should reflect this.

Rationale

We know from experience that making high quality, accessible UI components is hard and time consuming: it takes many iterations, a lot of development time and a lot of testing to get a generic component that works in every context, supports many edge cases and is accessible in all relevant screen readers.

Lion aims to do the heavy lifting for you. This means you only have to apply your own Design System: by delivering styles, configuring components and adding a minimal set of custom logic on top.

Coding guidlines

Check out our coding guidelines for more detailed information.

How to contribute

Lion Web Components are only as good as its contributions. Read our contribution guide and feel free to enhance/improve Lion. We keep feature requests closed while we're not working on them.

Scoped elements

The CustomElementRegistry provides methods for registering custom elements. One of the limitations of working with this global registry is that multiple versions of the same element cannot co-exist. This causes bottlenecks in software delivery that should be managed by the teams and complex build systems. Scoped Custom Element Registries is a proposal that will solve the problem. Since this functionality won't be available (especially not cross browser) anytime soon, we've adopted OpenWC's Scoped Elements.

Whenever a lion component uses composition (meaning it uses another lion component inside), we apply ScopedElementsMixin to make sure it uses the right version of this internal component.

import { ScopedElementsMixin, LitElement, html } from '@lion/core';

import { LionInput } from '@lion/input';
import { LionButton } from '@lion/button';

class MyElement extends ScopedElementsMixin(LitElement) {
  static get scopedElements() {
    return {
      'lion-input': LionInput,
      'lion-button': LionButton,
    };
  }

  render() {
    return html`
      <lion-input label="Greeting" name="greeting" .modelValue=${'Hello world'}></lion-input>
      <lion-button>Save</lion-button>
    `;
  }
}

Query selectors

Since Scoped Elements changes tagnames under the hood, a tagname querySelector should be written like this:

this.querySelector(this.constructor.getScopedTagName('lion-input'));

CSS selectors

Avoid tagname css selectors (we already avoid query selectors internally in lion, but just be aware that a selector like lion-input {...} will stop working ).

Edge cases

Sometimes we need to render parts of a template to light dom for accessibility. For instance we render a node via lit-html that we append to the host element, so it gets slotted in the right position. In this case, we should also make sure that we also scope the rendered element.

We can do this as follows:

_myLightTemplate() {
  return html`
    This template may be overridden by a Subclasser.
    Even I don't end up in shadow root, I need to be scoped to constructor.scopedElements as well.
    <div>
      <lion-button>True</lion-button>
      <lion-input label="xyz"></lion-input>
    </div>
  `;
}

__getLightDomNode() {
  const renderParent = document.createElement('div');
  this.constructor.render(this._myLightTemplate(), renderParent, {
    scopeName: this.localName,
    eventContext: this,
  });
  // this node will be appended to the host
  return renderParent.firstElementChild;
}

connectedCallback() {
  super.connectedCallback();
  this.appendChild(this.__getLightDomNode());
}

In a less complex case, we might just want to add a child node to the dom.

import { ScopedElementsMixin, LitElement } from '@lion/core';

...

__getLightDomNode() {
  return document.createElement(this.constructor.getScopedTagName('lion-input'));
}

We encourage you to have a look at OpenWC's Scoped elements.

Contact

Feel free to create a github issue for any feedback or questions you might have. You can also find us on the Polymer slack in the #lion channel.

You can join the Polymer slack by visiting https://www.polymer-project.org/slack-invite.

Support and issues

As stated above "support and issues time" is currently rather limited: feel free to open a discussion. However, we can not guarantee any response times.

You can’t perform that action at this time.