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

Create a magnetic-poetry block #1

Closed
bobbingwide opened this issue Feb 11, 2019 · 7 comments
Closed

Create a magnetic-poetry block #1

bobbingwide opened this issue Feb 11, 2019 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@bobbingwide
Copy link
Owner

Similar to Verse but formatted to look like magnetic poetry fridge magnets.

Block name: oik-block/magnetic-poetry
Title: Magnetic Poetry
category: formatting -
icon: editor

Steps to develop

  1. Prototype some code in bw
  2. Create a hard-coded version, satisfied by the server.
  3. Add client code based on oik-block/CSV
  4. Update PHP to perform server side rendering
  5. Find out why it doesn't work when Gutenberg is active!
  6. Implement the proper server side rendering code.

Early screenshot

image

This screenshot was taker after step 4. WordPress 5.0.3, Gutenberg not activated.
I'd already resolved a number of minor issues.

  1. Incorrect category: wigets
  2. Invalid icon name ( verse ) led to blank icon
  3. Incorrect block name for ServerSideRender - extra oik- before magnetic-poetry

Issues visible in the screenshot:

  1. white background needed by default - not being applied for 0 degree rotation
  2. Rendered contents bigger than the block.
@bobbingwide bobbingwide added the enhancement New feature or request label Feb 11, 2019
@bobbingwide bobbingwide self-assigned this Feb 11, 2019
bobbingwide added a commit that referenced this issue Feb 11, 2019
@bobbingwide
Copy link
Owner Author

image

@bobbingwide
Copy link
Owner Author

I wish I’d written down where I found the CSS that could resolve the overflow issues.

@bobbingwide
Copy link
Owner Author

I wish I’d written down where I found the CSS that could resolve the overflow issues.

I did. See #3.
Note: I managed to achieve something close to what I wanted by styling the individual words as display: inline-box and adjusting the margins.
Need to try display: flex as well.

@bobbingwide
Copy link
Owner Author

New requirements

  • I now want to rename the block. From oik-block/magnetic-poetry to oik-mp/magnetic-poetry; so that it’s not listed under the oik-block prefix.
  • To be able to transform core/verse to oik-mp/magnetic-poetry and vice-versa.

The transform is easy.
For the rename, I’m considering adding a filter to rename the block on the fly.
Producing a server side deprecated style message in the editor.
This’ll be more friendly than ‘Your site doesn’t support this block’.

@bobbingwide
Copy link
Owner Author

bobbingwide commented Dec 31, 2019

I now want to rename the block. From oik-block/magnetic-poetry to oik-mp/magnetic-poetry; so that it’s not listed under the oik-block prefix.

I couldn't work out how to intercept the editor. I decided to use wp search-replace.

Note: With blocks that are delivered by oik-blocks then it's possible to add a transform for each block that is now being delivered in another plugin. e.g. oik-css/css can be transformed in oik-css from oik-block/css . It's not possible when the block is renamed within its own plugin.

@bobbingwide
Copy link
Owner Author

bobbingwide commented Jan 4, 2020

Next I want to make use of the logic in the oik-blocks shared library.

  • use oik\oik_blocks\oik_blocks_register_editor_scripts to register the editor_script JavaScript
  • use oik\oik_blocks\oik_blocks_register_block_styles to register the CSS, used for both editor_style and style
  • move the CSS from css/oik-magnetic-poetry.css to the block's style.scss file.
  • confirm that it's not necessary to respond to enqueue_block_assets and/or enqueue_block_editor_assets since this is now handled by our use of register_block_type.

@bobbingwide
Copy link
Owner Author

Closing this as I've now built v0.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant