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

mosaic-framework

v0.9.1

Published

A front-end JavaScript library for creating user interfaces

Downloads

27

Readme

Mosaic

Mosaic is a declarative front-end JavaScript library for building user interfaces!

💠 (Web) Component-Based: Mosaic uses the Custom Elements API to create web components that can keep track of their own data, actions, and more, and can be included in other components to create front-end web applications.

⚡️ Observable Data: Mosaic uses Observables to keep track of changes to a component's data. This means that there is no need to call "setState" or anything like that to update a component - instead just change the data directly.

🧠 Smart DOM: Updates in Mosaic work by remembering which nodes are dynamic (i.e. subject to change) and traveling directly to those nodes to make changes, rather than traversing the tree again.

🔀 Built-in Router: Comes with a basic, client-side router which allows Mosaic components to be used as separate pages.

🌐 State Manager: Comes with a built-in global state manager called Portfolio.

👌 Lightweight: The minified Mosaic library comes in at a size of 28KB.

🔖 Tagged Template Literals: Views are written using tagged template literals, which means there is no need for a compiler:

const name = "Mosaic";
html`<h1>Welcome to ${name}!</h1>`

Demo

Here is an example of a simple Mosaic application. All you need is an index.html file and an index.js file. For a more detailed example, run the project inside the "example" folder.

index.html:

<html>
  <head>
    <title>My Mosaic App</title>
  </head>
    
  <div id='root'></div>

  <script src='https://unpkg.com/mosaic-framework@latest/dist/index.js'></script>
  <script type="text/javascript" src='./index.js'></script>
</html>

index.js:

// Import Mosaic
import Mosaic, { html } from 'mosaic-framework';

// Create components
Mosaic({
    name: 'my-label',
    data: {
        text: ''
    },
    view: self => {
        return html`
            <h2>${ self.data.text }</h2>
            <p>This is a custom label component!</p>
            ${self.descendants}
        `;
    }
});
const app = Mosaic({
    name: 'my-app',
    element: 'root',
    data: {
        title: "Mosaic App"
    },
    sayHello: function() {
        console.log("Hello World!!");
        console.log("This component is ", this);
    },
    view: function() {
        return html`
            <h1>This is a ${this.data.title}!</h1>
            <p>Click below to print a message!</p>
            <button onclick="${this.sayHello}">Click Me!</button>

            <my-label text='Welcome to Mosaic!'>
                Awesome, right?
            </my-label>
        `;
    }
});

// Paint the Mosaic onto the page.
app.paint();

Installation

The easiest way to use Mosaic is to first install the npm package by using:

npm install --save mosaic-framework
yarn add mosaic-framework --save

or with a script tag.

<script src='https://unpkg.com/mosaic-framework@latest/dist/index.js'></script>

(Optional) For fast builds and hot reloading, install the build tool "Parcel." This is not required, though, as Mosaic uses built-in JavaScript features. This means that no build tool is required, but any may be used if it helps the overall project structure.

npm install --save-dev parcel-bundler

Now you are ready to use Mosaic!

Author

  • Year: 2019
  • Programmer: Adeola Uthman
  • Languages/Tools: JavaScript, TypeScript, Parcel