How to use @automattic/data-stores - 4 common examples

To help you get started, we’ve selected a few @automattic/data-stores examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Automattic / wp-calypso / client / landing / gutenboarding / components / header / index.tsx View on Github external
import { Icon, IconButton } from '@wordpress/components';
import { useDispatch, useSelect } from '@wordpress/data';
import React, { FunctionComponent } from 'react';
import { useDebounce } from 'use-debounce';

/**
 * Internal dependencies
 */
import { DomainSuggestions } from '@automattic/data-stores';
import { STORE_KEY as ONBOARD_STORE } from '../../stores/onboard';
import './style.scss';
import { DomainPickerButton } from '../domain-picker';
import { selectorDebounce } from '../../constants';
import Link from '../link';

const DOMAIN_SUGGESTIONS_STORE = DomainSuggestions.register();

interface Props {
	isEditorSidebarOpened: boolean;
	next?: string;
	prev?: string;
	toggleGeneralSidebar: () => void;
	toggleSidebarShortcut: KeyboardShortcut;
}

interface KeyboardShortcut {
	raw: string;
	display: string;
	ariaLabel: string;
}

const Header: FunctionComponent< Props > = ( {
github Automattic / wp-calypso / client / landing / gutenboarding / components / domain-picker / list.tsx View on Github external
Panel,
	PanelBody,
	PanelRow,
	TextControl,
} from '@wordpress/components';
import { __ as NO__ } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';
import { useDebounce } from 'use-debounce';

/**
 * Internal dependencies
 */
import { DomainSuggestions } from '@automattic/data-stores';
import { selectorDebounce } from '../../constants';

const DOMAIN_SUGGESTIONS_STORE = DomainSuggestions.register();

export interface Props {
	/**
	 * Term to search when no user input is provided.
	 */
	defaultQuery?: string;

	/**
	 * Callback that will be invoked when a domain is selected.
	 *
	 * @param domainSuggestion The selected domain.
	 */
	onDomainSelect: ( domainSuggestion: DomainSuggestions.DomainSuggestion ) => void;

	/**
	 * Additional parameters for the domain suggestions query.
github Automattic / wp-calypso / client / landing / gutenboarding / onboarding-block / vertical-select / index.tsx View on Github external
/**
 * Internal dependencies
 */
import { STORE_KEY as ONBOARD_STORE } from '../../stores/onboard';
import { Verticals } from '@automattic/data-stores';
import { SiteVertical } from '../../stores/onboard/types';
import { StepProps } from '../stepper-wizard';
import Question from '../question';
import { __TodoAny__ } from '../../../../types';

/**
 * Style dependencies
 */
import './style.scss';

const VERTICALS_STORE = Verticals.register();

const VerticalSelect: FunctionComponent< StepProps > = ( {
	onSelect,
	inputClass,
	isActive,
	onExpand,
} ) => {
	const popular = [
		NO__( 'Travel Agency' ),
		NO__( 'Digital Marketing' ),
		NO__( 'Cameras & Photography' ),
		NO__( 'Website Designer' ),
		NO__( 'Restaurant' ),
		NO__( 'Fashion Designer' ),
		NO__( 'Real Estate Agent' ),
	];
github Automattic / wp-calypso / client / landing / gutenboarding / onboarding-block / design-selector / index.tsx View on Github external
import { CSSTransition } from 'react-transition-group';
import PageLayoutSelector from './page-layout-selector';
import { partition } from 'lodash';

/**
 * Internal dependencies
 */
import { SiteVertical } from '../../stores/onboard/types';
import DesignCard from './design-card';

import './style.scss';
import { VerticalsTemplates } from '@automattic/data-stores';

type Template = VerticalsTemplates.Template;

const VERTICALS_TEMPLATES_STORE = VerticalsTemplates.register();

const DesignSelector: FunctionComponent = () => {
	const siteVertical = useSelect(
		select => select( 'automattic/onboard' ).getState().siteVertical as SiteVertical
	);

	const templates =
		useSelect( select => select( VERTICALS_TEMPLATES_STORE ).getTemplates( siteVertical.id ) ) ??
		[];

	const [ designs, otherTemplates ] = partition(
		templates,
		( { category } ) => category === 'home'
	);

	const [ selectedDesign, setSelectedDesign ] = useState< Template | undefined >();

@automattic/data-stores

Calypso Data Stores.

GPL-2.0
Latest version published 1 month ago

Package Health Score

87 / 100
Full package analysis

Similar packages