Home
Softono
z

zachleat

Professional software vendor delivering innovative solutions on the Softono platform. Specialized in both open-source and proprietary software development.

Total Products
4

Software by zachleat

table-saw
Open Source

table-saw

# `table-saw` A small structural-only zero-dependency Web Component for responsive `<table>` elements. Heavily inspired by [Filament Group’s Tablesaw Stack jQuery plugin](https://github.com/filamentgroup/tablesaw). ## [Demo](https://zachleat.github.io/table-saw/demo.html) ## Examples ```html <!-- Note: requires `type="module"` --> <script type="module" src="table-saw.js"></script> <!-- stacks below 640px viewport --> <table-saw> <table><!-- some HTML omitted for brevity --></table> </table-saw> <!-- stacks below 400px viewport --> <table-saw breakpoint="(max-width: 24.9375em)"> <table><!-- … --></table> </table-saw> <!-- stack columns are 50% and 50% width --> <table-saw ratio="1/1"> <table><!-- … --></table> </table-saw> <!-- Remove left/right padding on table cells when stacked --> <table-saw zero-padding> <table><!-- … --></table> </table-saw> <!-- Force left-aligned text when stacked --> <table-saw text-align> <table><!-- … --></table> </table-saw> <!-- Use your own text-align value when stacked --> <table-saw text-align="right"> <table><!-- … --></table> </table-saw> ``` * Use `breakpoint` attribute to set the breakpoint (default:`(max-width: 39.9375em)`). * Use `type="container"` attribute to use container queries instead of viewport-based media queries (default: `type="media"`). * Use `ratio` attribute to override the small viewport column ratio (default: `1/2`). * Use `zero-padding` attribute to remove small viewport padding on table cells. * Use `text-align` attribute to force column text alignment at small viewport. ## Installation You have a few options (choose one of these): 1. Install via [npm](https://www.npmjs.com/package/@zachleat/table-saw): `npm install @zachleat/table-saw` 1. [Download the source manually from GitHub](https://github.com/zachleat/table-saw/tags) into your project. 1. Skip this step and use the script directly via a 3rd party CDN (not recommended for production use) ### Usage Make sure you include the `<script>` in your project (choose one of these): ```html <!-- Host yourself --> <script type="module" src="table-saw.js"></script> ``` ```html <!-- 3rd party CDN, not recommended for production use --> <script type="module" src="https://www.unpkg.com/@zachleat/[email protected]/table-saw.js"></script> ``` ```html <!-- 3rd party CDN, not recommended for production use --> <script type="module" src="https://esm.sh/@zachleat/[email protected]"></script> ``` ## Features * Supports one or many `<table>` child elements. * Works with viewport media queries or container queries. * Uses CSS grid for small viewport alignment. * Falls back to regular table before or without JavaScript. * Cuts the mustard on [`CSSStyleSheet.prototype.replaceSync`](https://caniuse.com/mdn-api_cssstylesheet_replacesync)

Web Components & Widgets
336 Github Stars
browser-window
Open Source

browser-window

# `browser-window` A small themed zero-dependency Web Component for demos with a fake browser window (Safari-esque). * [**Go to the Demo**](https://zachleat.github.io/browser-window/demo.html) * [Read the blog post](https://www.zachleat.com/web/browser-window/) > “this is maybe my favoritest [web component] yet.”—[Dave Rupert, President of Web Components](https://mastodon.social/@davatron5000/111301972550207963) ## Installation Via [`npm`](https://www.npmjs.com/package/@zachleat/browser-window) or download [`browser-window.js`](./browser-window.js) directly for use in your project. ```sh npm install @zachleat/browser-window ``` ## Changelog - `v2.0.0` URL bar now shows the full url by default (including pathname, searchParams, et al). Use `url-mode="hostname-only"` to swap back to previous behavior.

Web Components & Widgets
278 Github Stars
filter-container
Open Source

filter-container

