WordPress / wporg-developer

WordPress.org Developer theme
https://developer.wordpress.org/
60 stars 23 forks source link

Dashicons: Implement with Interactivity API #531

Open sirreal opened 2 months ago

sirreal commented 2 months ago

Replace the dashicon page shortcode with a dashicon page block.

I had to replace the shortcode with a block because wpautop was running on the shortcode and mangling Interactivity API HTML.

I have commented the problematic line and added a todo comment to re-enabled this when supported. ~This requires https://github.com/WordPress/wordpress-develop/pull/7075 to work correctly on the server. I expect that to be released in 6.6.2. To test this, you'll need to check out that PR and instruct wp-env to use that core version.~

I have not removed or touched the existing dashicon shortcode code for now, but there are opportunities for removing code if we go ahead with this.

Most of the page HTML is transformed from the shortcode in https://github.com/WordPress/wporg-developer/blob/trunk/source/wp-content/themes/wporg-developer-2023/inc/shortcode-dashicons.php.

Testing

Load up the page in a local environment and confirm it behaves like prodoction. Note that these pages render a random icon in detail:

"Permalinks" were rendered client site with a hash to the icon slug. This behavior has been changed to use query params so that the server can render the requested icon (hash is not available to the server). Client-side, if a fragment is found with no valid icon query param, it will be upgraded to a query param:

See the upgrade behavior, where these will behave the same (after client rewrites the URL):

Filtering should work basically the same. Try using the filter bar. Non-alphanumeric characters are ignored from filtering.

The copy buttons work the same, but they are buttons instead of a elements. This seems more semantic as they open a prompt.

sirreal commented 2 months ago

@ryelle I'd appreciate feedback on this PR, thank you!

sirreal commented 2 months ago

I've addressed feedback and fixed lints, this is ready for another review.