Directory

← Back

hydrofoil-shell

Barebone base for building Hypermedia-driven applications

Author

Contributors

Rating

Popularity

<100

hydrofoil-shell

UI-agnostic base element which can be used to build hypermedia-driven single page applications.

Implemented using lit-element

Installation

yarn add @hydrofoil/hydrofoil-shell

Usage

<hydrofoil-shell>

The core element, which manages a state (single resource representation).

This element is abstract. It does not:

  • handle of client-server interaction (doesn't load the resource)
  • does not render any shell UI
  • delegates the rending of resource representations to <lit-view> element

Using the element

In order to actually deploy a shell element simple steps are required:

  1. inherit from the base
  2. implement loadResourceInternal
  3. override renderMain to create some core app UI

Here's an example of how this would be done

import HydrofoilShell from '@hydrofoil-shell/hydrofoil-shell/hydrofoil-shell'
import {customElement, html} from 'lit-element'

@customElement('my-app-shell')
export default class MyAppShell extends HydrofoilShell {
  renderMain () {
    // call base to keep using <lit-view> to render the actual resource
    return html`
      <nav>Some static menu</nav>
      <section class=main>
        ${base.renderMain()}
      </section>
      <footer>Footer element</footer>
    `
  }

  loadResourceInternal (uri) {
    return fetch(uri)
  }
}

The base shell element does not implement the actual loading so that it's not being coupled with a single client library or API implementation. Still, instead of repeating the load method every time you should build a hydrofoil application, a mixin can be used instead to reuse the logic for loading the resources.

For example, Hydra APIs can be consumed by mixing in alcaeus-loader

+import AlcaeusLoader from '@hydrofoil-shell/alcaeus-loader`

@customElement('my-app-shell')
-export default class MyAppShell extends HydrofoilShell {
+export default class MyAppShell extends AlcaeusLoader(HydrofoilShell) {

-  loadResourceInternal (uri) {
-    return fetch(uri)
-  }
}

<hydrofoil-multi-resource-view>

A helper element, which helps manage multiple resource. Just as the base shell element, it only serves as a skeleton and needs to be inherited to actually serve as a presentation layer.

For examples check out the material design implementations hydrofoil-resource-tabs and hydrofoil-resource-accordion.

Usage

The element is controlled by standard DOM events. To add a resource to the ones displayed dispatch hydrofoil-append-resource from any child element.

child.dispatchEvent(new CustomEvent('hydrofoil-append-resource', {
  bubbles: true,
  composed: true,
  detail: {
    parent: currentResource,
    resource: nextResource,
  },
}))

Both parent and resource are mandatory. If parent is not the topmost resource on the stack all its current children will be replaced with nextResource.

To remove an element from the stack, dispatch hydrofoil-close-resource. This will also remove any other resources higher on the stack.

child.dispatchEvent(new CustomEvent('hydrofoil-append-resource', {
  bubbles: true,
  composed: true,
  detail: {
    resource: removedResource,
  },
}))
Examples
Before event After Note
1. resA hydrofoil-append-resource
- parent: resA
- resource: resB
1. resA
2. resB
Add resB to stack
1. resA
2. resB
hydrofoil-append-resource
- parent: resA
- resource: resC
1. resA
2. resC
Replace resB with resC
1. resA
2. resC
hydrofoil-append-resource
- parent: resC
- resource: resD
1. resA
2. resC
3. resD
Further append resD
1. resA
2. resC
3. resD
hydrofoil-close-resource
- resource: resC
1. resA Remove resC which also discards resD

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Dependencies

  • @babel/core#^7.4.4
  • @babel/preset-env#^7.4.4
  • @lit-any/lit-any#^0.8.1
  • ld-navigation#^0.5.2
  • lit-element#^2.0.0
Released
2019-05-08
Maturity
IMPORTED
License
MIT License

Compatibility

Framework
Browser
Browser Independent

morph-list-view-item - Vaadin Add-on Directory

List view item component morph-list-view-item - Vaadin Add-on Directory
# morph-list-view-item [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/PolymerElements/paper-progress) A lightning fast list view item web component using LitElement base class. `morph-list-view-item` changes its look automatically and will native native based on when it is either IOS device or Android device. ## Getting Started For the information about how to clone the desired repository, running the local server and testing, please refer to Polymorph elements getting started docs at the end of this repository. ## Demo ```html

Android

Android List Item Android Version Android list item with href becomes a link with ripple effect by default Android Version Expandable Link - Click to close or expand Android Version Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean elementum id neque nec commodo. Sed vel justo at turpis laoreet pellentesque quis sed lorem. Integer semper arcu nibh, non mollis arcu tempor vel. Sed pharetra tortor vitae est rhoncus, vel congue dui sollicitudin. Donec eu arcu dignissim felis viverra blandit suscipit eget ipsum.

IOS

IOS List Item IOS Version IOS list item with no-chevron attribute IOS Version Expandable Link - Click to close or expand IOS Version Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean elementum id neque nec commodo. Sed vel justo at turpis laoreet pellentesque quis sed lorem. Integer semper arcu nibh, non mollis arcu tempor vel. Sed pharetra tortor vitae est rhoncus, vel congue dui sollicitudin. Donec eu arcu dignissim felis viverra blandit suscipit eget ipsum. ``` - Here is a quick demo of the morph-list-view-item element for IOS platform.

IOS morph-list-view-item demo

- Here is a quick demo of the morph-list-view-item element for Android platform.

IOS morph-list-view-item demo

- Both IOS and Android demo are using the HTML markup. ```html ``` - Demo when morph-list-view-item is inside morph-list-view for IOS platform

IOS morph-list-view-item demo

- Demo when morph-list-view-item is inside morph-list-view for IOS platform

IOS morph-list-view-item demo

- Here's the HTML markup when morph-list-view-item is inside morph-list-view for both IOS and Android platform ```html ``` - Demo showing ripple effect when morph-list-view-item is a link on Android platform

IOS morph-list-view-item demo

- Sample HTML markup for expandable item ```html Link 1 Version Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean elementum id neque nec commodo. Sed vel justo at turpis laoreet pellentesque quis sed lorem. Integer semper arcu nibh, non mollis arcu tempor vel. Sed pharetra tortor vitae est rhoncus, vel congue dui sollicitudin. Donec eu arcu dignissim felis viverra blandit suscipit eget ipsum. ``` - Demo showing expandable item

IOS morph-list-view-item demo

### Attributes | Custom Attribute | Type | Description | Default | |:-----------------------:|:-------:|-----------------------------------------------------------------------------------------------|----------------| | **`href`** | String | Takes the value of the url. When **`href`** is present, the item becomes a link | **no default** | | **`containsMedia`** | Boolean | This is an option for items to take in media/images instead of just icons | **`false`** | | **`noRipple`** | Boolean | To have a list item with no ripple assign **`true`** or just set this on the the html markup | **`false`** | | **`noChevron`** | Boolean | To have a list item with no chevron assign **`true`** or just set this on the the html markup | **`false`** | | **`expandable`** | Boolean | Option to have expandable list item with expandable content just assign **`true`** | **`false`** | | **`expanded`** | Boolean | Option to expand list item just assign **`true`** or just set this on the the html markup | **`false`** | ### Styling - Custom CSS property Custom property | Description | Default | -----------------------------------|----------------------------------------------------------------------------------|------------| `--display-top-line` | Display property for item top line use to configure when on a list view | block | `--display-inner-item-bottom-line` | Display property for item inner bottom line use to configure when on a list view | none | ## Further help For more information on how to install and run test please go here - [Polymorph elements getting started] [Polymorph elements getting started]: https://github.com/moduware/polymorph-components/blob/master/INFO.md
View on NPM
View on GitHub

morph-list-view-item version 1.0.0
### Dependencies * @polymer/polymer#^3.0.0 * @polymer/iron-icons#^3.0.0-pre.18 * @moduware/morph-element#^1.0.0 * @moduware/morph-ripple#^1.0.0 * @moduware/morph-shared-styles#^1.0.0

morph-list-view-item version 1.1.0
### Dependencies * @polymer/lit-element#^0.6.2 * @moduware/morph-ripple#^1.1.0 * @moduware/morph-shared-styles#^1.0.0 * @moduware/lit-utils#^1.0.0

morph-list-view-item version 2.0.0
### Dependencies * lit-element#^2.0.1 * @moduware/morph-ripple#^2.0.0 * @moduware/lit-utils#^1.0.0

morph-list-view-item version 2.0.1
### Dependencies * lit-element#^2.0.1 * @moduware/morph-ripple#^2.0.0 * @moduware/lit-utils#^1.0.0

morph-list-view-item version 2.0.2
### Dependencies * lit-element#^2.0.1 * @moduware/morph-ripple#^2.0.0 * @moduware/lit-utils#^1.0.0

Online