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

@tnke/wp-block-toolkit

v2.1.1

Published

Toolkit for developing WordPress Gutenberg blocks.

Downloads

4

Readme

WP Block Toolkit

A simple collection of useful tools for WordPress Gutenberg block building.

Styles

To include the editor styles, currently you need to add this to the top of your Gutenberg block's _editor.scss:

@import "~@tnke/wp-block-toolkit/build/index.css";

In the future, we'll figure out a better way to manage CSS in the toolkit.

Components

InlineNotice

Compliments the base WordPress notice system by allowing you to show either warning or error level notices inside the editor.

InlineNotice example

<InlineNotice level="error">
	<strong>Error: </strong> Lorem ipsum dolor sit amet.
</InlineNotice>

PostControl

Custom ComboboxControl for selecting a single post. Takes an array of post objects and returns and id number on change.

PostControl example

<PostControl
	label={"My Label"}
	value={mySelectedPostId}
	posts={myPosts}
	onChange={(value) =>
		setAttributes({
			mySelectedPostId: value,
		})
	}
/>

RequireBlocks

Allows you to only show components if certain blocks are installed and activated in the system. If some of the blocks are missing, displays an error instead using an InlineNotice.

RequireBlocks example

<RequireBlocks blocks={["core/paragraph", "my-namespace/my-custom-block"]}>
	<h2>My title</h2>
	<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>
	<MyComponent />
</RequireBlocks>

SortablePostsControl

Select and sort multiple posts, with search filtering. Takes an array of post objects and returns an array of id numbers on change.

SortablePostsControl example

<SortablePostsControl
	label={"My Label"}
	posts={myPosts}
	value={mySelectedPosts}
	onChange={(value) =>
		setAttributes({
			mySelectedPosts: value,
		})
	}
/>

TaxonomyControl

Similar to the default WordPress category selector, shows a filterable list of checkboxes.

TaxonomyControl example

<TaxonomyControl
	label={"My Label"}
	value={mySelectedTaxonomies}
	taxonomies={myTaxonomies}
	onChange={(value) => setAttributes({ mySelectedTaxonomies: value })}
/>

Hooks

useAllPosts

QoL wrapper for getting all posts of a certain post type, ordered alphabetically by title.

const stories = useAllPosts("story");
const contacts = useAllPosts("contact");

useRequiredBlocks

Checks if the listed block names are installed and activated on the site. Also returns the list of missing block names if you wish to list them in an error message for example.

const { missingBlocks, hasRequiredBlocks } = useRequiredBlocks([
	"core/paragraph",
	"core/image",
]);

Changelog

2.1.1

  • Clarified some stuff in readme

2.1.0

  • Removed key option from PostControl and assume a single number value instead (post id)
  • Added SortablePostsControl component, which let's you select and sort multiple posts
  • Moved TaxonomyControl's styles from inline to editor.scss

2.0.2

  • Added "prepare" script
  • Refactored PostControl: core ComboboxControl now has query filtering built-in, no need to manually do it like in the official docs.

2.0.1

  • Optimized readme assets

2.0.0

  • Changed the name of PostSelectControl component and the postValue prop (breaking changes)
  • Added descriptions of the different tools to the readme

1.0.8

  • Style tweaks for TaxonomyControl
  • Added a config.json file

1.0.7

  • Added preliminary typescript typings

1.0.0 - 1.0.6

  • Initial release