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

tijak

v1.0.2

Published

Library for Vite.js with vanilla template for create multi-pages SPA

Downloads

1

Readme

TIJAK

fr krl

TIJAK.js is a library aimed at making multi-page sites in vanilla javascript under Vite.js. The lib uses hash navigation (#) to take advantage of the benefits of a SPA. Its goal is to take advantage of a development environment similar to a framework but with native components without virtual DOM.

Installation

In your Vite.js project template vanilla , install the library:

npm install TIJAK

how it works

TIJAK.js is designed to distribute the components of the "pages" folder as a site page. It is on these that you will mount your custom components or classic HTML tags.
ex:

import * as txt from '../strings/seconPageTxt'
export default class SecondPage extends HTMLElement {
  constructor() {
    // Always call super first in constructor
    super();
    build.mountingPageElements(
      this,
      `<my-header h1title="Second Page"></my-header>
        <main>
          <section>
            <h2>This is the second page</h2>
            <p>${txt.description}.</p>
          </section>
        </main>
        `);
    }

    connectedCallback() {}
    disconnectedCallback() {}
    adoptedCallback() {}
    attributeChangedCallback(name, oldValue, newValue) {}
    
  }
  customElements.define('second-page', SecondPage);

Setting

The routing of the different pages being managed by the lib in its navigator() function, it must be provided with a navigator-mapping.js file at the root of the project. In this one you will import the PAGE components only) under their customElement notations ( ) and you will fill in the uris:


export const mapping = [
  { 
    uri: '', 
    page: '<index-page></index-page>' 
  },
  { 
    uri: '#/', 
    page: '<index-page></index-page>' 
  },
  { 
    uri: '#/second-page', 
    page: '<second-page></second-page>' 
  }
];

Structure

To allow navigation by "page", it is necessary to separate the components folder and the pages folder. The ideal structure is this:

project-folder   
    public
        main.js
    src   
        components
        pages  
        strings
        sass
    navigatore-mapping.js
    vite.config.js

Strings

In order to facilitate the readability of the code, TIJAK.js proposes to separate the text of each page in a STRINGS folder with a naming convention of the type: pageNameTxt.

css

Sass

We recommend using Sass and taking full advantage of custom component name targeting and nesting to style components.

components
  MyListComponent
    my-list-component.js
    my-list-component.scss

And Rollup will create one style tag per component. Ideally page styling would be handled in main.scss. If one or more pages have their own styles, then create a style tag in the page components and manage it in css.
To have your Sass variables globally you can import them into the vite.config.js:

import { defineConfig } from 'vite'

export default defineConfig({
  server: {
    open: 'index.html'
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `
          @import "/src/sass/_variables.scss";
          @import "/src/sass/_mixins.scss";`
      }
    }
  },
  
})