polaris icon indicating copy to clipboard operation
polaris copied to clipboard

Icons: request for svg clock icon

Open mattchidley opened this issue 9 years ago • 6 comments

Issue summary

There is no SVG clock icon included with the Shopify Polaris SVG icons

Expected behavior

SVG clock icon being created

Actual behavior

I am currently creating a time input component and would love to have a Polaris svg icon. I am using the calendar svg icon as a prefix on a TextField for the DatePicker and hope to use a similar style clock icon.

Steps to reproduce the problem

  1. install shopify/polaris
  2. <Icon source="
  3. No clock icon available

Specifications

  • Polaris version: 1.8.3
  • React version: 3.10.10
  • Browser: Any
  • Device: PC
  • Operating System: Windows

⚓️ We’re not accepting pull requests at this time
🗒 This repo is for reporting issues and feature requests only

mattchidley avatar Nov 01 '17 16:11 mattchidley

Thanks @mattchidley. We'll discuss adding this icon to the bundle but in the meantime, just in case you are not aware, you can use your own icon with the icon component:

import clock from './clock.svg';

<Icon source={clock} />

dleroux avatar Nov 14 '17 15:11 dleroux

I am not having any luck with the above solution - just keep getting "TypeError: Cannot read property 'viewBox' of undefined." I have checked that the import is successful with <img src={myIcon} /> - am I missing a dependency perhaps?

alienvir avatar Jan 12 '18 20:01 alienvir

Hey @alienvir, there is a bit of build configuration required. You need to make sure you are using some sort of bundler for your app that can import SVGs — we use Webpack. For icons, the icon component actually expects a pretty specific structure: an object, that has a viewBox and a body property. You can automatically transform it this way using the @shopify/images/icon-loader for Webpack after installing the @shopify/images NPM package.

If you want to short-circuit all of that, you can simply manually write out your icon in the expected shape:

const icon = {
  viewBox: '0 0 20 20',
  body: '<path />', // everything in the SVG other than the `<svg>` tag itself
};

<Icon source={icon} />

lemonmade avatar Jan 12 '18 20:01 lemonmade

Thank you. Manually writing the icon structure worked. This is my first experience with react, so I used create-react-app to set up the project and it looks like Webpack is configured automatically. I will need to learn more about manually configuring as I work through this.

alienvir avatar Jan 12 '18 21:01 alienvir

We’re working on a better way to distribute icons. For now, using your own icon as described above is what we’d recommend.

ry5n avatar Mar 29 '18 01:03 ry5n

Polaris icons are now all available via a new npm package called @shopify/polaris-icons. Find them alongside usage instructions at https://polaris-icons.shopify.com 💟

kaelig avatar Jun 24 '19 22:06 kaelig