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

solid-router-stack

v0.1.30

Published

[查看中文文档](./README-CN.md)

Downloads

32

Readme

🏂🏽 solid-router-stack

查看中文文档

A solid router, mobile first.

View DEMO

Features:

  • Like navigation, page is keep in dom
  • Auto lazy load pages
  • Easy preload some pages when entry a page
  • Auto use URL params input page's props
  • Tiny, only 3kb in gzip

Example

Create routers

import { render } from "solid-js/web";
import { createRouters, stackOptions } from "solid-router-stack";
import Welcome from "./welcome";

export const routers = createRouters({
  Welcome: {
    render: Welcome,
    // not use lazy import
    sync: true,
  },
  Login: {
    render: () => import("./sign/Login"),
    // preload other pages
    preload: ["User"],
  },
  User: {
    render: () => import("./user"),
  },
});

// Set page background:
stackOptions.className = "bg-gray-800";

render(
  () => <routers.Routers root={routers.Welcome} hash />,
  document.getElementById("root");
);

Use Navigaion

import { routers } from "./routers";

function Welcome() {
  const handlePushProduct = () => {
    routers.user.push();
  };
  const handleReleaseProduct = () => {
    routers.user.replace({ id: "123" });
  };
  const handleClearToProduct = () => {
    routers.user.clearTo();
  };
  const handleGoBack = () => {
    routers.goBack();
  };
  return (
    <div>
      <div onclick={handlePushProduct}>push product</div>
      <div onclick={handleReleaseProduct}>release product</div>
      <div onclick={handleClearToProduct}>clear all stack and push product</div>
      <div onclick={handleGoBack}>go back</div>
    </div>
  );
}

export default Welcome;

Use params

When sub page back, you can do something:

import { createPropsSignal } from "solid-router-stack";

// params.dog in props
function App(props: { dog: string; age: number }) {
  const [dog, setDog] = createPropsSignal(props, "dog");
  return (
    <div>
      <input oninput={(e) => setDog(e.currentTarget.value)} />
      <div>change and load: {dog()}</div>
      <div>only load: {p.age}</div>
    </div>
  );
}

Not keep page

props.stackShow is when stack page is stack top, you can use <Show when={props.stackShow} /> change Not keep page:

const Page: Component = (props) => {
  return (
    <Show when={props.stackShow}>
      <div>the page</div>
    </Show>
  );
};

Like desktop router push

routers.xxxx.put is push a new page or move old page to top

routers.user.put(); // push a new page or move old page to top
routers.user.put({}, true); // ignore animation

Animation navigation, like application

import { setNavigationAnimation } from "solid-router-stack";

// like application
setNavigationAnimation("moveTop");

ignoreAnimation in once:

// routers.xxx.push(params?:Record<string, unknown>, ignoreAnimation?:boolean)
routers.user.push({}, true);

// routers.goBack(params?:Record<string, unknown>, ignoreAnimation?:boolean)
routers.goBack({}, true);

Events listen

When use history change:

import { historyProxy } from "solid-router-stack";

historyProxy.beforeChange((url, path) => {
  if (path === "/user") {
    return "/login";
  }
  return url;
});

Use virtual history

Use virtual history in iOS Wechat application, history stack only one.

export function isIOSWechat(): boolean {
  const ua = navigator.userAgent.toLocaleLowerCase();
  return  new RegExp("(iphone|ipod|ipad)").test(ua) && new RegExp("(micromessenger)").test(ua);
}

render(
  () => <routers.Routers root={routers.Welcome} hash virtualHistory={isIOSWechat()} />,
  document.getElementById("root");
);