Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try/variation icons editor #22

Closed
wants to merge 5 commits into from
Closed

Try/variation icons editor #22

wants to merge 5 commits into from

Conversation

gaambo
Copy link

@gaambo gaambo commented Sep 20, 2023

Tries solution no 3 for #21.
The icon and label for social sharing link variations (=services) will be get from all registered block variations (the data store) and not from the hardcoded variations of the plugin.

Testing instructions:

  1. Register a custom block variation for the outermost/social-sharing-link block in JavaScript (editor):
import { link as linkIcon } from "@wordpress/icons";
registerBlockVariation("outermost/social-sharing-link", {
    name: "link",
    isDefault: true,
    title: __("Link"),
    icon: linkIcon,
    attributes: {
      service: "link",
    },
    isActive: (blockAttributes, variationAttributes) => blockAttributes.service === "link",
  });
  1. Add a social sharing block in the editor and add this variation as a child.
  2. The block displays the correct icon and label (renderd in the button!)

Important: Does only work with icons set to SVG/react components. If you pass a string (like the name of a Dashicon) the string directly will be rendered.

TODO:

  • Maybe check that icon is a component and not a string
  • Map Twitter to X

Important 2
This is based on top of the add/local-dev-environment branch of my fork. I can cherry pick only the one commmit required for this issue (e074114) or (if PR #20 gets merged) rebase this branch on the upstream main.

Copy link

@philcable philcable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @gaambo, thank you very much for diving into this! It was completely unexpected and much appreciated.

I left one thought on the approach - feel free to take it or leave it 🙂!

src/social-sharing-link/social-list.js Outdated Show resolved Hide resolved
@ndiego
Copy link
Owner

ndiego commented Jan 2, 2024

Closing in favor of #23. Thanks so much for outlining the solution here!

@ndiego ndiego closed this Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants