npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ficusjs/app-shell-ui-loader

v0.1.0

Published

UI components for the FicusJS App Shell

Downloads

0

Readme

Ficus App Shell UI Loader

The app shell UI loader is the minimal UI required for an app. It is loaded as soon as possible, and is responsible for loading the rest of the app.

Usage

The app shell UI loader loads the initial UI for the app. The initial UI is the minimal UI required for the app to be visible on either mobile or desktop. The initial UI is loaded as soon as possible, and is responsible for loading the rest of the app.

To use the app shell UI loader, add the following to your index.html:

<script type="module">
  import { createLoader, html } from 'https://cdn.skypack.dev/@ficusjs/app-shell-ui-loader'
  createLoader()
</script>

API

createLoader(options)

The createLoader(options) function loads the initial UI for the app. The initial UI is the minimal HTML and CSS required for the app to be presented to the user. The initial UI is typically rendered using placeholders before the content is fully loaded. The loader is then responsible for loading the rest of the app.

Options can be passed to the createLoader(options) function to configure the loader. The following example shows the default values for each option. When passing options, all properties are optional, so you only need to override the values you want to change.

import { createLoader, html } from 'https://cdn.skypack.dev/@ficusjs/app-shell-ui-loader'

createLoader({
  appTagName: 'fas-app',
  desktopMediaQuery: '(min-width: 1280px)',
  breakpointReactive: false,
  desktopUiTagName: 'fas-ui-desktop',
  desktopUiScriptUrl: '/app-ui-desktop/main.js',
  desktopHTML: html`
    <div>
      <fas-desktop-header></fas-desktop-header>
      <fas-desktop-nav></fas-desktop-nav>
      <main>
        <div id="router-outlet"></div>
        <fas-desktop-aside></fas-desktop-aside>
      </main>
      <fas-desktop-footer></fas-desktop-footer>
    </div>
  `,
  mobileUiTagName: 'fas-ui-mobile',
  mobileUiScriptUrl: '/app-ui-mobile/main.js',
  mobileHTML: html`
    <div>
      <fas-mobile-header></fas-mobile-header>
      <fas-mobile-nav></fas-mobile-nav>
      <main id="router-outlet"></main>
      <fas-mobile-footer></fas-mobile-footer>
    </div>
  `
})

html tagged template literal

The html tagged template literal is used to create HTML templates for the desktop and mobile UI. It must be used to create the desktopHTML and mobileHTML options.

import { createLoader, html } from 'https://cdn.skypack.dev/@ficusjs/app-shell-ui-loader'

createLoader({
  desktopHTML: html`
    <div>
      <my-desktop-header></my-desktop-header>
      <my-desktop-aside></my-desktop-aside>
      <main id="router-outlet"></main>
      <my-desktop-footer></my-desktop-footer>
    </div>
  `
})

Options

The createLoader(options) function accepts an optional object containing properties for configuring the loader.

The following options can be provided:

| Option | Type | Default | Description | |----------------------|-----------|-----------------------------------|---------------------------------------------------------------------------------------------------------------------------| | appTagName | string | fas-app | The tag name of the app tag. The app tag is the root tag that uses a media query to load a specific mobile or desktop UI. | | desktopMediaQuery | string | (min-width: 1280px) | The breakpoint at which to switch from mobile to desktop. | | breakpointReactive | boolean | false | Should the breakpoint be reactive on resize? | | desktopUiTagName | string | fas-ui-desktop | The tag name of the desktop UI component. | | desktopUiScriptUrl | string | /app-ui-desktop/main.js | The path to the desktop UI components bundle. | | desktopHTML | string | See desktop HTML | The HTML of the desktop app shell UI. | | mobileUiTagName | string | fas-ui-mobile | The tag name of the mobile UI component. | | mobileUiScriptUrl | string | /app-ui-mobile/main.js | The path to the mobile UI components bundle. | | mobileHTML | string | See mobile HTML | The HTML of the mobile app shell UI. |

Desktop HTML

The desktop HTML is the HTML that is loaded when the desktop UI is loaded. The desktop HTML is loaded when the desktop media query is matched. It is loaded within the desktopUiTagName tag.


The default desktop HTML is:

```html
<div>
  <fas-desktop-header></fas-desktop-header>
  <fas-desktop-nav></fas-desktop-nav>
  <main>
    <div id="router-outlet"></div>
    <fas-desktop-aside></fas-desktop-aside>
  </main>
  <fas-desktop-footer></fas-desktop-footer>
</div>

To provide your own desktop HTML, pass it in as the desktopHTML option using the html tagged template literal:

{
  desktopHTML: html`
    <div>
      <my-desktop-header></my-desktop-header>
      <my-desktop-aside></my-desktop-aside>
      <main id="router-outlet"></main>
      <my-desktop-footer></my-desktop-footer>
    </div>
  `
}

Mobile HTML

The mobile HTML is the HTML that is loaded when the mobile UI is loaded. The mobile HTML is loaded when the desktop media query is not matched. It is loaded within the mobileUiTagName tag.

The default mobile HTML is:

<div>
  <fas-mobile-header></fas-mobile-header>
  <fas-mobile-nav></fas-mobile-nav>
  <main id="router-outlet"></main>
  <fas-mobile-footer></fas-mobile-footer>
</div>

To provide your own mobile HTML, pass it in as the mobileHTML option using the html tagged template literal:

{
  mobileHTML: html`
    <div>
      <my-mobile-header></my-mobile-header>
      <my-mobile-aside></my-mobile-aside>
      <main id="router-outlet"></main>
      <my-mobile-footer></my-mobile-footer>
    </div>
  `
}

Styling

The app shell UI loader does not provide any styling. It is up to you to style the app shell UI. It is recommended to provide the minimal styling required to present the app shell UI to the user. The rest of the styling should be loaded by the UI components.

Production

It is recommended to inline the app shell UI loader in production along with any initial styles. This embeds the initial app shell in the HTML, and removes the need for an additional HTTP requests. It also means the app shell UI is available immediately, and the user does not see a flash of unstyled content.