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

Reimplement gridicons using SVG external content. #32763

Merged
merged 9 commits into from
May 6, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions assets/stylesheets/_vendor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
.gridicon {
fill: currentColor;

&.needs-offset g {
&.needs-offset use {
Copy link
Member

Choose a reason for hiding this comment

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

If the svg4everybody polyfill is active, there won't be any use elements to style. The polyfill will remove them and replace with the SVG markup it downloads with XHR.

We need a style that targets both g and use elements.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Excellent catch, thanks @jsnajdr !

I have pushed a fix for this using :first-child. Waiting for calypso.live before testing on IE11.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The fix appears to be working, from what I can tell.

transform: translate( 1px, 1px ); /* translates to .5px because it's in a child element */
}

&.needs-offset-x g {
&.needs-offset-x use {
transform: translate( 1px, 0 ); /* only nudges horizontally */
}

&.needs-offset-y g {
&.needs-offset-y use {
transform: translate( 0, 1px ); /* only nudges vertically */
}
}
Expand Down
2 changes: 1 addition & 1 deletion client/blocks/inline-help/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
height: 36px;
width: 36px;

g {
use {
transform: none;
}
}
Expand Down
23 changes: 0 additions & 23 deletions client/components/async-gridicons/fallback.jsx

This file was deleted.

65 changes: 0 additions & 65 deletions client/components/async-gridicons/index.jsx

This file was deleted.

233 changes: 233 additions & 0 deletions client/components/gridicon/docs/example.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
/**
* External dependencies
*/

import React from 'react';

/**
* Internal dependencies
*/
import Gridicon from '../index';

const icons = [
'add-image',
'add-outline',
'add',
'align-center',
'align-image-center',
'align-image-left',
'align-image-none',
'align-image-right',
'align-justify',
'align-left',
'align-right',
'arrow-down',
'arrow-left',
'arrow-right',
'arrow-up',
'aside',
'attachment',
'audio',
'bell',
'block',
'bold',
'book',
'bookmark-outline',
'bookmark',
'briefcase',
'bug',
'calendar',
'camera',
'caption',
'cart',
'chat',
'checkmark-circle',
'checkmark',
'chevron-down',
'chevron-left',
'chevron-right',
'chevron-up',
'clear-formatting',
'clipboard',
'cloud-download',
'cloud-outline',
'cloud-upload',
'cloud',
'code',
'cog',
'comment',
'computer',
'coupon',
'create',
'credit-card',
'crop',
'cross-circle',
'cross-small',
'cross',
'custom-post-type',
'customize',
'domains',
'dropdown',
'ellipsis-circle',
'ellipsis',
'external',
'filter',
'flag',
'flip-horizontal',
'flip-vertical',
'folder-multiple',
'folder',
'fullscreen-exit',
'fullscreen',
'gift',
'globe',
'grid',
'heading-h1',
'heading-h2',
'heading-h3',
'heading-h4',
'heading-h5',
'heading-h6',
'heading',
'heart-outline',
'heart',
'help-outline',
'help',
'history',
'house',
'image-multiple',
'image-remove',
'image',
'indent-left',
'indent-right',
'info-outline',
'info',
'ink',
'institution',
'italic',
'layout-blocks',
'layout',
'line-graph',
'link-break',
'link',
'list-checkmark',
'list-ordered-rtl',
'list-ordered',
'list-unordered',
'location',
'lock',
'mail',
'mention',
'menu',
'menus',
'microphone',
'minus-small',
'minus',
'money',
'multiple-users',
'my-sites-horizon',
'my-sites',
'nametag',
'next-page',
'not-visible',
'notice-outline',
'notice',
'offline',
'pages',
'pause',
'pencil',
'phone',
'pin',
'plans',
'play',
'plugins',
'plus-small',
'plus',
'popout',
'posts',
'print',
'product-downloadable',
'product-external',
'product-virtual',
'product',
'quote',
'read-more',
'reader-follow-conversation',
'reader-follow',
'reader-following-conversation',
'reader-following',
'reader',
'reblog',
'redo',
'refresh',
'refund',
'reply',
'resize',
'rotate',
'scheduled',
'search',
'share-computer',
'share-ios',
'share',
'shipping',
'shutter',
'sign-out',
'site',
'spam',
'speaker',
'special-character',
'star-outline',
'star',
'stats',
'stats-alt',
'stats-down',
'stats-down-alt',
'stats-up',
'stats-up-alt',
'status',
'strikethrough',
'sync',
'tablet',
'tag',
'text-color',
'themes',
'thumbs-up',
'time',
'trash',
'trophy',
'types',
'underline',
'undo',
'user-add',
'user-circle',
'user',
'video-camera',
'video-remove',
'video',
'visible',
'zoom-in',
'zoom-out',
];

export default function GridiconExample() {
function handleClick( icon ) {
const toCopy = `<Gridicon icon="${ icon }" />`;
window.prompt( 'Copy component code:', toCopy );
}

return (
// eslint-disable-next-line wpcalypso/jsx-classname-namespace
<div className="design-assets__group">
<h2>
<a href="/devdocs/design/social-logo">Social Logo</a>
</h2>
<div>
{ icons.map( icon => (
<Gridicon key={ icon } icon={ icon } size={ 48 } onClick={ () => handleClick( icon ) } />
) ) }
</div>
</div>
);
}

GridiconExample.displayName = 'Gridicon';
Loading