Giter Club home page Giter Club logo

material-shell's Introduction

material-shell

Published on npm

Shell element for material app.

Its utility revolves around these principles:

  • It should be the first script/element to be fetched to avoid FOUC (in non-SSR environment)
  • The element loads default material styles (tokens)
    • or load the tokens saved in material-theme local storage if it exists.
  • Your app can be slotted inside the element.
  • The element shows a circular progress by default, you can use helper functions to toggle loading/showing content.

Playground Demo

Usage

Install

npm add -D material-shell

Importing styles and shell element

index.html:

<head>
	<script src="./node_modules/material-shell/material-styles.js"></script>
	<script src="./node_modules/material-shell/material-shell.js"></script>
</head>
<body>
	<material-shell></material-shell>
</body>

Notes:

  • Update src to wherever the scripts are located, they should be included during your building process
  • The scripts are minified for fast loading
  • You can load these scripts from a CDN

Slot your app

By default <material-shell> element will show a circular progress in the middle of the screen, even if you slot a content:

index.html:

<material-shell>
	<my-material-app-or-whatever></my-material-app-or-whatever>
</material-shell>

When your content is ready you can send an event to instruct the shell to show content:

// Somewhere in your app when content is ready
myApp.dispatchEvent(
	new Event('material-loading-off', {composed: true, bubbles: true})
);

But that's tedious, instead you can use a helper function:

import {materialShellLoadingOff} from 'material-shell';

// Somewhere in your app...
materialShellLoadingOff.call(this);

(There is also materialShellLoadingOn in case you want to hide the content again)

License

MIT License

material-shell's People

Contributors

vdegenne avatar vandeurenglenn avatar

Watchers

 avatar

Forkers

vandeurenglenn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.