Skip to content

Commit 188bb75

Browse files
committed
feat(icons): add "Icon" suffix to all icons and deprecate old names
1 parent 7235f24 commit 188bb75

File tree

3,031 files changed

+15162
-6082
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,031 files changed

+15162
-6082
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ npm i @phosphor-icons/react
2727
Simply import the icons you need, and add them anywhere in your render method. Phosphor supports tree-shaking, so your bundle only includes code for the icons you use.
2828

2929
```tsx
30-
import { Horse, Heart, Cube } from "@phosphor-icons/react";
30+
import { HorseIcon, HeartIcon, CubeIcon } from "@phosphor-icons/react";
3131

3232
const App = () => {
3333
return (
3434
<main>
35-
<Horse />
36-
<Heart color="#AE2983" weight="fill" size={32} />
37-
<Cube color="teal" weight="duotone" />
35+
<HorseIcon />
36+
<HeartIcon color="#AE2983" weight="fill" size={32} />
37+
<CubeIcon color="teal" weight="duotone" />
3838
</main>
3939
);
4040
};
@@ -66,10 +66,10 @@ module.exports = {
6666
When using Phosphor Icons in an SSR environment, within a React Server Component, or in any environment that does not permit the use of the Context API ([Next.js](https://nextjs.org/) Server Component, for example), import icons from the `/dist/ssr` submodule:
6767

6868
```tsx
69-
import { Fish } from "@phosphor-icons/react/dist/ssr";
69+
import { FishIcon } from "@phosphor-icons/react/dist/ssr";
7070

7171
const MyServerComponent = () => {
72-
return <Fish weight="duotone" />;
72+
return <FishIcon weight="duotone" />;
7373
};
7474
```
7575

@@ -91,7 +91,7 @@ Icon components accept all props that you can pass to a normal SVG element, incl
9191
Phosphor takes advantage of React Context to make applying a default style to all icons simple. Create an `IconContext.Provider` at the root of the app (or anywhere above the icons in the tree) and pass in a configuration object with props to be applied by default to all icons:
9292

9393
```tsx
94-
import { IconContext, Horse, Heart, Cube } from "@phosphor-icons/react";
94+
import { IconContext, HorseIcon, HeartIcon, CubeIcon } from "@phosphor-icons/react";
9595

9696
const App = () => {
9797
return (
@@ -104,9 +104,9 @@ const App = () => {
104104
}}
105105
>
106106
<div>
107-
<Horse /> {/* I'm lime-green, 32px, and bold! */}
108-
<Heart /> {/* Me too! */}
109-
<Cube /> {/* Me three :) */}
107+
<HorseIcon /> {/* I'm lime-green, 32px, and bold! */}
108+
<HeartIcon /> {/* Me too! */}
109+
<CubeIcon /> {/* Me three :) */}
110110
</div>
111111
</IconContext.Provider>
112112
);
@@ -132,7 +132,7 @@ The following will cause the Cube icon to rotate and pulse:
132132
```jsx
133133
const RotatingCube = () => {
134134
return (
135-
<Cube color="darkorchid" weight="duotone">
135+
<CubeIcon color="darkorchid" weight="duotone">
136136
<animate
137137
attributeName="opacity"
138138
values="0;1;0"
@@ -148,7 +148,7 @@ const RotatingCube = () => {
148148
to="360 0 0"
149149
repeatCount="indefinite"
150150
></animateTransform>
151-
</Cube>
151+
</CubeIcon>
152152
);
153153
};
154154
```
@@ -163,9 +163,9 @@ You may wish to import all icons at once for use in your project, though dependi
163163
```tsx
164164
import * as Icon from "@phosphor-icons/react";
165165

166-
<Icon.Smiley />
167-
<Icon.Folder weight="thin" />
168-
<Icon.BatteryHalf size="24px" />
166+
<Icon.SmileyIcon />
167+
<Icon.FolderIcon weight="thin" />
168+
<Icon.BatteryHalfIcon size="24px" />
169169
```
170170

