Skip to content

Commit cf433af

Browse files
committed
✨ Improve customizability of Icon component
1 parent b8e587e commit cf433af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+309
-66
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ import { Accordion } from 'webcoreui/react'
284284
- [FAQ](https://github.com/Frontendland/webcoreui/tree/main/src/blocks/FAQ)
285285
- [GridWithIcons](https://github.com/Frontendland/webcoreui/tree/main/src/blocks/GridWithIcons)
286286
- [Hero](https://github.com/Frontendland/webcoreui/tree/main/src/blocks/Hero)
287+
- [Icon](https://github.com/Frontendland/webcoreui/tree/main/src/blocks/Icon)
287288
- [IconList](https://github.com/Frontendland/webcoreui/tree/main/src/blocks/IconList)
288289
- [Layout](https://github.com/Frontendland/webcoreui/tree/main/src/blocks/Layout)
289290
- [SEO](https://github.com/Frontendland/webcoreui/tree/main/src/blocks/SEO)

src/blocks/Icon/Icon.astro

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
import IconComponent from '@components/Icon/Icon.astro'
3+
4+
import type { CustomIconProps } from './icon'
5+
import iconSet from './iconSet'
6+
7+
interface Props extends CustomIconProps {}
8+
---
9+
10+
<IconComponent iconSet={iconSet} {...Astro.props} />

src/blocks/Icon/Icon.svelte

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<script lang="ts">
2+
import IconComponent from '@components/Icon/Icon.svelte'
3+
4+
import type { CustomIconProps } from './icon'
5+
import iconSet from './iconSet'
6+
7+
const props: CustomIconProps = $props()
8+
</script>
9+
10+
<IconComponent iconSet={iconSet} {...props} />

src/blocks/Icon/Icon.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react'
2+
3+
import IconComponent from '@components/Icon/Icon.tsx'
4+
5+
import type { CustomIconProps } from './icon'
6+
import iconSet from './iconSet'
7+
8+
const Icon = (props: CustomIconProps) => <IconComponent iconSet={iconSet} {...props} />
9+
10+
export default Icon

src/blocks/Icon/icon.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { IconProps } from 'webcoreui/astro'
2+
3+
export type CustomIconProps = {
4+
type: 'astro'
5+
| 'components'
6+
| 'config'
7+
| 'cookie'
8+
| 'discord'
9+
| 'drag'
10+
| 'edit'
11+
| 'file'
12+
| 'lock'
13+
| 'lock-open'
14+
| 'react'
15+
| 'rocket'
16+
| 'svelte'
17+
| 'swatches'
18+
| 'terminal'
19+
| IconProps['type']
20+
} & Omit<IconProps, 'type'>

src/blocks/Icon/iconSet.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import Astro from './icons/astro.svg?raw'
2+
import Components from './icons/components.svg?raw'
3+
import Config from './icons/config.svg?raw'
4+
import Cookie from './icons/cookie.svg?raw'
5+
import Discord from './icons/discord.svg?raw'
6+
import Drag from './icons/drag.svg?raw'
7+
import Edit from './icons/edit.svg?raw'
8+
import File from './icons/file.svg?raw'
9+
import Lock from './icons/lock.svg?raw'
10+
import LockOpen from './icons/lock-open.svg?raw'
11+
import React from './icons/react.svg?raw'
12+
import Rocket from './icons/rocket.svg?raw'
13+
import Svelte from './icons/svelte.svg?raw'
14+
import Swatches from './icons/swatches.svg?raw'
15+
import Terminal from './icons/terminal.svg?raw'
16+
17+
const iconSet = {
18+
'astro': Astro,
19+
'components': Components,
20+
'config': Config,
21+
'cookie': Cookie,
22+
'discord': Discord,
23+
'drag': Drag,
24+
'edit': Edit,
25+
'file': File,
26+
'lock': Lock,
27+
'lock-open': LockOpen,
28+
'react': React,
29+
'rocket': Rocket,
30+
'svelte': Svelte,
31+
'swatches': Swatches,
32+
'terminal': Terminal
33+
}
34+
35+
export default iconSet

src/blocks/Icon/icons/astro.svg

Lines changed: 4 additions & 0 deletions
Loading
File renamed without changes.

src/blocks/Icon/icons/config.svg

Lines changed: 3 additions & 0 deletions
Loading

src/blocks/Icon/icons/cookie.svg

Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)