Skip to content

Commit

Permalink
Merge branch 'main' into studio/layers
Browse files Browse the repository at this point in the history
  • Loading branch information
jguddas authored Nov 9, 2024
2 parents c715eb5 + f93beca commit ba0d9c4
Show file tree
Hide file tree
Showing 64 changed files with 3,475 additions and 3,415 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ outlined
packages/**/src/icons/*.js
packages/**/src/icons/*.ts
packages/**/src/icons/*.tsx
packages/**/src/aliases/*.ts
packages/**/src/aliases.ts
!packages/**/src/aliases/index.ts
packages/**/src/dynamicIconImports.ts
packages/**/dynamicIconImports.js
packages/**/dynamicIconImports.d.ts
Expand Down
Empty file added comment-markup.md
Empty file.
4 changes: 4 additions & 0 deletions docs/.vitepress/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ const sidebar: UserConfig<DefaultTheme.Config>['themeConfig']['sidebar'] = {
text: 'Filled icons',
link: '/guide/advanced/filled-icons',
},
{
text: 'Aliased Names',
link: '/guide/advanced/aliased-names',
},
// {
// text: 'Combining icons',
// },
Expand Down
93 changes: 93 additions & 0 deletions docs/guide/advanced/aliased-names.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Aliased Names

Icons can have multiple names for the same icon. This is because we choose to rename some icons to make them more consistent with the rest of the icon set, or the name was not generic. For example, the `edit-2` icon is renamed to `pen` to make the name more generic, since it is just a pen icon.

Beside aliases names lucide also includes prefixed and suffixed names to use within your project. This is to prevent import name collisions with other libraries or your own code.

```tsx
// These are all the same icon
import {
Home,
HomeIcon,
LucideHome,
} from "lucide-react";
```

## Choosing import name style

To be consistent in your imports or want to change the autocompletion of Lucide icons in your IDE there an option to able the choose the import name style you want.

This can be done by creating a custom module declaration file to override the lucide imports and turning off the autocomplete in your IDE.

### Turn off autocomplete in your IDE

```json [.vscode/settings.json]
{
"typescript.preferences.autoImportFileExcludePatterns": [
"lucide-react", // or
"lucide-preact", // or
"lucide-react-native", // or
"lucide-vue-next",
]
}
```

### Create a custom module declaration file

Only available for `lucide-react`, `lucide-preact`, `lucide-react-native`, `lucide-vue-next` package.
This will enable you to choose the import name style you want to use in your project.

::: code-group

```ts [React]
declare module "lucide-react" {
// Prefixed import names
export * from "lucide-react/dist/lucide-react.prefixed";
// or
// Suffixed import names
export * from "lucide-react/dist/lucide-react.suffixed";
}
```

```ts [Vue]
declare module "lucide-vue-next" {
// Prefixed import names
export * from "lucide-vue-next/dist/lucide-vue-next.prefixed";
// or
// Suffixed import names
export * from "lucide-vue-next/dist/lucide-vue-next.suffixed";
}
```

```ts [Preact]
declare module "lucide-preact" {
// Prefixed import names
export * from "lucide-preact/dist/lucide-preact.prefixed";
// or
// Suffixed import names
export * from "lucide-preact/dist/lucide-preact.suffixed";
}
```

```ts [React Native]
declare module "lucide-react-native" {
// Prefixed import names
export * from "lucide-react-native/dist/lucide-react-native.prefixed";
// or
// Suffixed import names
export * from "lucide-react-native/dist/lucide-react-native.suffixed";
}
```

:::

Place this in your project root or in a folder where your tsconfig.json is located, or locate it in your defined type directory.
Easiest way is to create a `@types` folder in your project root and name the file `[package-name].d.ts`.

### Import name styles

| Import Style | Available imports | Declaration file import |
| ------------- | --------------------------- | ----------------------- |
| Default | Home, HomeIcon, LucideHome | |
| Prefixed | LucideHome | [package].prefixed |
| Suffixed | HomeIcon | [package].suffixed |
13 changes: 8 additions & 5 deletions docs/guide/packages/lucide-angular.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,17 @@ export class AppModule { }
or using standalone version:

