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

@sharks-interactive/simple-components

v1.2.3

Published

A vanilla js library for easy replication of html components.

Downloads

5

Readme

npm version npm downloads

Simple Components

Simple Components is a lightweight vanilla javascript component framework.

Functionality

  • Easily replicate individual html components with custom data
  • Easy bulk rendering of components
  • Supports custom props for all your components
  • Supports conditional rendering, for hiding portions of a component based on conditions
  • Supports inline script tags and modules

Usage:

https://www.jsdelivr.com/package/npm/@sharks-interactive/simple-components

Quick Examples:

Rendering individual comps (w/ props & promise)

import { SimpleComps } from 'https://www.jsdelivr.com/package/npm/@sharks-interactive/simple-components';
const sc = new SimpleComps('relative/path/to/components/');

window.onload = sc.render('welcome-msg').then(() => {
	// Called when the comp finishes rendering in case you need to access it
	console.log('Done rendering');
});

/// In another file at
// /relative/path/to/components/welcome-msg.html:
<div style="background-color: {color};"></div>

// In index.html or whatever else file is using this component:
<welcome-msg color="red"></welcome-msg>

Rendering Multiple

// By default calling sc.render('comp-name') renders every element of that type in the DOM, but Simple-Components has a utility function for creating multiple in the DOM for rendering
import {SimpleComps} from 'https://www.jsdelivr.com/package/npm/@sharks-interactive/simple-components';
const sc = new SimpleComps('relative/path/to/components/');

// Create a new object containing a list of objects contaning a list of attributes each component should use
// Populate this via code for search results, tweets or whatever else you need
let dataObj = {
  l: [
    {attrs: ['propName|propValue', 'resultName|https://dogs.com']}, // Javascript object for each comp's attrs
    {attrs: ['propName|propValue', 'resultName|https://cats.com']},
  ],
};

sc.create(
  'result-card',
  2 /* Num of comps to create */,
  myContainer /* Parent obj */,
  dataObj /* Comp data */,
);
sc.render('result-card'); // Renders all the comps we just created in the DOM

///
/// In the result-card.html comp file:
///
<div class="search-result">
  <h1>{resultName}</h1>
</div>;

Features:

  • .create() creates multiple comps with specified props in the DOM
  • .render() renders all of a specific comp
  • <script>, <style> inline script and style tags supported
  • if="false" conditional rendering of elements
  • {propName} supports all kinds of custom props, even in your <script>
  • Promise-based supports a promise for running code when a comp is finished rendering
  • Custom HTML elements supports the (appearance) of custom HTML elements
  • <script type="module"> supports javascript modules

Options (Required)

| Option | Type | Description | | ------ | ------ | ----------------------------------------------------------------------------------- | | folder | string | A string containing the path to your components, relative to the script calling it. |

How it works:

This component library is a easy way to render html files. In the background it loads your component files over https, parses props, ifs, and <script> tags, and then inserts them into the HTML DOM.

Read the wiki for extra documentation.

Project created and maintained by Sharks Interactive.

Developing:

  • Commit to staging and pr to prod for changes

Code Style:

  • Continious Integration will handle formatting for you
  • Use ESLINT locally to catch errors pre-pr

Acknowledgements:

README.MD styling, practices etc, modelled after and taken from the excellent Toucan-JS