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

@solidx/moko

v2.0.6

Published

Moko is a lightweight WebComponents based navigation library highly inspired by [React Navigation](https://reactnavigation.org).

Downloads

8

Readme

Moko

Moko is a lightweight WebComponents based navigation library highly inspired by React Navigation.

It supports three kinds of navigators:

  • switch navigator
  • stack navigator
  • tab navigator

Switch navigator

Switch navigator only show one content at a time, each route displaying a different content. Content is not cached

Code example:

<moko-switch-navigator>
  <moko-route path="view1/:name" component="demo-view1">
    <span>diego</span>
  </moko-route>
  <moko-route path="view2/:name" component="demo-view2"></moko-route>
  <moko-route path="view3/:name" component="demo-view3"></moko-route>
</moko-switch-navigator>

A navigator contains one or multiple <moko-route>. A route has two mandatory attributes path and component.

  • path associates the route to an url fragment. Each time an url match that path, the component associated with that route will be displayed. The path can contain placeholders
  • component name of the Web Component to be displayed for a matching route.

Navigation is triggered either with standard <a href="#some-route">Click</a> or with safer moko provided custom element <moko-link to="some-route""></moko-link>. moko-link supports navigator nesting and only relative (to the closest parent navigator) path must be provided.

If the url fragment is empty, the component associated with the first route will be rendered.

It's possible to define a default route to render with the default-path attribute.

By default a navigator will take all the space available in his node ancestor.

Server side rendering

First moko-route element can contain markup that will be displayed before corresponding web component is rendered properly. It allows to server side render content and make the page SSO friendly.

Demo

See switchNavigator.html for a complete example.

Stack navigator

Stack navigator will display new content on top of previous one while navigating.

Code example:

<moko-stack-navigator>
  <moko-route path="path1" component="demo-el1"></moko-route>
  <moko-route path="path2" component="demo-el2"></moko-route>
  <moko-route path="path3" component="demo-el3"></moko-route>
</moko-stack-navigator>

Demo

See stackNavigator.html for a complete example.

Server side rendering

First moko-route element can contain markup that will be displayed before corresponding web component is rendered properly. It allows to server side render content and make the page SSO friendly.

Tab navigator

Tab navigator will display a tabbar at the bottom of the screen. Each click on a tab entry will display different content.

Code example:

<moko-tab-navigator active-color="red">
  <moko-tab-route
    icon="trending-up"
    title="Home"
    path="home1"
    component="demo-home"
  >
  </moko-tab-route>
  <moko-tab-route
    icon="package"
    title="Home2"
    path="home2"
    component="demo-home2"
  >
  </moko-tab-route>
  <moko-tab-route
    icon="trending-down"
    title="Home3"
    path="home3"
    component="demo-home3"
  >
  </moko-tab-route>
  <div style="height: 200%; background: yellow">Home1</div>
</moko-tab-navigator>

Demo

See tabNavigator.html for a complete example.

Server side rendering

moko-tab-navigator element can contain markup as last child that will be displayed before corresponding web component is rendered properly. It allows to server side render content and make the page SSO friendly.

Using navigators in your webpage

Each navigator is available as Web Components through ES6 modules (see the dist folder).

Live Demos