```js
import { Component } from '@angular/core';
import { LucideAngularModule, FileIcon } from 'lucide-angular';

@NgModule({
imports: [
LucideAngularModule
]
@Component({
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html',
styleUrl: './app.component.scss',
imports: [LucideAngularModule]
})
export class AppModule {
export class AppComponent {
readonly FileIcon = FileIcon;
}
```
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/packages/lucide-svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ For faster builds and load times, you can import icons directly from the `lucide

```svelte
<script>
import AlertCircle from 'lucide-svelte/icons/alert-circle';
import CircleAlert from 'lucide-svelte/icons/circle-alert';
</script>
<AlertCircle color="#ff3e98" />
<CircleAlert color="#ff3e98" />
```

## Props
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@lucide/build-icons": "workspace:*",
"@lucide/helpers": "workspace:*",
"@lucide/shared": "workspace:*",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-replace": "^6.0.1",
"@types/semver": "^7.5.3",
"h3": "^1.8.0",
"nitropack": "2.8.1",
Expand Down
3 changes: 2 additions & 1 deletion icons/file-music.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"$schema": "../icon.schema.json",
"contributors": [
"danielbayley"
"danielbayley",
"jguddas"
],
"tags": [
"audio",
Expand Down
4 changes: 2 additions & 2 deletions icons/file-music.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion icons/glass-water.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions icons/grid-2x2-plus.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@
"design",
"shapes",
"maths"
],
"aliases": [
"grid-2-x-2-plus"
]
}
3 changes: 2 additions & 1 deletion icons/slice.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"$schema": "../icon.schema.json",
"contributors": [
"karsa-mistmere",
"danielbayley"
"danielbayley",
"jguddas"
],
"tags": [
"cutter",
Expand Down
3 changes: 1 addition & 2 deletions icons/slice.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions icons/undo-dot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions icons/wind-arrow-down.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "../icon.schema.json",
"contributors": [
"colebemis",
"csandman",
"ericfennis",
"jamiemlaw"
],
"tags": [
"weather",
"air",
"pressure",
"blow"
],
"categories": [
"weather",
"sustainability"
]
}
16 changes: 16 additions & 0 deletions icons/wind-arrow-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions icons/wind.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"postinstall": "husky install",
"lint:es": "eslint .",
"lint:format": "prettier \"**/*.{js,mjs,ts,jsx,tsx,html,css,scss,json,yml,yaml}\" --check",
"lint:format-fix": "prettier \"**/*.{js,mjs,ts,jsx,tsx,html,css,scss,json,yml,yaml}\" --write",
"lint:json:icons": "ajv --spec=draft2020 -s icon.schema.json -d 'icons/*.json' > /dev/null",
"lint:json:categories": "ajv --spec=draft2020 -s category.schema.json -d 'categories/*.json' > /dev/null",
"lint:json": "pnpm run lint:json:icons && pnpm run lint:json:categories",
Expand All @@ -43,26 +44,26 @@
"@html-eslint/eslint-plugin": "^0.19.1",
"@html-eslint/parser": "^0.19.1",
"@octokit/rest": "^19.0.13",
"@types/yargs": "^17.0.32",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"@types/yargs": "^17.0.33",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"ajv-cli": "^5.0.0",
"eslint": "^8.56.0",
"eslint": "^8.57.1",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-config-prettier": "^8.10.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-import-resolver-custom-alias": "^1.3.2",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-import": "^2.31.0",
"husky": "^8.0.3",
"lint-staged": "^13.3.0",
"minimist": "^1.2.8",
"p-memoize": "^7.1.1",
"prettier": "3.2.4",
"semver": "^7.5.4",
"simple-git": "^3.25.0",
"svgo": "^3.1.0",
"semver": "^7.6.3",
"simple-git": "^3.27.0",
"svgo": "^3.3.2",
"svgson": "^5.3.1",
"yargs": "^17.7.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/lucide-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"build": "pnpm clean && pnpm copy:license && pnpm build:icons && pnpm build:ng",
"copy:license": "cp ../../LICENSE ./LICENSE",
"clean": "rm -rf dist && rm -rf ./src/icons/*.ts",
"build:icons": "build-icons --output=./src --templateSrc=./scripts/exportTemplate.mjs --renderUniqueKey --withAliases --aliasesFileExtension=.ts --iconFileExtension=.ts --exportFileName=lucide-icons.ts",
"build:icons": "build-icons --output=./src --templateSrc=./scripts/exportTemplate.mjs --renderUniqueKey --withAliases --aliasNamesOnly --aliasesFileExtension=.ts --iconFileExtension=.ts --exportFileName=lucide-icons.ts",
"build:ng": "ng build --configuration production",
"test": "ng test --no-watch --no-progress --browsers=ChromeHeadlessCI",
"test:watch": "ng test",
Expand Down
1 change: 1 addition & 0 deletions packages/lucide-angular/src/aliases/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './aliases';
2 changes: 1 addition & 1 deletion packages/lucide-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"rollup": "^4.22.4",
"rollup-plugin-dts": "^6.1.0",
"typescript": "^5.3.3",
"vite": "5.0.13",
"vite": "5.1.8",
"vitest": "^1.1.1"
},
"peerDependencies": {
Expand Down
20 changes: 20 additions & 0 deletions packages/lucide-preact/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,25 @@ export default [
],
plugins: [dts()],
},
{
input: `src/${outputFileName}.suffixed.ts`,
output: [
{
file: `dist/${outputFileName}.suffixed.d.ts`,
format: 'es',
},
],
plugins: [dts()],
},
{
input: `src/${outputFileName}.prefixed.ts`,
output: [
{
file: `dist/${outputFileName}.prefixed.d.ts`,
format: 'es',
},
],
plugins: [dts()],
},
...configs,
];
3 changes: 3 additions & 0 deletions packages/lucide-preact/src/aliases/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './aliases';
export * from './prefixed';
export * from './suffixed';
7 changes: 7 additions & 0 deletions packages/lucide-preact/src/lucide-preact.prefixed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export * from './icons';
export * as icons from './icons';
export * from './aliases/prefixed';
export * from './types';

export { default as createLucideIcon } from './createLucideIcon';
export { default as Icon } from './Icon';
7 changes: 7 additions & 0 deletions packages/lucide-preact/src/lucide-preact.suffixed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export * from './icons';
export * as icons from './icons';
export * from './aliases/suffixed';
export * from './types';

export { default as createLucideIcon } from './createLucideIcon';
export { default as Icon } from './Icon';
6 changes: 3 additions & 3 deletions packages/lucide-react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@
"jest-serializer-html": "^7.1.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-native": "^0.73.1",
"react-native-svg": "^15.0.0",
"react-native": "^0.76.0",
"react-native-svg": "^15.8.0",
"rollup": "^4.22.4",
"rollup-plugin-dts": "^6.1.0",
"typescript": "^4.8.4",
"vite": "5.0.13",
"vite": "5.1.8",
"vitest": "^1.1.1"
},
"peerDependencies": {
Expand Down
Loading

0 comments on commit ba0d9c4

Please sign in to comment.