# Filter Container A themeless zero-dependency web component to filter visible child elements based on form field values. * [Demo](https://zachleat.github.io/filter-container/demo.html) * [Demo on jamstack.org](https://jamstack.org/generators/) (Filter by Language, Template, or License) * [Demo on zachleat.com](https://www.zachleat.com/web/) (Filter by blog post category) ## Installation ``` npm install @zachleat/filter-container ``` Please see the demo for sample code. Use: * `<filter-container>` * `<select data-filter-key="KEY_NAME">` for the form element and `<option value="CATEGORY_VALUE">` for categories. * (New in v3) `<input value="CATEGORY_VALUE" data-filter-key="KEY_NAME">` (try text, radio, checkbox, etc) * Add a `data-filter-KEY_NAME="CATEGORY_VALUE"` attribute to _any_ child element of `<filter-container>` to assign both a filter key and category to match on. ### Optional Features * You can add the CSS for each `KEY_NAME` yourself if you’re server rendering (or not happy with the [browser support of `replaceSync`](https://caniuse.com/mdn-api_cssstylesheet_replacesync)). Prepopulate the server-rendered content on each individual item using this too if you’d like (maybe your page has a server-rendered filter applied). ```css .filter-KEY_NAME--hide { display: none; } ``` * This component will not filter on initialization unless you use `<filter-container oninit>`. By default the form field needs to change for filtering to take place. * Add the `data-filter-results` attribute to any child element of the component if you’d like us to populate it with the number of results. * Add a string to this attribute value to customize your Results labels (delimited by `/`). e.g. `data-filter-results="Country/Countries"` * Add `aria-live="polite"` to this element and screen readers will announce when the text changes. * Use `<filter-container delimiter=",">` if your content elements may have more than one filter value assigned (in this example delimited by a comma). * For example, Egypt is in both Africa and Asia: `<li data-filter-continent="africa,asia">Egypt</li>` ## Changelog ### v4.0.0 - `filter-KEY_NAME--hide` CSS is now added automatically via the component—works alongside manually added CSS for proper progressive enhancement. ### v3.0.4 - Add support for `filter-mode="all"` on `<filter-container>` to enable AND-ing filters for all multi-select form elements (checkboxes). Use `filter-mode-KEY_NAME="any"` to override back to the default. ### v3.0.3 - Add support for AND-ing filters across multiple checkboxes. Previously only OR operations were supported. - Use `filter-mode-KEY_NAME="all"` on `<filter-container>` to enable. ### v3.0.0 - Added support for radio and checkbox inputs for filtering. - Renamed attributes: - `data-oninit` renamed to `oninit` - `data-filter-delimiter` renamed to `delimiter` (only supported on `<filter-container>`) - `data-filter-skip-url` renamed to `leave-url-alone` (only supported on `<filter-container>`) ## Credits * [MIT](./LICENSE)

JavaScript Libraries & Components Web Components & Widgets
92 Github Stars
announcement-banner
Open Source

announcement-banner

# announcement-banner A reusable announcement bar banner component. If you don’t need a _Hide_ or _Close_ button on the banner (and to save the user preference), you don’t need this (just use CSS)! * [Demo](https://zachleat.github.io/announcement-banner/demo.html) * Read more at [_Ruthlessly Eliminating Layout Shift on Netlify.com_](https://www.zachleat.com/web/layout-shift/) Features: * Hyperlink to a thing. * Limited visual style (bring your own theme) * JavaScript not required. * Close preference saved to local storage for future page loads * Frameworkless: Web component * No CLS (cumulative layout shift): * Even when opted in to closed by default * Even when JavaScript fails * Even when JavaScript succeeds but runs after render * Use the `key` attribute (v1.0.5+) (or backwards compatible with `data-banner-key` 1.0.3+) to set your own storage key for comparison (defaults to the first link URL). ## Installation 1. Install from [npm](https://www.npmjs.com/package/@zachleat/announcement-banner): `npm install @zachleat/announcement-banner --save` 2. Inline helper script into your `<head>` ```js // Inline this into your <head> // The current banner CTA URL let latestBannerUrl = "YOUR_URL"; let savedKey = localStorage.getItem("banner--cta-url"); // Hide if the banner URL is the same as the saved preference banner URL if(savedKey === latestBannerUrl) { document.documentElement.classList.add("banner--hide"); } ``` 3. Add `banner.css` and `banner.js` to your build CSS and JS. 4. Add the markup: ```html <announcement-banner> <a href="YOUR_URL">YOUR_TEXT</a> <button type="button" data-banner-close>Close</button> </announcement-banner> ``` ## Changelog * `v1.0.6` npm package name changed from `herald-of-the-dog` to `@zachleat/announcement-banner`

Web Components & Widgets
50 Github Stars