Skip to content

Commit

Permalink
feat(icons-ui): update spectrum css input
Browse files Browse the repository at this point in the history
  • Loading branch information
Westbrook Johnson authored and Westbrook committed Jan 6, 2021
1 parent 549b4b6 commit 4cb87ff
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 32 deletions.
33 changes: 3 additions & 30 deletions packages/icons-ui/bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ glob(`${rootDir}/node_modules/${iconsPath}/**.svg`, (err, icons) => {
const $ = cheerio.load(svg, {
xmlMode: true,
});
const title = Case.capital(id);
const fileName = `${id}.ts`;
const location = path.join(
rootDir,
Expand All @@ -72,21 +71,15 @@ glob(`${rootDir}/node_modules/${iconsPath}/**.svg`, (err, icons) => {

$('*').each((index, el) => {
if (el.name === 'svg') {
$(el).attr('aria-hidden', '...');
$(el).attr('role', 'img');
$(el).attr('aria-hidden', 'true');
if (keepColors !== 'keep') {
$(el).attr('fill', 'currentColor');
}
$(el).attr('aria-label', '${title}');
$(el).removeAttr('id');
}
if (el.name === 'defs') {
$(el).remove();
}
const dimensions = {
width: 0,
height: 0,
};
Object.keys(el.attribs).forEach((x) => {
if (x === 'class') {
$(el).removeAttr(x);
Expand All @@ -97,17 +90,7 @@ glob(`${rootDir}/node_modules/${iconsPath}/**.svg`, (err, icons) => {
if (keepColors !== 'keep' && x === 'fill') {
$(el).attr(x, 'currentColor');
}
if (el.name === 'svg') {
if (x === 'width' || x === 'height') {
dimensions[x] = $(el).attr(x);
$(el).attr(x, '${' + x + '}');
}
}
});
$(el).attr(
'viewBox',
`0 0 ${dimensions.width} ${dimensions.height}`
);
});

const iconLiteral = `
Expand All @@ -116,18 +99,8 @@ glob(`${rootDir}/node_modules/${iconsPath}/**.svg`, (err, icons) => {
import {tag as html, TemplateResult} from '../custom-tag.js';
export {setCustomTemplateLiteralTag} from '../custom-tag.js';
export const ${ComponentName}Icon = ({
width = 24,
height = 24,
hidden = false,
title = '${title}',
} = {},): string | TemplateResult => {
return html\`${$('svg')
.toString()
.replace(
'aria-hidden="..."',
"aria-hidden=\"${hidden ? 'true' : 'false'}\""
)}\`;
export const ${ComponentName}Icon = (): string | TemplateResult => {
return html\`${$('svg').toString()}\`;
}
`;

Expand Down
2 changes: 1 addition & 1 deletion packages/icons-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"author": "",
"license": "Apache-2.0",
"devDependencies": {
"@spectrum-css/icon": "^3.0.0-beta.1",
"@spectrum-css/icon": "^3.0.0-beta.2",
"@spectrum-web-components/icon": "^0.6.3",
"@spectrum-web-components/iconset": "^0.1.7",
"case": "^1.6.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/icons-ui/stories/icons-ui.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const ui = (): TemplateResult => {
}
const size = select(
'Icon Size',
['xxs', 'xs', 's', 'm', 'l', 'xl', 'xxl'],
['s', 'm', 'l', 'xl', 'xxl'],
'm',
'Element'
);
Expand Down

0 comments on commit 4cb87ff

Please sign in to comment.