From be8f2ca5685c4ed87131033f2bbc3b81cab3b94a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ev=C5=BEen=20Gasta?= <46690189+gastoner@users.noreply.github.com> Date: Tue, 27 Jan 2026 07:21:51 +0100 Subject: [PATCH] feat: added icon examples to code guidelines (#15673) * feat: added icon examples to code guideliens Signed-off-by: Evzen Gasta * chore: applied suggestions Signed-off-by: Evzen Gasta * chore: removed unused imports Signed-off-by: Evzen Gasta --------- Signed-off-by: Evzen Gasta --- CODE-GUIDELINES.md | 97 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/CODE-GUIDELINES.md b/CODE-GUIDELINES.md index aac1f175960..72cb19d5927 100644 --- a/CODE-GUIDELINES.md +++ b/CODE-GUIDELINES.md @@ -65,6 +65,103 @@ async function onButtonClicked(object: Object): Promise { {/each} ``` +### Usage of Icon component + +The Icon component is a unified icon wrapper that supports multiple icon formats: + +- FontAwesome `IconDefinition` object uses `` from `svelte-fa` +- Font class icons strings starting with fas fa-, far fa-, fab fa- or ending with -icon Renders as `` with CSS classes +- Data URI images strings starting with data:image/ Renders as `` +- Svelte Components + +✅ **Use this pattern:** + +```ts + + + + +``` + +🚫 **Instead of:** + +```ts + + + + + +``` + +Use typescript imports rather than string definitions + +✅ **Use this pattern:** + +```ts + + + +``` + +🚫 **Instead of:** + +```ts + + + +``` + +Another example: + +✅ **Use this pattern:** + +```ts + + + +``` + +🚫 **Instead of:** + +```ts + + +{#if isFontAwesomeIcon(icon)} + +{:else} + {@const IconComponent = icon} + +{/if} +``` + ### Using async/await in expressions As of Svelte 5.36+, you can use the `await` keyword directly inside component expressions in three places: at the top level of the component's `