Open bobbingwide opened 2 years ago
The current logic can't handle SVG's which are not in the simple form <Path d="SVG stuff">
There are approximately 70 of these, reducing the number of icons from 620 to 550.
An example is the icon for Query Pagination.
https://github.com/WordPress/gutenberg/blob/trunk/packages/icons/src/library/query-pagination.js
This uses Rect.
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<Rect x="4" y="10.5" width="6" height="3" rx="1.5" fill="#000" />
<Rect x="12" y="10.5" width="3" height="3" rx="1.5" fill="#000" />
<Rect x="17" y="10.5" width="3" height="3" rx="1.5" fill="#000" />
</SVG>
Others use <g>
, <polygon>
, etc.
There are also some icons which have other attributes for the <Path>
tag.
And a few which have different values for viewBox
on the <SVG>
tag.
The SVG version of some of the dashicons doesn't look right. I'll create a page showing the dashicon and SVG icon version for each icon that's wrong then investigate
Icon | Expect problems ? | Explanation |
---|---|---|
archive-title | Yes | <Path stroke |
query-pagination | Yes | 3 Rects |
query-pagination-next | Yes | 3 Rects |
query-pagination-numbers | Yes | Rect |
query pagination-previous | Yes | Rect and stroke and strokeWidth |
star empty | Yes | fillRule and clipRule |
telegram | ? | viewBox="0 0 128 128" |
term-description | Yes | 2 Paths with stroke, strokeWidth, and fill |
wordpress | ? | SVG version for social links implements wordpress-alt ? |
should also look at the 70 or so that don't get included
Extract the value of the d attribute from the Path tag as the value of the $icons array
As noted above, this method didn't work for approx 80 of the icons. The pragmatic solution is to extract the full SVG and to adjust the SVG tag in the code that displays the icon.
Generate a .php file to load in class OIK_SVG_icons, using require_once ?
oik-dash-svg-list.php
. bw_dash_list_svg_icons()
libs
folder for three plugins: oik, oik-bob-bing-wide, oik-libsDeliver the file ( it was originally called oik-dash-svg-list.php ) as a shared library file
oik-dash-svg-list.php is loaded as a shared library file by the class-oik-svg-icons shared library file.
See OIK_SVG_icons::list_svg_icons()
Cater for duplicate keys. Solution TBC. Probably newest version trumps the others.
When a duplicate key is found a new entry is created with a suffix indicating which set of icons it's associated with.
The dash
icons are processed first, followed by icons
, then the Social links
icons.
Example duplicate is:
wordpress
- the original dashiconwordpress-icons
- from the icons setwordpress-links
- from the social links setNote: wordpress-icons
and wordpress-links
are actually more like the wordpress-alt
dashicon.
Gutenberg now uses SVG instead of dashicons for the pretty images used for blocks, block icons etc. The [bw_dash] shortcode and associated block should also support SVG images. In the first version of bw_dash I extracted the
d=
attribute from the svg tag and hand crafted a PHP array that could be used in the server to return the required icon. I now want to automate the process of updating this file. There are 3 sources for the icons:Notes:
Requirement
oik-bbw/dashicons
block.Proposed solution
svg2php.php
d
attribute from thePath
tag as the value of the $icons arrayStructure of the file