171171
For information on using Phosphor Icons in Server Components, see See [React Server Components and SSR](#react-server-components-and-ssr).

example/App.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { useState, useCallback } from "react";
22

3-
import * as Icons from "../dist";
4-
import { IconContext } from "../dist";
5-
import type { IconWeight, Icon } from "../dist";
3+
import * as Icons from "..";
4+
import { IconContext } from "..";
5+
import type { IconWeight, Icon } from "..";
66
import { icons } from "../core/src/icons";
77
import { CustomIcon } from "./CustomIcon";
8-
import { At } from "../dist/ssr";
8+
import { AtIcon } from "..";
99
import "./index.css";
1010

1111
const pascalNames = new Set(icons.map((entry) => entry.pascal_name));
@@ -73,9 +73,9 @@ const App = () => {
7373
<CustomIcon size={32} weight="fill" color="darkorange" />
7474
</div>
7575
<div>
76-
<At />
77-
<At color="crimson" size={48} />
78-
<At color="teal" size={48} weight="fill" />
76+
<AtIcon />
77+
<AtIcon color="crimson" size={48} />
78+
<AtIcon color="teal" size={48} weight="fill" />
7979
</div>
8080
<Icons.Cube
8181
style={{ cursor: "pointer" }}

example/CustomIcon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ReactElement, forwardRef } from "react";
2-
import { IconBase, Icon, IconWeight } from "../dist";
2+
import { IconBase, Icon, IconWeight } from "..";
33

44
const weights = new Map<IconWeight, ReactElement>([
55
[

example/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
"preserveConstEnums": true,
1616
"removeComments": true,
1717
"sourceMap": true,
18-
"strictNullChecks": true,
19-
},
18+
"strictNullChecks": true
19+
}
2020
}

scripts/assemble.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,12 @@ const I: Icon = forwardRef((props, ref) => (
9595
<IconBase ref={ref} {...props} weights={weights} />
9696
));
9797
98-
I.displayName = "${name}";
99-
export { I as ${name}${
100-
!!ALIASES[key] ? `, I as ${pascalize(ALIASES[key])}` : ""
98+
I.displayName = "${name}Icon";
99+
100+
/** @deprecated Use ${name}Icon */
101+
export const ${name} = I;
102+
export { I as ${name}Icon${
103+
!!ALIASES[key] ? `, I as ${pascalize(ALIASES[key])}Icon` : ""
101104
} }
102105
`;
103106

@@ -113,9 +116,12 @@ const I: Icon = forwardRef((props, ref) => (
113116
<SSRBase ref={ref} {...props} weights={weights} />
114117
));
115118
116-
I.displayName = "${name}";
117-
export { I as ${name}${
118-
!!ALIASES[key] ? `, I as ${pascalize(ALIASES[key])}` : ""
119+
I.displayName = "${name}Icon";
120+
121+
/** @deprecated Use ${name}Icon */
122+
export const ${name} = I;
123+
export { I as ${name}Icon${
124+
!!ALIASES[key] ? `, I as ${pascalize(ALIASES[key])}Icon` : ""
119125
} }
120126
`;
121127

@@ -189,7 +195,7 @@ export * from "./${name}";
189195
}
190196
}
191197

192-
function pascalize(str) {
198+
function pascalize(str: string) {
193199
return str
194200
.split("-")
195201
.map((substr) => substr.replace(/^\w/, (c) => c.toUpperCase()))

src/csr/Acorn.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@ const I: Icon = forwardRef((props, ref) => (
1616
<IconBase ref={ref} {...props} weights={weights} />
1717
));
1818

19-
I.displayName = "Acorn";
20-
export { I as Acorn };
19+
I.displayName = "AcornIcon";
20+
21+
/** @deprecated Use AcornIcon */
22+
export const Acorn = I;
23+
export { I as AcornIcon };

src/csr/AddressBook.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@ const I: Icon = forwardRef((props, ref) => (
1616
<IconBase ref={ref} {...props} weights={weights} />
1717
));
1818

19-
I.displayName = "AddressBook";
20-
export { I as AddressBook };
19+
I.displayName = "AddressBookIcon";
20+
21+
/** @deprecated Use AddressBookIcon */
22+
export const AddressBook = I;
23+
export { I as AddressBookIcon };

src/csr/AddressBookTabs.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@ const I: Icon = forwardRef((props, ref) => (
1616
<IconBase ref={ref} {...props} weights={weights} />
1717
));
1818

19-
I.displayName = "AddressBookTabs";
20-
export { I as AddressBookTabs };
19+
I.displayName = "AddressBookTabsIcon";
20+
21+
/** @deprecated Use AddressBookTabsIcon */
22+
export const AddressBookTabs = I;
23+
export { I as AddressBookTabsIcon };

src/csr/AirTrafficControl.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@ const I: Icon = forwardRef((props, ref) => (
1616
<IconBase ref={ref} {...props} weights={weights} />
1717
));
1818

19-
I.displayName = "AirTrafficControl";
20-
export { I as AirTrafficControl };
19+
I.displayName = "AirTrafficControlIcon";
20+
21+
/** @deprecated Use AirTrafficControlIcon */
22+
export const AirTrafficControl = I;
23+
export { I as AirTrafficControlIcon };

0 commit comments

Comments
 (0)