Git Product home page Git Product logo

Comments (4)

bobbingwide avatar bobbingwide commented on September 27, 2024

Core embed blocks are now Variations of the core/embed block.
You can use getBlockVariations( state, blockName, scope ) to get the block variations by block name.

from oik-blocks.

bobbingwide avatar bobbingwide commented on September 27, 2024

Requirements

The following blocks will need changing to support block variations.

  1. oik-blocks/blockicon
  2. oik-blocks/blockinfo
  3. oik-blocks/blocklist

oik-blocks/blockicon

  • The Blocks select list needs to be updated to include the Block variations.
  • The display of the icon may need updating

oik-blocks/blockinfo

  • The Blocks select list needs to be updated to include the Block variations
  • The display should list the variations ( in ascending name or title )
  • If the Show block link toggle is on each variation should link to the defined block
  • For each variation the values for the other toggles should be respected.

oik-blocks/blocklist

  • The list should include variations for each parent block with the selected prefix
  • It should no longer be necessary to create oikwp oik-create-blocks.php commands
  • The Show block description toggle can be removed

Also, the core BlockIcon should be displayed by passing icon={block.icon}. Was icon={block.icon.src}.

from oik-blocks.

bobbingwide avatar bobbingwide commented on September 27, 2024

You can use getBlockVariations( state, blockName, scope ) to get the block variations by block name.

That's the theory. In practice I didn't know how to do this because I was trying to use the wrong API.

In https://developer.wordpress.org/block-editor/packages/packages-blocks/
getBlockVariations is documented as taking two parameters.

  1. blockName string: Name of block (example: “core/columns”).
  2. scope [WPBlockVariationScope]: Block variation scope name.

where scope is 'block' or 'inserter'.

In https://developer.wordpress.org/block-editor/data/data-core-blocks/ there's a different function with the same name.
This is used when working with select( 'core/blocks').
This is the stuff that I'm still struggling to understand.
Fortunately, I don't need to use this function; I just needed to use the right values for the parameters to the first.

from oik-blocks.

bobbingwide avatar bobbingwide commented on September 27, 2024

The Show block description toggle can be removed

Do two things at the same time.

  • Change the showDescription toggle to showVariations; to optionally display the Variations.
  • Add logic to filter variations when the toggle is off.
  • Don't worry about deprecation.

from oik-blocks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.