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

@gechiui/interface

v4.1.18

Published

Interface module for GeChiUI. The package contains shared functionality across the modern JavaScript-based GeChiUI screens.

Downloads

7

Readme

(Experimental) Interface

The Interface Package contains the basis to start a new GeChiUI screen as Edit Post or Edit Site. The package offers a data store and a set of components. The store is useful to contain common data required by a screen (e.g., active areas). The information is persisted across screen reloads. The components allow one to implement functionality like a sidebar or menu items. Third-party plugins can extend them by default.

Installation

Install the module

npm install @gechiui/interface --save

This package assumes that your code will run in an ES2015+ environment. If you're using an environment that has limited or no support for such language features and APIs, you should include the polyfill shipped in @gechiui/babel-preset-default in your code.

API Usage

Complementary Areas

This component was named after a complementary landmark – a supporting section of the document, designed to be complementary to the main content at a similar level in the DOM hierarchy, but remains meaningful when separated from the main content.

ComplementaryArea and ComplementaryArea.Slot form a slot fill pair to render complementary areas. Multiple ComplementaryArea components representing different complementary areas may be rendered at the same time, but only one appears on the slot depending on which complementary area is enabled.

It is possible to control which complementary is enabled by using the store:

Below are some examples of how to control the active complementary area using the store:

gc.data
	.select( 'core/interface' )
	.getActiveComplementaryArea( 'core/edit-post' );
// -> "edit-post/document"

gc.data
	.dispatch( 'core/interface' )
	.enableComplementaryArea( 'core/edit-post', 'edit-post/block' );

gc.data
	.select( 'core/interface' )
	.getActiveComplementaryArea( 'core/edit-post' );
// -> "edit-post/block"

gc.data
	.dispatch( 'core/interface' )
	.disableComplementaryArea( 'core/edit-post' );

gc.data
	.select( 'core/interface' )
	.getActiveComplementaryArea( 'core/edit-post' );
// -> null

Pinned Items

PinnedItems and PinnedItems.Slot form a slot fill pair to render pinned items (or areas) that act as a list of favorites similar to browser extensions listed in the Chrome Menu.

Example usage: ComplementaryArea component makes use of PinnedItems and automatically adds a pinned item for the complementary areas marked as a favorite.

gc.data.select( 'core/interface' ).isItemPinned( 'core/edit-post', 'edit-post-block-patterns/block-patterns-sidebar' );
// -> false

gc.data.dispatch( 'core/interface' ).pinItem( 'core/edit-post', 'edit-post-block-patterns/block-patterns-sidebar' );

gc.data.select( 'core/interface' ).isItemPinned( 'core/edit-post', 'edit-post-block-patterns/block-patterns-sidebar' );
// -> true

gc.data.dispatch( 'core/interface' ).unpinItem( 'core/edit-post', 'edit-post-block-patterns/block-patterns-sidebar' );

gc.data.select( 'core/interface' ).isItemPinned( 'core/edit-post', 'edit-post-block-patterns/block-patterns-sidebar' ); -> false

Preferences

The interface package provides some helpers for implementing editor preferences.

Features

Features are boolean values used for toggling specific editor features on or off.

Set the default values for any features on editor initialization:

import { dispatch } from '@gechiui/data';
import { store as interfaceStore } from '@gechiui/interface';

function initialize() {
	// ...

	dispatch( interfaceStore ).setFeatureDefaults(
		'namespace/editor-or-plugin-name',
		{
			myFeatureName: true,
		}
	);

	// ...
}

Use the toggleFeature action and the isFeatureActive selector to toggle features within your app:

gc.data
	.select( 'core/interface' )
	.isFeatureActive( 'namespace/editor-or-plugin-name', 'myFeatureName' ); // true
gc.data
	.dispatch( 'core/interface' )
	.toggleFeature( 'namespace/editor-or-plugin-name', 'myFeatureName' );
gc.data
	.select( 'core/interface' )
	.isFeatureActive( 'namespace/editor-or-plugin-name', 'myFeatureName' ); // false

The MoreMenuDropdown and MoreMenuFeatureToggle components help to implement an editor menu for changing preferences and feature values.

function MyEditorMenu() {
	return (
		<MoreMenuDropdown>
			{ () => (
				<MenuGroup label={ __( 'Features' ) }>
					<MoreMenuFeatureToggle
						scope="namespace/editor-or-plugin-name"
						feature="myFeatureName"
						label={ __( 'My feature' ) }
						info={ __( 'A really awesome feature' ) }
						messageActivated={ __( 'My feature activated' ) }
						messageDeactivated={ __( 'My feature deactivated' ) }
					/>
				</MenuGroup>
			) }
		</MoreMenuDropdown>
	);
}