mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-13 12:39:14 +00:00
Compare commits
3 Commits
native-cod
...
support-fa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67d8962e32 | ||
|
|
714250cc96 | ||
|
|
ac366987f3 |
@@ -1,52 +1,56 @@
|
||||
import { getKitCode } from '../../utilities/base-path.js';
|
||||
import type { IconLibrary } from './library.js';
|
||||
|
||||
type IconFamily = 'classic' | 'duotone' | 'sharp' | 'sharp-duotone';
|
||||
type IconVariant = 'solid' | 'regular' | 'light' | 'thin' | 'brands';
|
||||
|
||||
type IconLookup = {
|
||||
[key in IconFamily]: Partial<Record<IconVariant, string>>;
|
||||
};
|
||||
|
||||
const lookup: IconLookup = {
|
||||
classic: {
|
||||
solid: 'solid',
|
||||
regular: 'regular',
|
||||
light: 'light',
|
||||
thin: 'thin',
|
||||
brands: 'brands',
|
||||
},
|
||||
duotone: {
|
||||
solid: 'duotone',
|
||||
regular: 'duotone-regular',
|
||||
light: 'duotone-light',
|
||||
thin: 'duotone-thin',
|
||||
},
|
||||
sharp: {
|
||||
solid: 'sharp-solid',
|
||||
regular: 'sharp-regular',
|
||||
light: 'sharp-light',
|
||||
thin: 'sharp-thin',
|
||||
},
|
||||
'sharp-duotone': {
|
||||
solid: 'sharp-duotone-solid',
|
||||
regular: 'sharp-duotone-regular',
|
||||
light: 'sharp-duotone-light',
|
||||
thin: 'sharp-duotone-thin',
|
||||
},
|
||||
};
|
||||
|
||||
const version = '6.7.2';
|
||||
|
||||
function getIconUrl(name: string, family: string, variant: string) {
|
||||
const kitCode = getKitCode();
|
||||
// TODO this is not a good indicator of if the Kit is pro
|
||||
const isPro = kitCode.length > 0;
|
||||
let folder = 'solid';
|
||||
let folder = (lookup as Record<string, Record<string, string>>)?.[family]?.[variant] ?? 'solid';
|
||||
|
||||
// Classic
|
||||
if (family === 'classic') {
|
||||
if (variant === 'thin') folder = 'thin';
|
||||
if (variant === 'light') folder = 'light';
|
||||
if (variant === 'regular') folder = 'regular';
|
||||
if (variant === 'solid') folder = 'solid';
|
||||
if (family === 'kit' || family === 'kit-duotone') {
|
||||
return `https://kit.fontawesome.com/${kitCode}/icons/${family}/custom/${name}.svg`;
|
||||
}
|
||||
|
||||
// Sharp
|
||||
if (family === 'sharp') {
|
||||
if (variant === 'thin') folder = 'sharp-thin';
|
||||
if (variant === 'light') folder = 'sharp-light';
|
||||
if (variant === 'regular') folder = 'sharp-regular';
|
||||
if (variant === 'solid') folder = 'sharp-solid';
|
||||
}
|
||||
|
||||
// Duotone
|
||||
if (family === 'duotone') {
|
||||
if (variant === 'thin') folder = 'duotone-thin';
|
||||
if (variant === 'light') folder = 'duotone-light';
|
||||
if (variant === 'regular') folder = 'duotone-regular';
|
||||
if (variant === 'solid') folder = 'duotone';
|
||||
}
|
||||
|
||||
// Sharp Duotone
|
||||
if (family === 'sharp-duotone') {
|
||||
if (variant === 'thin') folder = 'sharp-duotone-thin';
|
||||
if (variant === 'light') folder = 'sharp-duotone-light';
|
||||
if (variant === 'regular') folder = 'sharp-duotone-regular';
|
||||
if (variant === 'solid') folder = 'sharp-duotone-solid';
|
||||
}
|
||||
|
||||
// Brands
|
||||
if (family === 'brands') {
|
||||
folder = 'brands';
|
||||
}
|
||||
|
||||
// Use the default CDN
|
||||
return isPro
|
||||
? `https://ka-p.fontawesome.com/releases/v6.7.2/svgs/${folder}/${name}.svg?token=${encodeURIComponent(kitCode)}`
|
||||
: `https://ka-f.fontawesome.com/releases/v6.7.2/svgs/${folder}/${name}.svg`;
|
||||
? `https://ka-p.fontawesome.com/releases/v${version}/svgs/${folder}/${name}.svg?token=${encodeURIComponent(kitCode)}`
|
||||
: `https://ka-f.fontawesome.com/releases/v${version}/svgs/${folder}/${name}.svg`;
|
||||
}
|
||||
|
||||
const library: IconLibrary = {
|
||||
|
||||
Reference in New Issue
Block a user