HTML

html/project-icons

Icons use the project's generated icon classes (its icon classes), not separate SVG image files.

drobnastatycznefe-images

W projekcie raport i explain zastępują przykład w nawiasach klamrowych własnym narzędziem projektu.

Dlaczego

This project builds its icons into CSS classes ({{icon-classes.tool|an icon build step}}), so one cached file serves every icon and they share size and colour rules. An <img src="…/icons/x.svg"> bypasses that build: another request per icon, an icon that does not follow the text colour, and a second way to do the same thing. The rule runs only in projects where such a build was detected.

Poprawka

Use the generated class: <i class="icon-<name>" aria-hidden="true"></i> and give the control a text label (visible, or aria-label on the button). A new icon is added as an SVG in the icon source folder and the build is run again.

Przykłady

<!-- bad -->
<button type="button"><img src="/assets/icons/close.svg" alt="Close"></button>
<!-- good -->
<button type="button" aria-label="Close"><i class="icon-close" aria-hidden="true"></i></button>

Źródła

Fakty

Identyfikator
html/project-icons
Waga
drobna
Sprawdzanie
statyczne sprawdzane w kodzie źródłowym przez audit
Dotyczy plików
html angular vue svelte astro jsx
Wymaga narzędzia projektu
icon-classes
Uczy jej skill
fe-images Images and media delivery
Od wersji
0.1.0

Plik reguły na GitHubie

Przeczytaj w terminalu

npx github:dawidolko/frontend-skills explain html/project-icons