Skip to content

Commit 84e8574

Browse files
committed
Rename Sprite component to Icon
1 parent 17d7802 commit 84e8574

25 files changed

Lines changed: 88 additions & 82 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ dist/
44
# generated types
55
.astro/
66
.vercel/
7-
src/components/GeneratedSprites.astro
87

98
# test output
109
/test-results/

README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -369,27 +369,23 @@ losst.pro has a modal that pops up for fixing mistakes:
369369
- astro-navigation
370370
- astro-webfinger (Mastodon)
371371

372-
## Sprites
372+
## Icons
373373

374374
Icons are managed through the `astro-icon` system with SVG files stored in `src/icons/`.
375375

376376
**Adding a new icon:**
377377

378-
1. Add the SVG file to `src/icons/` (use kebab-case naming)
379-
2. Update `src/components/Sprite/sprites.ts` to add the icon name to the `SpriteName` union type
380-
3. Use the icon with the `Sprite` component
378+
See [docs](src/icons/README.md).
381379

382380
**Usage:**
383381

384382
```typescript
385383
---
386-
import Sprite from 'components/Sprite.astro'
384+
import Icon from 'components/Icon.astro'
387385
---
388-
<Sprite name="fileName" class="customClassName"/>
386+
<Icon name="fileName" class="customClassName"/>
389387
```
390388

391-
See `src/icons/README.md` for detailed icon documentation.
392-
393389
## Pages
394390

395391
Any `.astro`, `.md`, or `.mdx` file anywhere within the `src/pages/` folder automatically became a page on your site.

src/components/Button/index.astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
import type { ButtonProps } from '@components/Button/server'
33
import { buildButtonClassList, resolveAriaLabel } from '@components/Button/server'
4-
import Sprite from '@components/Sprite/index.astro'
4+
import Icon from '@components/Icon/index.astro'
55
import styles from './button.module.css'
66
77
type Props = ButtonProps
@@ -48,10 +48,10 @@ const ariaAttributes = computedAriaLabel ? { 'aria-label': computedAriaLabel } :
4848
>
4949
{
5050
icon && (iconPosition === 'left' || iconPosition === 'only') && (
51-
<Sprite name={icon} size={defaultIconSize} class={text ? 'mr-2' : ''} />
51+
<Icon name={icon} size={defaultIconSize} class={text ? 'mr-2' : ''} />
5252
)
5353
}
5454
{text && <span>{text}</span>}
55-
{icon && iconPosition === 'right' && <Sprite name={icon} size={defaultIconSize} class="ml-2" />}
55+
{icon && iconPosition === 'right' && <Icon name={icon} size={defaultIconSize} class="ml-2" />}
5656
<slot />
5757
</button>

src/components/Button/server/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { SpriteName } from '@components/Sprite/sprites'
1+
import type { IconName } from '@components/Icon/@types/icons'
22

