Skip to content

Commit

Permalink
feat(create-component): use formatAttributes from icon-helpers
Browse files Browse the repository at this point in the history
Supports #4.

Breaking changes:

- remove width, height exports
  • Loading branch information
Eric Liu authored and Eric Liu committed Dec 13, 2019
1 parent 7e45e60 commit 99dd286
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
10 changes: 2 additions & 8 deletions src/createComponent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getAttributes } from '@carbon/icon-helpers';
import { formatAttributes, getAttributes } from '@carbon/icon-helpers';
import { createElements } from './createElements';

interface IAttributes {
Expand Down Expand Up @@ -54,13 +54,10 @@ function createComponent(icon: ICarbonIcon) {
let className = undefined;
export { className as class };
export let tabindex = undefined;
export let width = ${attrs.width};
export let height = ${attrs.height};
export let focusable = '${attributes.focusable}';
export let title = undefined;
export let style = '${attributes.style}';
const viewBox = '${attrs.viewBox}';
const preserveAspectRatio = '${attributes.preserveAspectRatio}';
const ariaLabel = $$props['aria-label'];
const ariaLabelledBy = $$props['aria-labelledby'];
Expand All @@ -79,12 +76,9 @@ function createComponent(icon: ICarbonIcon) {
on:mouseover
on:mouseenter
on:mouseleave
xmlns='${attrs.xmlns}'
${formatAttributes(attrs)}
class={className}
{preserveAspectRatio}
{viewBox}
{width}
{height}
{style}
{...attributes}>
${createElements(content)}
Expand Down
8 changes: 1 addition & 7 deletions src/tests/__snapshots__/createComponent.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ Object {
let className = undefined;
export { className as class };
export let tabindex = undefined;
export let width = 16;
export let height = 16;
export let focusable = 'false';
export let title = undefined;
export let style = 'will-change: transform;';
const viewBox = '0 0 16 16';
const preserveAspectRatio = 'xMidYMid meet';
const ariaLabel = $$props['aria-label'];
const ariaLabelledBy = $$props['aria-labelledby'];
Expand All @@ -32,12 +29,9 @@ Object {
on:mouseover
on:mouseenter
on:mouseleave
xmlns='http://www.w3.org/2000/svg'
xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 16 16\\" width=\\"16\\" height=\\"16\\"
class={className}
{preserveAspectRatio}
{viewBox}
{width}
{height}
{style}
{...attributes}>
<path d='M6.7 12.3L2.9 8.5H15v-1H2.9l3.8-3.8L6 3 1 8l5 5z'></path>
Expand Down

0 comments on commit 99dd286

Please sign in to comment.