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

refactor icons.json #2084

Merged
merged 3 commits into from
Feb 6, 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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 12 additions & 12 deletions packages/docs-app/src/components/docsIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,51 +11,51 @@ import { ContextMenuTarget, Icon, IconName, Menu, MenuItem } from "@blueprintjs/
import { ClickToCopy } from "./clickToCopy";

export interface IDocsIconProps {
displayName: string;
group: string;
name: string;
iconName: IconName;
tags: string;
className: IconName;
}

const GITHUB_PATH = "https://github.com/palantir/blueprint/blob/develop/resources/icons";

@ContextMenuTarget
export class DocsIcon extends React.PureComponent<IDocsIconProps, {}> {
public render() {
const { className, name, tags } = this.props;
const { iconName, displayName, tags } = this.props;
return (
<ClickToCopy className="docs-icon" data-tags={tags} value={className}>
<Icon iconName={className} iconSize={Icon.SIZE_LARGE} />
<ClickToCopy className="docs-icon" data-tags={tags} value={iconName}>
<Icon iconName={iconName} iconSize={Icon.SIZE_LARGE} />
<span className="docs-icon-detail">
<div className="docs-icon-name">{name}</div>
<div className="docs-icon-class-name pt-monospace-text">{className}</div>
<div className="docs-icon-name">{displayName}</div>
<div className="docs-icon-class-name pt-monospace-text">{iconName}</div>
<div className="docs-clipboard-message pt-text-muted" data-hover-message="Click to copy" />
</span>
</ClickToCopy>
);
}

public renderContextMenu() {
const { className } = this.props;
const { iconName } = this.props;
return (
<Menu>
<MenuItem
className="docs-icon-16"
iconName={className}
iconName={iconName}
text="Download 16px SVG"
onClick={this.handleClick16}
/>
<MenuItem
className="docs-icon-20"
iconName={className}
iconName={iconName}
text="Download 20px SVG"
onClick={this.handleClick20}
/>
</Menu>
);
}

private handleClick16 = () => window.open(`${GITHUB_PATH}/16px/${this.props.className}.svg`);
private handleClick16 = () => window.open(`${GITHUB_PATH}/16px/${this.props.iconName}.svg`);

private handleClick20 = () => window.open(`${GITHUB_PATH}/20px/${this.props.className}.svg`);
private handleClick20 = () => window.open(`${GITHUB_PATH}/20px/${this.props.iconName}.svg`);
}
5 changes: 1 addition & 4 deletions packages/docs-app/src/components/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ export class Icons extends React.PureComponent<IIconsProps, IIconsState> {
groups[icon.group].push(icon);
return groups;
}, {});
for (const group of Object.keys(this.iconGroups)) {
this.iconGroups[group].sort((a, b) => a.name.localeCompare(b.name));
}
}

public render() {
Expand Down Expand Up @@ -108,7 +105,7 @@ export class Icons extends React.PureComponent<IIconsProps, IIconsState> {
}

function isIconFiltered(query: string, icon: IIcon) {
return smartSearch(query, icon.name, icon.className, icon.tags, icon.group);
return smartSearch(query, icon.displayName, icon.iconName, icon.tags, icon.group);
}

function renderIcon(icon: IIcon, index: number) {
Expand Down
Loading