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

wex-js

v1.0.32

Published

Introdution to web components with JS and HTML

Downloads

1,633

Readme

Wex.JS

Wex.JS is a JavaScript library for building user interfaces using web components with JS and HTML.

Installation

npm i -g wex-js-cli

Creating a project

npx wex-js-cli <project-name>

Library Structure

The library is organized into two main sections: Pages and Components.

Pages

  • src/pages/your-page/your-page.mjs - JavaScript module for your page logic.
  • src/pages/your-page/your-page.html - HTML template for your page.
  • src/pages/your-page/your-page.css - CSS styles for your page.

Components

  • src/components/your-component/your-component.mjs - JavaScript module for your component logic.
  • src/components/your-component/your-component.html - HTML template for your component.
  • src/components/your-component/your-component.css - CSS styles for your component.

How to Define a Component

To define your component, you must import it in the src/module/define-module.mjs file.

Example

Define your component in its own module file (e.g., src/pages/home-app/home-app.mjs):

import { HomeApp } from "../pages/home-app/home-app.mjs";

const elements = [
  {
    tag: "home-app",
    element: HomeApp
  },
];

export { elements };

Run the Application

npm run start

Getting Started

Example HTML

<!DOCTYPE html>
<html>
  <head>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="/public/style.css">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Application</title>
  </head>

  <body>
    <wex-route path="/" title="Home" component="home-app"></wex-route>

    <div id="root"></div>

    <script type="module" src="../src/index.mjs"></script>
  </body>
</html>

Example Component

import { Component } from './component.js';

class HomeApp extends Component {
  constructor() {
    super('home-app', [], true);
  }

  connectedCallback() {
    this.innerHTML = '<h1>Welcome to the Home Page</h1>';
  }
}

customElements.define('home-app', HomeApp);

Main Script

// src/index.mjs
import { DefineElementsConfig } from "../lib/src/configurations/define-elements-config.mjs";
import { PageConstants } from "../lib/src/constants/page-constants.mjs";
import { elements } from "./module/define-module.mjs";

class Application {
  static start() {
    this.configure();
    this.define();
  }

  static configure() {
    PageConstants.pagesPath = "/src/pages/";
    PageConstants.componentsPath = "/src/components/";
  }

  static define() {
    DefineElementsConfig.defines(elements);
  }
}

Application.start();
// src/module/define-module.mjs
import { DefineElementsConfig } from "../lib/src/configurations/define-elements-config.mjs";
import { PageConstants } from "../lib/src/constants/page-constants.mjs";
import { elements } from "./module/define-module.mjs";

class Application {
  static start() {
    this.configure();
    this.define();
  }

  static configure() {
    PageConstants.pagesPath = "/src/pages/";
    PageConstants.componentsPath = "/src/components/";
  }

  static define() {
    DefineElementsConfig.defines(elements);
  }
}

Application.start();

Contributing

Thank you for considering contributing to Wex.JS! Please follow the guidelines below. How to Contribute

  1. Fork the repository.
  2. Create a new branch.
  3. Make your changes.
  4. Submit a pull request.

License

This project is licensed under the ISC License - see the LICENSE file for details.