File tree 3 files changed +65
-0
lines changed
3 files changed +65
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ const {
3
+ type,
4
+ size = 24 ,
5
+ color
6
+ } = Astro .props
7
+
8
+ const { default : innerHTML } = await import (` ../../icons/${type }.js ` );
9
+
10
+ ---
11
+
12
+ <svg
13
+ width ={ size }
14
+ height ={ size }
15
+ viewBox =" 0 0 24 24"
16
+ color ={ color }
17
+ set:html ={ innerHTML }
18
+ />
Original file line number Diff line number Diff line change
1
+ <script >
2
+ export let type
3
+ export let size = 24
4
+ export let color
5
+
6
+ const icon = () => import (` ../../icons/${ type} .js` )
7
+ </script >
8
+
9
+ {#await icon () then module }
10
+ <svg
11
+ width ={size }
12
+ height ={size }
13
+ viewBox =" 0 0 24 24"
14
+ color ={color }
15
+ >{@html module .default }</svg >
16
+ {/await }
17
+
Original file line number Diff line number Diff line change
1
+ import React , { useState , useEffect } from 'react'
2
+
3
+ import github from '../../icons/github'
4
+
5
+ export const Icon = ( {
6
+ type,
7
+ size = 24 ,
8
+ color
9
+ } ) => {
10
+ const [ icon , setIcon ] = useState ( '' )
11
+
12
+ useEffect ( ( ) => {
13
+ ( async ( ) => {
14
+ const icon = ( await import ( `../../icons/${ type } .js` ) ) . default ;
15
+
16
+ setIcon ( icon )
17
+ } ) ( )
18
+ } , [ ] )
19
+
20
+ return (
21
+ < svg
22
+ width = { size }
23
+ height = { size }
24
+ viewBox = "0 0 24 24"
25
+ color = { color }
26
+ dangerouslySetInnerHTML = { { __html : github } }
27
+ />
28
+ )
29
+ }
30
+
You can’t perform that action at this time.
0 commit comments