Skip to content

Commit

Permalink
refactor: correct resolve path to icons (#8510)
Browse files Browse the repository at this point in the history
Co-authored-by: taiga-family-bot <[email protected]>
  • Loading branch information
splincode and taiga-family-bot authored Aug 13, 2024
1 parent 2d8b6b4 commit 7e2ca6f
Show file tree
Hide file tree
Showing 12,736 changed files with 3,905 additions and 149 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 0 additions & 2 deletions projects/cdk/constants/used-icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ export const TUI_USED_ICONS = [
'@tui.circle-help',
'@tui.x',
'@tui.chevron-right',
'@tui.material',
'@tui.fa',
'@tui.chevron-left',
'@tui.calendar',
'@tui.minus',
Expand Down
25 changes: 4 additions & 21 deletions projects/core/tokens/icon-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,10 @@ export const TUI_ICON_START_RESOLVER = tuiCreateTokenFromFactory<
>(() => {
const path = inject(TUI_ASSETS_PATH);

return (icon) => {
if (!icon || icon.includes('/')) {
return icon;
}

let directory = '';

if (icon.includes('@tui.material')) {
directory = 'material/';
} else if (icon.includes('@tui.fa')) {
directory = 'fontawesome/';
}

const name = icon
.replace(/^@tui./, '')
.replace(/^material.|^fa./, '')
.split('.')
.join('/');

return `${path}/${directory}${name}.svg`;
};
return (icon) =>
!icon || icon.includes('/')
? icon
: `${path}/${icon.replace('@tui.', '').split('.').join('/')}.svg`;
});

export function tuiInjectIconResolver(): TuiStringHandler<string> {
Expand Down
4 changes: 2 additions & 2 deletions projects/demo/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@
{
"glob": "**/*",
"input": "projects/icons-material/src",
"output": "assets/taiga-ui/icons/material"
"output": "assets/taiga-ui/icons/"
},
{
"glob": "**/*",
"input": "projects/icons-fontawesome/src",
"output": "assets/taiga-ui/icons/fontawesome"
"output": "assets/taiga-ui/icons/"
}
],
"baseHref": "./",
Expand Down
2 changes: 1 addition & 1 deletion projects/demo/src/modules/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export const ROUTES: Routes = [
}),
route({
path: DemoRoute.IconsLucide,
loadComponent: async () => import('../icons/lucide'),
loadComponent: async () => import('../icons/icons'),
title: 'Icons',
}),
route({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{
"glob": "**/*",
"input": "node_modules/@taiga-ui/icons-fontawesome/src",
"output": "assets/taiga-ui/icons/fontawesome"
"output": "assets/taiga-ui/icons/"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion projects/demo/src/modules/icons/fontawesome/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import {TuiDemo} from '@demo/utils';
changeDetection,
})
export default class Page {
protected readonly assets = import('./examples/assets.md?raw');
protected readonly assets = import('./assets.md?raw');
}
19 changes: 19 additions & 0 deletions projects/demo/src/modules/icons/icons/assets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```json
{
"projects": {
"demo": {
"architect": {
"build": {
"assets": [
{
"glob": "**/*",
"input": "node_modules/@taiga-ui/icons/src",
"output": "assets/taiga-ui/icons/"
}
]
}
}
}
}
}
```
15 changes: 15 additions & 0 deletions projects/demo/src/modules/icons/icons/examples/1/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<tui-icon icon="@tui.accessibility" />

<img
alt=""
[src]="'@tui.badge-pound-sterling' | tuiIcon"
/>

<tui-icon
icon="@tui.twitter"
[style.color]="'var(--tui-background-accent-1)'"
/>

<tui-icon icon="@tui.square-arrow-out-up-left" />

<tui-icon icon="@tui.gamepad-2" />
4 changes: 4 additions & 0 deletions projects/demo/src/modules/icons/icons/examples/1/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
:host {
display: flex;
gap: 0.625rem;
}
14 changes: 14 additions & 0 deletions projects/demo/src/modules/icons/icons/examples/1/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {Component} from '@angular/core';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiIcon, TuiIconPipe} from '@taiga-ui/core';

@Component({
standalone: true,
imports: [TuiIcon, TuiIconPipe],
templateUrl: './index.html',
styleUrls: ['./index.less'],
encapsulation,
changeDetection,
})
export default class Example {}
47 changes: 47 additions & 0 deletions projects/demo/src/modules/icons/icons/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<tui-doc-page
header="Icons"
package="icons"
type="icons"
>
<ng-template pageTab="Overview">
<h2 class="title">Lucide (default) icons pack</h2>

<p>
Open source theme for Taiga UI uses processed
<a
href="https://lucide.dev/"
rel="noreferrer"
target="_blank"
tuiLink
>
Lucide Icons
</a>
. You can browse all the icons from this pack and find the one that suits you
<a
href="https://lucide.dev/icons/"
rel="noreferrer"
target="_blank"
tuiLink
>
here
</a>
.
</p>

<tui-doc-example
id="basic"
heading="Basic"
[component]="1 | tuiComponent"
[content]="1 | tuiExample"
/>
</ng-template>

<ng-template pageTab="Setup">
<tui-doc-code code="npm i @taiga-ui/icons" />

<tui-doc-code
filename="angular.json"
[code]="assets"
/>
</ng-template>
</tui-doc-page>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {COLORED_ICONS, MONO_ICONS} from './icons.tokens';
changeDetection,
})
export default class Page {
protected readonly assets = import('./assets.md?raw');

protected readonly icons = {
Mono: MONO_ICONS,
Colored: COLORED_ICONS,
Expand Down
59 changes: 0 additions & 59 deletions projects/demo/src/modules/icons/lucide/index.html

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{
"glob": "**/*",
"input": "node_modules/@taiga-ui/icons-material/src",
"output": "assets/taiga-ui/icons/material"
"output": "assets/taiga-ui/icons/"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion projects/demo/src/modules/icons/material/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import {TuiDemo} from '@demo/utils';
changeDetection,
})
export default class Page {
protected readonly assets = import('./examples/assets.md?raw');
protected readonly assets = import('./assets.md?raw');
}
5 changes: 5 additions & 0 deletions projects/demo/used-icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ export const TUI_USED_ICONS = [
'@tui.chevron-up',
'@tui.play',
'@tui.pause',
'@tui.accessibility',
'@tui.badge-pound-sterling',
'@tui.twitter',
'@tui.square-arrow-out-up-left',
'@tui.gamepad-2',
'@tui.electron-mono',
'@tui.maestro-mono',
'@tui.mir-mono',
Expand Down
7 changes: 5 additions & 2 deletions projects/icons-fontawesome/scripts/prepare-icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import path from 'node:path';
'<$1 vector-effect="non-scaling-stroke"',
);

const filePath = path.join(dest, type, filename);
const filePath = path.join(dest, 'fa', type, filename);

fs.mkdirSync(path.dirname(filePath), {recursive: true});
fs.writeFileSync(filePath, content);
Expand Down Expand Up @@ -83,7 +83,10 @@ import path from 'node:path';
].forEach((filename) => {
const filePath = path.join('projects/icons/src', `${filename}.svg`);

fs.writeFileSync(path.join(dest, `${filename}.svg`), filePath);
fs.writeFileSync(
path.join(dest, `${filename}.svg`),
fs.readFileSync(path.join(filePath), 'utf-8'),
);

console.info('copied:', filePath);
});
Expand Down
41 changes: 40 additions & 1 deletion projects/icons-fontawesome/src/ali-pay.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 34 additions & 1 deletion projects/icons-fontawesome/src/amazon-pay.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 7e2ca6f

Please sign in to comment.