# shaco-router

> Component to deal with history changes with shaco

Latest version **0.0.2** (published 2016-03-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install shaco-router
pnpm add shaco-router
yarn add shaco-router
bun add shaco-router
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2016-03-18 |
| First published | 2016-03-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Sergio Marin |
| Maintainers | highercomve |
| Keywords | shadow, dom, dom, component, shaco |

## Links

- npm: https://www.npmjs.com/package/shaco-router
- Repository: https://github.com/highercomve/shaco-router
- Homepage: https://github.com/highercomve/shaco-router#readme
- Issues: https://github.com/highercomve/shaco-router/issues
- npm.io page: https://npm.io/package/shaco-router

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.0.2 (latest) — 2016-03-18
- 0.0.1 — 2016-03-18

## README

# shaco-router

This is a component for [Shaco](http://github.com/highercomve/shadowDOMcomponent) that allow use the window.history to change the URL on the browser and render diferents components depending of the URL


## Example

```
const TodoContainer = Shaco.ComponentFactory({
  elementName: 'todo-container',
  template: `<content></content>`,
  view: function () {
    /*
     * RouteManager: will allow render one component depending the URL in the browser.
     *
     * the routeIs function receive to params:
     * Fist the pattern to match the URL, Example:
     *    This could be something like:
     *    "/" -> the index
     *    "/tasks"
     *    "/tasks/:id"
     *    ".*" -> the rest
     * The second parameter is and array that will be past to Shaco.createElement. You don't add the state here
     * The State will be passed to all the components inside the router-manager
     * You can use router-manager using JSX like before or using javascript functions, like this:
     *
     */
     
    // With Javascript functions (normal Shaco components)
    // Shaco.createElement('route-manager', null, this.state, {}, () => {
    //   Shaco.createElement('route-selector', null, { pattern: '/', params: ['todo-app', null]} )
    //   Shaco.createElement('route-selector', null, { pattern: '.*', params: ['div', null, {}, "Not found"]} )
    // })

    // With JSX
    return (
      <route-manager state={this.state}>
        <route-selector state={{ pattern: '/', params: ['todo-app', null] }}></route-selector>
        <route-selector state={{ pattern: '.*', params: ['div', null, {}, "Not found"]}}></route-selector>
      </route-manager>
    )
  }
})
```

---
_Source: https://npm.io/package/shaco-router · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
