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

remove IconClasses #2097

Merged
merged 4 commits into from
Feb 7, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 12 additions & 1 deletion packages/core/src/components/icon/icon.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ for 16px and 20px grids. The `icon` prop dictates which SVG is rendered and `ico
which pixel grid is used: `iconSize >= 20` will use the 20px grid and smaller icons will use the 16px grid.

```tsx
import { Icon, IconNames, Intent } from "@blueprintjs/core";

// string literals are supported through IconName union type
<Icon icon="cross" />
<Icon icon="globe" iconSize={20} />
Expand All @@ -42,7 +44,16 @@ which pixel grid is used: `iconSize >= 20` will use the 20px grid and smaller ic
<Icon icon={IconNames.GRAPH} iconSize={Icon.SIZE_LARGE} intent={Intent.PRIMARY} />

// can pass all valid HTML props
<Icon icon="add" onClick={this.handleAdd} onKeyDown={this.handleAddKeys}>
<Icon icon="add" onClick={this.handleAdd} onKeyDown={this.handleAddKeys} />
```

```html
<Icon icon="globe" iconSize={30} />
<!-- renders the following HTML markup: -->
<svg class="pt-icon" data-icon="globe" width="30" height="30" viewBox="0 0 20 20">
<title>globe</title>
<path ... />
</svg>
```

@interface IIconProps
Expand Down
4 changes: 2 additions & 2 deletions packages/core/test/icon/iconTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { assert } from "chai";
import { shallow } from "enzyme";
import * as React from "react";

import { IconClasses, IconName } from "@blueprintjs/icons";
import { IconName } from "@blueprintjs/icons";

import { Classes, Icon, IIconProps, Intent } from "../../src/index";

Expand All @@ -26,7 +26,7 @@ describe("<Icon>", () => {

it("prefixed icon renders nothing", () => {
// @ts-ignore invalid icon
const icon = shallow(<Icon icon={IconClasses.AIRPLANE} />);
const icon = shallow(<Icon icon={Classes.iconClass("airplane")} />);
assert.isTrue(icon.isEmptyRender());
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { Button, Classes, MenuItem } from "@blueprintjs/core";
import { IconClasses, IconName } from "@blueprintjs/icons";
import { IconName, IconNames } from "@blueprintjs/icons";
import { ItemRenderer, Select } from "@blueprintjs/select";
import * as classNames from "classnames";
import * as React from "react";
Expand All @@ -17,9 +17,7 @@ export interface IIconSelectProps {

const NONE = "(none)";
type IconType = IconName | typeof NONE;
const ICON_NAMES = Object.keys(IconClasses).map<IconType>(
(name: keyof typeof IconClasses) => IconClasses[name].replace("pt-icon-", "") as IconName,
);
const ICON_NAMES = Object.keys(IconNames).map<IconType>((name: keyof typeof IconNames) => IconNames[name]);
ICON_NAMES.push(NONE);

const TypedSelect = Select.ofType<IconType>();
Expand Down
5 changes: 2 additions & 3 deletions packages/icons/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
* Licensed under the terms of the LICENSE file distributed with this project.
*/

import * as IconClasses from "./generated/iconClasses";
import * as IconContents from "./generated/iconContents";
import * as IconNames from "./generated/iconNames";
import { IconSvgPaths16, IconSvgPaths20 } from "./generated/iconSvgPaths";

export { IconClasses, IconContents, IconNames, IconSvgPaths16, IconSvgPaths20 };
export { IconContents, IconNames };
export { IconSvgPaths16, IconSvgPaths20 } from "./generated/iconSvgPaths";
export { IconName } from "./iconName";
3 changes: 0 additions & 3 deletions packages/node-build-scripts/generate-icons-source
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ writeLinesToFile(
// simple variable definitions
writeLinesToFile("_icon-variables.scss", ...ICONS_METADATA.map(icon => `$${toLongName(icon)}: "${icon.content}";`));

// map ENUM_NAME to pt-icon-class-name
writeLinesToFile("iconClasses.ts", ...exportIconConsts(toLongName));

// map ENUM_NAME to unicode character
writeLinesToFile("iconContents.ts", ...exportIconConsts(icon => icon.content.replace("\\", "\\u")));

Expand Down
2 changes: 2 additions & 0 deletions scripts/upgrade-blueprint-2.0.0-rename
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ renameProp renderLabel labelRenderer
renameProp isDisabled disabled
renameProp isModal hasBackdrop
renameProp iconName icon
renameString "icon=\{IconClasses" "icon={IconNames" # prop usage (previous line renames icon prop)
renameString IconClasses "Classes.iconClass(IconNames" # assuming user wanted class name
renameString FileUpload FileInput
renameString fileUpload fileInput
renameString "pt-file-upload(?!-)" pt-file-input # only rename full classname, not partial classname like pt-file-upload-input
Expand Down