33
export type ButtonVariant = 'primary' | 'secondary' | 'twitter' | 'success' | 'warning' | 'icon'
44
export type ButtonSize = 'small' | 'medium' | 'large'
@@ -17,7 +17,7 @@ export interface ButtonProps {
1717
id?: Optional<string>
1818
ariaLabel?: Optional<string>
1919
onClick?: Optional<string>
20-
icon?: Optional<SpriteName>
20+
icon?: Optional<IconName>
2121
iconPosition?: Optional<IconPosition>
2222
iconSize?: Optional<number | string>
2323
}
@@ -86,7 +86,7 @@ export function buildButtonClassList({
8686
export interface ButtonLabelOptions {
8787
text?: Optional<string>
8888
ariaLabel?: Optional<string>
89-
icon?: Optional<SpriteName>
89+
icon?: Optional<IconName>
9090
iconPosition?: Optional<IconPosition>
9191
}
9292

@@ -110,7 +110,7 @@ export function resolveAriaLabel({ text, ariaLabel, icon, iconPosition }: Button
110110
return undefined
111111
}
112112

113-
function humanizeIconName(icon: SpriteName): string {
113+
function humanizeIconName(icon: IconName): string {
114114
return icon
115115
.replace(/[-_]+/g, ' ')
116116
.replace(/\b\w/g, (char) => char.toUpperCase())

src/components/Callout/index.astro

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
import Sprite from '@components/Sprite/index.astro'
3-
import type { SpriteName } from '@components/Sprite/sprites'
2+
import Icon from '@components/Icon/index.astro'
3+
import type { IconName } from '@components/Icon/@types/icons'
44
55
export interface Props {
66
type?: 'warning' | 'action' | 'tip' | 'info' | 'note'
@@ -9,7 +9,7 @@ export interface Props {
99
const { type = 'info' } = Astro.props
1010
1111
// Map callout types to sprite icons
12-
const iconMap: Record<string, SpriteName> = {
12+
const iconMap: Record<string, IconName> = {
1313
warning: 'warning',
1414
action: 'warning',
1515
info: 'info',
@@ -35,7 +35,7 @@ const borderColorMap: Record<string, string> = {
3535
note: 'var(--color-text)',
3636
}
3737
38-
const icon: SpriteName = iconMap[type] as SpriteName
38+
const icon: IconName = iconMap[type] as IconName
3939
const backgroundColor = backgroundColorMap[type]
4040
const borderColor = borderColorMap[type]
4141
---
@@ -61,7 +61,7 @@ const borderColor = borderColorMap[type]
6161
<div
6262
class="callout__icon bg-bg rounded-full absolute left-0 top-0 ml-0.5 p-1 -translate-x-1/2 -translate-y-1/2"
6363
>
64-
<Sprite name={icon} size={20} />
64+
<Icon name={icon} size={20} />
6565
</div>
6666

6767
<div class="callout__content border-l-4 p-4 md:pl-8">

src/components/Consent/Banner/index.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
import { Image } from 'astro:assets'
3-
import Sprite from '@components/Sprite/index.astro'
3+
import Icon from '@components/Icon/index.astro'
44
import Button from '@components/Button/index.astro'
55
import CookieSvg from '@assets/images/site/cookie.svg'
66
---
@@ -22,7 +22,7 @@ import CookieSvg from '@assets/images/site/cookie.svg'
2222
aria-label="close cookie consent dialog"
2323
class="consent-modal__close-btn bg-secondary border-none text-text flex p-1.5 absolute top-0 right-0 transition-all duration-150 ease-in-out hover:bg-secondary-offset hover:text-text focus:bg-secondary-offset focus:text-text focus:outline-none z-10"
2424
>
25-
<Sprite name="close" class="h-8 w-8" />
25+
<Icon name="close" class="h-8 w-8" />
2626
</button>
2727

2828
<!-- Modal content container with page column constraints -->

src/components/Consent/Preferences/index.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
import { Image } from 'astro:assets'
3-
import Sprite from '@components/Sprite/index.astro'
3+
import Icon from '@components/Icon/index.astro'
44
import logoSvg from '@assets/images/site/logo.svg'
55
---
66

@@ -30,7 +30,7 @@ import logoSvg from '@assets/images/site/logo.svg'
3030
data-testid="consent-preferences-close"
3131
aria-label="Close privacy preferences dialog"
3232
>
33-
<Sprite name="close" />
33+
<Icon name="close" />
3434
</button>
3535
</div>
3636

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
declare const styles: {
2+
readonly footerGrid: string
3+
readonly footerContact: string
4+
readonly footerSocial: string
5+
readonly footerBottomRow: string
6+
readonly footerCopyright: string
7+
readonly footerHireMe: string
8+
readonly footerHireMeAnchor: string
9+
readonly footerFeedIcon: string
10+
}
11+
12+
export default styles

src/components/Footer/index.astro

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { Image } from 'astro:assets'
33
import contactData from '@content/contact.json'
44
import { absoluteUrl } from '@components/scripts/utils'
55
import { formatPhoneNumber } from '@components/Footer/server'
6-
import Sprite from '@components/Sprite/index.astro'
7-
import type { SpriteName } from '@components/Sprite/sprites'
6+
import Icon from '@components/Icon/index.astro'
7+
import type { IconName } from '@components/Icon/@types/icons'
88
import AuthorAvatar from '@assets/images/avatars/kevin-brown.webp'
99
import styles from './footer.module.css'
1010
@@ -83,7 +83,7 @@ const year = new Date().getFullYear()
8383
class="flex items-baseline uppercase text-text underline decoration-dotted decoration-text underline-offset-4 hover:text-secondary hover:decoration-secondary focus:text-secondary focus:decoration-secondary focus:outline-none [&_.icon]:fill-text! [&_.icon]:stroke-text! hover:[&_.icon]:fill-secondary! hover:[&_.icon]:stroke-secondary! focus:[&_.icon]:fill-secondary! focus:[&_.icon]:stroke-secondary!"
8484
>
8585
<span class="[&_.icon]:h-4 [&_.icon]:w-4">
86-
<Sprite name={social.iconName as SpriteName} variant="inherit" />
86+
<Icon name={social.iconName as IconName} variant="inherit" />
8787
</span>
8888
<span class="footer-social-platform ml-2 mt-4">{social.displayName}</span>
8989
</a>
@@ -131,7 +131,7 @@ const year = new Date().getFullYear()
131131
class="text-text [&_.icon]:fill-text! [&_.icon]:stroke-text! [&_.icon]:h-10 [&_.icon]:w-10 hover:[&_.icon]:fill-secondary! hover:[&_.icon]:stroke-secondary! focus:[&_.icon]:fill-secondary! focus:[&_.icon]:stroke-secondary! focus:outline-none"
132132
>
133133
<span class="sr-only">RSS Feed</span>
134-
<span><Sprite name="feed" variant="inherit" /></span>
134+
<span><Icon name="feed" variant="inherit" /></span>
135135
</a>
136136
</span>
137137
</div>

src/components/Hero/Default/content.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Hero Content Column - Default Variant
44
*/
5-
import Sprite from '@components/Sprite/index.astro'
5+
import Icon from '@components/Icon/index.astro'
66
77
export interface Props {
88
pretitle?: string
@@ -51,7 +51,7 @@ const { pretitle, title, benefits, primaryLink, secondaryLink } = Astro.props as
5151
{benefits.map(benefit => (
5252
<li class="flex items-start gap-3">
5353
<span class="shrink-0 w-6 h-6 text-success [&_.icon]:w-6 [&_.icon]:h-6 [&_.icon]:stroke-current">
54-
<Sprite name="check" />
54+
<Icon name="check" />
5555
</span>
5656
<span class="text-base md:text-lg text-text">
5757
<strong class="font-bold text-primary">{benefit.highlight}</strong>{' '}

0 commit comments

Comments
 (0)