Giter Site home page Giter Site logo

cityofnewyork / patterns-scripts Goto Github PK

View Code? Open in Web Editor NEW
0.0 17.0 0.0 103 KB

A set of common utility ES modules to help keep scripting DRY and support accessibility. Maintained by @nycopportunity

Home Page: https://nycopportunity.github.io/patterns-framework/

JavaScript 99.08% SCSS 0.92%
patterns nycopportunity javascript module pttrn

patterns-scripts's Introduction

Patterns Scripts

A set of common utility ES modules to help keep scripting DRY and support accessibility. Used along with @nycopportunity/pttrn-cli projects.

Installation

$ npm install @nycopportunity/pttrn-scripts

Import ES modules from the source.

import '@nycopportunity/pttrn-scripts/src/{{ module }}/{{ module }}'

new {{ Module }}();

In most cases implementation is done by adding a data-js attribute to the appropriate element. Configuration is often handled through other data and aria attributes but advanced customization can also be achieved by setting module properties pre or post instantiation. Where utilities are listening to click events the listeners are added to the body and trigger the script when the click target selector matches the utility settings.

<{{ element }} data-js="{{ script }}"> My script enhanced element </{{ element }}>

Some utilities support scripting only and do not have HTML counterparts. See documentation for more details.

Docs

  • Copy - A wrapper around the Navigator Clipboard API that creates a click to copy to clipboard button
  • Dialog - A utility for creating modal or non-modal dialogs
  • Direction - A utility for setting the reading direction of the document and saves the user preference to local storage
  • Forms - Form validation and other form utilities
  • Google Translate Element - Custom Google Translate Selector
  • Icons - Fetches an svg sprite and adds it to the DOM
  • Localize - Retrieve localized strings from a global constant
  • LZW - Compression algorithm for encoding strings of data
  • Newsletter - Enhances an embedded Mailchimp form with validation
  • Observe - A wrapper around the Intersection Observer API that creates an scroll watch on a scrollable element
  • Spinner - Generic process or loading spinner animation
  • Themes - A CSS theme cycling utility that toggles the document classname and saves the user preference to local storage
  • Toggle - Multi-purpose element visibility toggle
  • Tooltips - An accessible tooltip toggle and positioning
  • Track - Auto click tracking for Google Analytics and Webtrends
  • Web Share - A wrapper around the Navigator Share API that creates a web sharing button
  • Window Vh - Sets the CSS Custom Property --100vh to the viewport's true height as a workaround for iOS 100vh value

patterns-scripts's People

Contributors

devowhippit avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.