Skip to content

Commit

Permalink
Define icons as React components to eliminate SVG -> JSX build step a…
Browse files Browse the repository at this point in the history
…nd allow testing
  • Loading branch information
reidmit committed Feb 16, 2019
1 parent 844a77a commit 9cf9900
Show file tree
Hide file tree
Showing 111 changed files with 715 additions and 449 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,4 @@ spec/css/regressionRunner.js

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc
vendor/ruby

src/react/iconography/icons.js
vendor/ruby
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
"sass-loader": "^7.1.0",
"stringifier": "^2.0.0",
"style-loader": "^0.23.1",
"svg-to-jsx": "^1.0.0",
"url-loader": "^1.1.2",
"webpack": "^4.28.1",
"webpack-cli": "^3.2.1",
Expand Down
42 changes: 42 additions & 0 deletions spec/pivotal-ui-react/iconography/iconography.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom';
import {Icon} from '../../../src/react/iconography';
import * as Icons from '../../../src/react/iconography/icons';

describe('iconography', () => {
afterEach(() => {
Expand All @@ -18,6 +19,47 @@ describe('iconography', () => {
expect('.icon').toHaveAttr('id', 'bar');
});

Object.keys(Icons).filter(iconName => {
return !iconName.startsWith('_') && !iconName.includes('spinner');
}).forEach(iconName => {
it(`works with src "${iconName}"`, () => {
ReactDOM.render(<Icon src={iconName} className="foo" id="bar"/>, root);
expect('.icon svg').toHaveClass(`icon-${iconName}`);
});
});

describe('spinner icons', () => {
it('works with src "spinner_lg"', () => {
ReactDOM.render(<Icon src="spinner_lg" className="foo" id="bar"/>, root);
expect('.icon svg').toHaveClass('icon-spinner-lg');
});

it('works with src "spinner-lg" (for backwards compatibility)', () => {
ReactDOM.render(<Icon src="spinner-lg" className="foo" id="bar"/>, root);
expect('.icon svg').toHaveClass('icon-spinner-lg');
});

it('works with src "spinner_md"', () => {
ReactDOM.render(<Icon src="spinner_md" className="foo" id="bar"/>, root);
expect('.icon svg').toHaveClass('icon-spinner-md');
});

it('works with src "spinner-md" (for backwards compatibility)', () => {
ReactDOM.render(<Icon src="spinner-md" className="foo" id="bar"/>, root);
expect('.icon svg').toHaveClass('icon-spinner-md');
});

it('works with src "spinner_sm"', () => {
ReactDOM.render(<Icon src="spinner_sm" className="foo" id="bar"/>, root);
expect('.icon svg').toHaveClass('icon-spinner-sm');
});

it('works with src "spinner-sm" (for backwards compatibility)', () => {
ReactDOM.render(<Icon src="spinner-sm" className="foo" id="bar"/>, root);
expect('.icon svg').toHaveClass('icon-spinner-sm');
});
});

describe('verticalAlign', () => {
it('if verticalAlign is not specified it applies the .icon-middle', () => {
ReactDOM.render(<Icon src="add"/>, root);
Expand Down
3 changes: 0 additions & 3 deletions src/css/iconography/svgs/account_circle.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/add.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/add_circle.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/add_circle_outline.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/apple_logo.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/arrow_back.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/arrow_downward.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/arrow_drop_down.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/arrow_drop_left.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/arrow_drop_right.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/arrow_drop_up.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/arrow_forward.svg

This file was deleted.

5 changes: 0 additions & 5 deletions src/css/iconography/svgs/arrow_up_circle.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/arrow_upward.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/autorenew.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/cached.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/cancel.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/chat.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/check.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/check_circle.svg

This file was deleted.

4 changes: 0 additions & 4 deletions src/css/iconography/svgs/check_circle_outline.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/chevron_down.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/chevron_left.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/chevron_right.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/chevron_up.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/iconography/svgs/circle.svg
Diff not rendered.
3 changes: 0 additions & 3 deletions src/css/iconography/svgs/circle_outline.svg
Diff not rendered.
5 changes: 0 additions & 5 deletions src/css/iconography/svgs/close.svg
Diff not rendered.
3 changes: 0 additions & 3 deletions src/css/iconography/svgs/close_circle_outline.svg
Diff not rendered.
3 changes: 0 additions & 3 deletions src/css/iconography/svgs/cloud_done.svg
Diff not rendered.
3 changes: 0 additions & 3 deletions src/css/iconography/svgs/cloud_download.svg
Diff not rendered.
3 changes: 0 additions & 3 deletions src/css/iconography/svgs/cloud_upload.svg
Diff not rendered.
4 changes: 0 additions & 4 deletions src/css/iconography/svgs/code.svg
Diff not rendered.
3 changes: 0 additions & 3 deletions src/css/iconography/svgs/collapse.svg
Diff not rendered.
4 changes: 0 additions & 4 deletions src/css/iconography/svgs/compare_arrows_alt.svg
Diff not rendered.
3 changes: 0 additions & 3 deletions src/css/iconography/svgs/copy.svg
Diff not rendered.
5 changes: 0 additions & 5 deletions src/css/iconography/svgs/database.svg
Diff not rendered.
3 changes: 0 additions & 3 deletions src/css/iconography/svgs/download.svg
Diff not rendered.
3 changes: 0 additions & 3 deletions src/css/iconography/svgs/error.svg
Diff not rendered.
3 changes: 0 additions & 3 deletions src/css/iconography/svgs/error_outline.svg
Diff not rendered.
3 changes: 0 additions & 3 deletions src/css/iconography/svgs/euro_symbol.svg
Diff not rendered.
3 changes: 0 additions & 3 deletions src/css/iconography/svgs/exit_to_app.svg
Diff not rendered.
3 changes: 0 additions & 3 deletions src/css/iconography/svgs/feedback.svg
Diff not rendered.
3 changes: 0 additions & 3 deletions src/css/iconography/svgs/filter_list.svg
Diff not rendered.
3 changes: 0 additions & 3 deletions src/css/iconography/svgs/format_align_center.svg
Diff not rendered.
3 changes: 0 additions & 3 deletions src/css/iconography/svgs/format_align_justify.svg
Diff not rendered.
3 changes: 0 additions & 3 deletions src/css/iconography/svgs/format_align_left.svg
Diff not rendered.
3 changes: 0 additions & 3 deletions src/css/iconography/svgs/format_align_right.svg
Diff not rendered.
4 changes: 0 additions & 4 deletions src/css/iconography/svgs/github.svg
Diff not rendered.
4 changes: 0 additions & 4 deletions src/css/iconography/svgs/grip.svg
Diff not rendered.
3 changes: 0 additions & 3 deletions src/css/iconography/svgs/help.svg
Diff not rendered.
3 changes: 0 additions & 3 deletions src/css/iconography/svgs/help_outline.svg
Diff not rendered.
11 changes: 0 additions & 11 deletions src/css/iconography/svgs/highlight.svg
Diff not rendered.
Loading

0 comments on commit 9cf9900

Please sign in to comment.