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

thind-js

v1.4.6

Published

JS framework to develop web apps with Webflow frontend

Downloads

40

Readme

Thind JS

Thind-js is a lightweight JavaScript framework designed for building powerful web applications with Webflow. It provides an intuitive API for data management, rendering, creating sortable tables, form handling, and element manipulation.

Installation

npm install thind-js

Usage

Importing Thind

import Thind, { DataStore, Render, SortableTable } from 'thind-js';

Creating a Thind Instance

Declare the attribute you will use globally in the DOM

const thind = new Thind({ attribute: 'data-my-el' });

Modules and Examples

Element Handling

Thind provides easy access to elements using custom attributes.

// Get a single element
const element = thind.element.get('my-element');
// Get a all elements
const elements = thind.element.getAll('my-elements');

Form Handling

Manage form submissions, validations, and values.

const form = thind.element.get('form');

// Disable the default Webflow submission
thind.form.disable(form); 

//Get value of a specific field by field name
const value = thind.form.value(form, 'username'); 

//Get values of all fields
const values = thind.form.values(form);

//Check if current form is valid, where all required fields are complete
const isValid = thind.form.isValid(form);

//Show Webflow native Form error and pass a custom error message
thind.form.error(form, 'An error occurred');

//Hide the native Webflow form error state
thind.form.errorHide(form);

//Show the Webflow form sucess state
thind.form.success(form, 'showMessage');

//Show the sucess state with custom sucess message
thind.form.success(form, 'showMessage', 'Login Sucessfull');

//Redirect user based on redirect settings of Webflow from
thind.form.success(form, 'redirect');

// Change the text of form button to show the status of form, at end pass true or false to disable or enable the submit buton. True will disable the button.
thind.form.changeSubmitButton(form, 'Submitting...', true);

// Reset the Webflow form. Clear the inputs and hide error & Success state.
thind.form.reset(form);

Page Management

Retrieve page information and URL parameters.

// Get current page name from url
const pageName = thind.page.name();

// Get all page parameters from url
const params = thind.page.parameters();

// Get value of specific page parameter from url
const param = thind.page.parameter('id');

DataStore

Manage your Webflow application state with a reactive data store.

import { DataStore } from 'thind-js';
import { log } from './logs.js';

// Usage example:
const store = new DataStore({ users: [] }, { caching: true });

// Subscribe to changes in users
store.subscribe('users', (newData) => {
  log(JSON.stringify(newData));
});

// Using DataStore's add, update, delete, and get APIs
store.add('users', { name: 'Placeholder' });
store.add('users', { name: 'Dilraj' });
store.add('users', { name: 'Parminder' });
store.add('users', { name: 'Jasbir' });

store.update('users.4', {
  ...store.get('users.4'),
  age: '23',
  test: true,
});

store.update('users.3', {
  ...store.get('users.3'),
  age: '23',
  test: true,
});

store.delete('users.0');

Check the demo here

Data Rendering

Render data to HTML elements.

const dataStore = new DataStore({ users: [] }, { caching: true });

const renderOptions = {
  element: document.getElementById('data-container'),
  data: [{ name: 'Alice' }, { name: 'Bob' }], // Provide data attribute with json data or bind the render instance with a key from Datastore
  dataStore: dataStore,
  key: 'user-data'
  config: {
    props: {
      name: {
        action: (data, element) => {
          element.textContent = data;
        }
      }
    }
  }
};

const render = new Render(renderOptions);


render.update([{ title: '123', complete: false }, { title: 'ABCD', complete: true }]);
render.clear();
render.destroy();

Check the demo here

Sortable Table

Create tables with sortable columns.

const tableConfig = {
  showIndicators: true,
  acsSvg: '<svg>...</svg>',  // Optional SVG code for icon that will be added text to the text of table header on a accessding sort
  descSvg: '<svg>...</svg>',  // Optional SVG code for icon that will be added text to the text of table header on a descending sort
  SvgClass: 'sort-icon' // Optional class to add to the svg icon
};

const sortableTable = new SortableTable('#header-wrapper', '#list-element', 'data-sort', tableConfig);

// Here we are finding headers inside #header-wrapper with attribute data-sort, and then for each found header we find list items that have data-sort="uniqe value"

Check the demo here