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

sham-ui-router

v6.1.0

Published

Router for sham-ui

Downloads

18

Readme

sham-ui-router

Build Status npm version MIT Licence

Router for sham-ui

Install

# npm
npm install sham-ui-router
# yarn
yarn add sham-ui-router

API

Table of Contents

LinkToOptions

Options for LinkTo

Type: Object

Properties

  • path string Name of page for link. Default ''
  • params Object Params of page for link. Default {}
  • text string Text for link. Default ''
  • useActiveClass boolean Use activeClass options for active page link. Default false
  • activeClass string Class name for active link. Default 'active'

LinkTo

Component for link to page

Properties

ActivePageContainer

Component-container for page

Examples

{% import ActivePageContainer from 'sham-ui-router/active-page-container' %}
...
<ActivePageContainer/>
...

ParamsBuilder

Helper for build params for href-to directive

Type: Object

Examples

{% import path from 'sham-ui-router/params' %}
...
<a :hrefto={{path("foo").param("id", 2)}} class="custom-class-1 custom-class-2">
 Foo
</a>
...

param

Add param for page

Parameters
  • name string Param name
  • value any Param value

Returns ParamsBuilder

_params

Set params

Parameters

Returns ParamsBuilder

_useActiveClass

Use active class

Returns ParamsBuilder

_activeClass

Set active class

Parameters

Returns ParamsBuilder

path

Create new ParamsBuilder

Parameters

  • path string Name of destination page

Returns ParamsBuilder

HrefTo

Directive for links

Parameters

  • component

Examples

...
  <a :hrefto={{ {"path": "foo",  "params": params} }} class="custom-class-1 custom-class-2">
    Foo
  </a>
....

lazyPage

Hook for process lazy page after loader finish. Can override with DI.bind( 'router:lazy-page' )

Parameters

  • pageComponent Class<Component>

Returns Class<Component>

Router

Router service

Parameters

  • DI Object App DI container
  • root (string | null) Root URL (optional, default null)
  • useHash boolean Use hash symbol as delimiter (optional, default false)
  • hash string Hash symbol (use useHash=true) (optional, default '#')

Examples

import FooPage from '../components/FooPage.sht';
import BarPage from '../components/BarPage.sht';
import Router from 'sham-ui-router';

const router = new Router();
router
    .bindPage(
        '/foo', // URL
        'foo', // Name
        FooPage, // Component class
        { componentOption: 1 } // Component options
    )
    .bindLazyPage( '/bar/:some_param/detail', 'bar', () => import( '../src/components/BarPage' ), {} )
    .resolve();

bindPage

Bind page component & url

Parameters
  • url string Url for page
  • name string Page name*
  • pageComponent Class<Component> Component for page
  • componentOptions Object Options for component

Returns Router

bindLazyPage

Bind lazy loaded page component & url

Parameters
  • url string Url for page
  • name string Page name
  • loader Function Loader for page component
  • componentOptions Object Options for component

Returns Router

navigateToRoute

Go to route by name

Parameters

resolve

Resolve current url & run router

notFound

Not found handler

navigate

Changing the page

Parameters

hooks

Hooks

Parameters
  • hooks Object Object with hooks

generate

Generate url for page

Parameters
Examples
router
    .bindPage( '/trip/:tripId/edit', 'trip.edit', PageComponent, {} )
    .bindPage( '/trip/save', 'trip.save', PageComponent, {} )
    .bindPage( '/trip/:action/:tripId', 'trip.action', PageComponent, {} );
console.log(router.generate('trip.edit', { tripId: 42 })); // --> /trip/42/edit
console.log(router.generate('trip.action', { tripId: 42, action: 'save' })); // --> /trip/save/42
console.log(router.generate('trip.save')); // --> /trip/save

routerStorage

Type: RouterStorage

RouterStorage

Data storage for router service

Type: Object

Properties

  • url string Current page url
  • name string Current page name
  • params Object Current page params
  • query string Current page query
  • activePageComponent Class<Component> Current page component class
  • activePageOptions Object Options for current page component
  • pageLoaded boolean Current page component loaded (@see Router.bindLazyPage)