Skip to content

Commit

Permalink
Tabler Icons v3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pierreavn committed Mar 25, 2024
1 parent 8fbd22c commit 8cbdbc3
Show file tree
Hide file tree
Showing 5,279 changed files with 5,984 additions and 48,921 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# angular-tabler-icons

[![tabler-icons-version](https://img.shields.io/badge/Tabler%20Icons-v2.47.0-%23206bc4?style=flat-square)](https://tabler-icons.io)
[![tabler-icons-version](https://img.shields.io/badge/Tabler%20Icons-v3.1.0-%23206bc4?style=flat-square)](https://tabler.io/icons)
[![license](https://img.shields.io/npm/l/angular-tabler-icons.svg?style=flat-square)]()
[![downloads](https://img.shields.io/npm/dm/angular-tabler-icons?style=flat-square)]()

## Description

This package allows you to use the [Tabler Icons](https://tabler-icons.io/) in your angular applications. Tabler Icons is a set of free MIT-licensed high-quality SVG icons for you to use in your web projects. Each icon is designed on a 24x24 grid and a 2px stroke.
This package allows you to use the [Tabler Icons](https://tabler.io/icons) in your angular applications. Tabler Icons is a set of free MIT-licensed high-quality SVG icons for you to use in your web projects. Each icon is designed on a 24x24 grid and a 2px stroke.

Inspired by [angular-feather](https://github.com/michaelbazos/angular-feather), thank you to the author.

Expand Down Expand Up @@ -106,14 +106,15 @@ After importing the _IconsModule_ in your feature or shared module, use the icon
```html
<i-tabler name="camera"></i-tabler>
<i-tabler name="heart" style="color: red;"></i-tabler>
<i-tabler name="heart-filled" style="color: red;"></i-tabler>
<i-tabler name="brand-github" class="someclass"></i-tabler>
```

## Available icons

List of available icons: https://tabler-icons.io/
List of available icons: https://tabler.io/icons

This version includes **Tabler Icons v2.47.0**, see [changelog](https://tabler-icons.io/changelog) to know which icons are available.
This version includes **Tabler Icons v3.1.0**, see [changelog](https://tabler.io/icons/changelog) to know which icons are available.


## Styling icons
Expand Down
44 changes: 24 additions & 20 deletions generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ const NG_PROJECT = 'projects/angular-tabler-icons';
const PATHS = {

// Path to Tabler SVG icons
ICONS_SRC: 'node_modules/@tabler/icons/icons',
ICONS: [
{ src: 'node_modules/@tabler/icons/icons/outline', attribute: '' },
{ src: 'node_modules/@tabler/icons/icons/filled', attribute: 'fill="currentColor" stroke="currentColor"', suffix: '-filled' },
],

// Path to Angular lib project
ICONS_DEST: `${NG_PROJECT}/icons/svg`,
Expand Down Expand Up @@ -41,26 +44,27 @@ async function generate() {
await fs.mkdir(PATHS.ICONS_DEST);

// Generate each icon file
const sourceIconFiles = await fs.readdir(PATHS.ICONS_SRC);
let i = 0;
for (const filename of sourceIconFiles) {
if (filename === ".DS_Store") {
continue;
for (const icons of PATHS.ICONS) {
const sourceIconFiles = await fs.readdir(icons.src);
for (const filename of sourceIconFiles) {
if (!filename.endsWith('.svg')) {
continue;
}

const iconNameHyphens = stripExtension(filename) + (icons.suffix ?? '');
const iconNameCamel = uppercamelcase('icon-' + iconNameHyphens);

const svgRaw = await fs.readFile(`${icons.src}/${filename}`, 'utf-8');
const svg = svgRaw.replaceAll('\n', '').replace(/<svg [^>]*>/, `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" ${icons.attribute}>`);
const component = `export const ${iconNameCamel} = \`${svg}\``;

await fs.writeFile(`${PATHS.ICONS_DEST}/${iconNameHyphens}.ts`, component, 'utf-8');

await fs.appendFile(
PATHS.INDEX_FILE,
`export { ${iconNameCamel} } from './svg/${iconNameHyphens}';\n`
);
}

const iconNameHyphens = stripExtension(filename);
const iconNameCamel = uppercamelcase('icon-' + iconNameHyphens);

const svgRaw = await fs.readFile(`${PATHS.ICONS_SRC}/${filename}`, 'utf-8');
const svg = svgRaw.replace(/<svg .*>/, `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">`);
const component = `export const ${iconNameCamel} = \`${svg}\``;

await fs.writeFile(`${PATHS.ICONS_DEST}/${iconNameHyphens}.ts`, component, 'utf-8');

await fs.appendFile(
PATHS.INDEX_FILE,
`export { ${iconNameCamel} } from './svg/${iconNameHyphens}';\n`
);
}

console.log('Done!');
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "workspace",
"version": "2.40.1",
"version": "3.1.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
Expand All @@ -21,7 +21,7 @@
"@angular/platform-browser": "^14.3.0",
"@angular/platform-browser-dynamic": "^14.3.0",
"@angular/router": "^14.3.0",
"@tabler/icons": "2.47.0",
"@tabler/icons": "3.1",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.11.4"
Expand Down
Loading

0 comments on commit 8cbdbc3

Please sign in to comment.