Skip to content

Latest commit

 

History

History

icons

tenup/icons data store

The data store for tenup/icons stores icons in this shape:

{
    iconSets: {
        'example/theme': {
            label: 'Example',
            icons: [
                {
                    source: "...",
                    name: "...",
                    label: "..."
                },
                {
                    source: "...",
                    name: "...",
                    label: "..."
                }
            ]
        },
        'core/dashicons': {
            label: 'Dashicons',
            icons: [
                {
                    source: "...",
                    name: "...",
                    label: "..."
                },
                {
                    source: "...",
                    name: "...",
                    label: "..."
                }
            ]
        }
    }
}

Available selectors:

You can access the Icons datastore using the tenup/icons namespace or by importing iconStore from @10up/block-components;

import { iconStore } from '@10up/block-components';

select(iconStore).getIconSets();

Get all available Icon Sets

select('tenup/icons').getIconSets();

response:

[
    { name: 'example/theme', label: 'Example' icons: [] },
    { name: 'core/dashicons', label: 'Dashicons' icons: [] },
]

Get an Icon Set by name

select('tenup/icons').getIconSet( 'core/dashicons' );

response:

{
    name: 'core/dashicons',
    label: 'Dashicons'
    icons: []
}

Get all icons from an Icon Set

select('tenup/icons').getIcons( 'core/dashicons' );

response:

[
    {
        source: "...",
        name: "...",
        label: "..."
    },
    {
        source: "...",
        name: "...",
        label: "..."
    }
]

Get Singular Icon from an Icon Set

select('tenup/icons').getIcon( 'core/dashicons', 'smiley' );

response:

{
    source: "...",
    name: "...",
    label: "..."
}