-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #311 from element-hq/vite
Build with Vite
- Loading branch information
Showing
7 changed files
with
2,740 additions
and
1,913 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
<style> | ||
/* | ||
CSS for Storybook Docs | ||
*/ | ||
</style> | ||
<link rel="stylesheet" href="/global.css" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,21 @@ | ||
import React from "react"; | ||
import React, { useEffect, useState } from "react"; | ||
|
||
export const Icon: React.FC<{iconName: string}> = ({ iconName }) => { | ||
return <div className="cpdIconItem"> | ||
<img className="cpdIcon" alt={iconName} src={require(`@vector-im/compound-design-tokens/icons/${iconName}.svg`)}/> | ||
<p>{iconName}</p> | ||
const icons = import.meta.glob( | ||
`../../../node_modules/@vector-im/compound-design-tokens/icons/*.svg` | ||
); | ||
|
||
export const Icon: React.FC<{ iconName: string }> = ({ iconName }) => { | ||
const [src, setSrc] = useState<string | undefined>(undefined); | ||
useEffect(() => { | ||
icons[ | ||
`../../../node_modules/@vector-im/compound-design-tokens/icons/${iconName}.svg` | ||
]().then((src) => setSrc((src as { default: string }).default)); | ||
}, [iconName]); | ||
|
||
return ( | ||
<div className="cpdIconItem"> | ||
<img className="cpdIcon" alt={iconName} src={src} /> | ||
<p>{iconName}</p> | ||
</div> | ||
} | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.