mirror of
https://github.com/simple-icons/simple-icons.git
synced 2025-01-25 01:32:58 +02:00
deprecate index (#7453)
This commit is contained in:
parent
665b82590d
commit
986589c34c
27
README.md
27
README.md
@ -49,20 +49,7 @@ The icons are also available through our npm package. To install, simply run:
|
||||
npm install simple-icons
|
||||
```
|
||||
|
||||
The API can then be used as follows, where `[ICON SLUG]` is replaced by a [slug]:
|
||||
|
||||
```javascript
|
||||
const simpleIcons = require('simple-icons');
|
||||
|
||||
// Get a specific icon by its slug as:
|
||||
// simpleIcons.Get('[ICON SLUG]');
|
||||
|
||||
// For example:
|
||||
const icon = simpleIcons.Get('simpleicons');
|
||||
|
||||
```
|
||||
|
||||
Alternatively, you can also import all icons from a single file, where `[ICON SLUG]` is replaced by a capitalized [slug]. We highly recommend using a bundler that can tree shake such as [webpack](https://webpack.js.org/) to remove the unused icon code:
|
||||
All icons are imported from a single file, where `[ICON SLUG]` is replaced by a capitalized [slug]. We highly recommend using a bundler that can tree shake such as [webpack](https://webpack.js.org/) to remove the unused icon code:
|
||||
```javascript
|
||||
// Import a specific icon by its slug as:
|
||||
// import { si[ICON SLUG] } from 'simple-icons/icons'
|
||||
@ -99,18 +86,6 @@ NOTE: the `license` entry will be `undefined` if we do not yet have license data
|
||||
*/
|
||||
```
|
||||
|
||||
Lastly, the `simpleIcons` object is also enumerable.
|
||||
This is useful if you want to do a computation on every icon:
|
||||
|
||||
```javascript
|
||||
const simpleIcons = require('simple-icons');
|
||||
|
||||
for (const iconSlug in simpleIcons) {
|
||||
const icon = simpleIcons.Get(iconSlug);
|
||||
// do stuff
|
||||
}
|
||||
```
|
||||
|
||||
#### TypeScript Usage <img src="https://raw.githubusercontent.com/simple-icons/simple-icons/develop/icons/typescript.svg#gh-light-mode-only" alt="Typescript" align=left width=19 height=19><img src="https://raw.githubusercontent.com/simple-icons/simple-icons/develop/assets/readme/typescript-white.svg#gh-dark-mode-only" alt="Typescript" align=left width=19 height=19>
|
||||
|
||||
Type definitions are bundled with the package.
|
||||
|
3
index.d.ts
vendored
3
index.d.ts
vendored
@ -14,6 +14,9 @@ export interface SimpleIcon {
|
||||
| undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated The `simple-icons` entrypoint will be removed in the next major. Please switch to using `import * as icons from "simple-icons/icons"` if you need an object with all the icons.
|
||||
*/
|
||||
declare const icons: Record<string, SimpleIcon> & {
|
||||
Get(name: string): SimpleIcon;
|
||||
};
|
||||
|
@ -1,3 +1,5 @@
|
||||
console.warn('Deprecation warning: The `simple-icons` entrypoint will be removed in the next major. Please switch to using `import * as icons from "simple-icons/icons"` if you need an object with all the icons.')
|
||||
|
||||
var icons = {%s};
|
||||
|
||||
Object.defineProperty(icons, "Get", {
|
||||
|
Loading…
x
Reference in New Issue
Block a user