-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
33304e5
commit dd052fb
Showing
10 changed files
with
257 additions
and
208 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[ | ||
"https://www.figma.com/design/GCvY3Qv8czRgZgvl1dG6lp/Primer-Web?node-id=26998-2424&t=eruKCwLaYv3FX2Vu-4", | ||
"https://www.figma.com/design/GCvY3Qv8czRgZgvl1dG6lp/Primer-Web?node-id=37174-89080&t=FOTWl3TFLux5dTgL-4", | ||
"https://www.figma.com/design/GCvY3Qv8czRgZgvl1dG6lp/Primer-Web?node-id=37174-89086&t=93vQIXFfs0sZZR3r-4" | ||
] |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react'; | ||
import {parseFigmaNodeUrl} from '@primer/figma-images/src/utils'; | ||
import { Link, StyledOcticon } from '@primer/react'; | ||
import {PencilIcon} from '@primer/octicons-react' | ||
|
||
type FigmaImageProps = React.ImgHTMLAttributes<HTMLImageElement> & { | ||
src: string | ||
caption?: string | ||
} | ||
|
||
const cssStyles = { | ||
width: "100%", | ||
margin: "0", | ||
"& img": { | ||
width: '100%' | ||
} | ||
} | ||
|
||
const FigmaImageDir = '/images/figma'; | ||
|
||
export const FigmaImage: React.FC<FigmaImageProps> = ({src, caption, ...props}) => { | ||
// check for missing prop | ||
if(src === undefined) throw new Error("src is required on FigmaImage component"); | ||
// get real image url | ||
const {nodeId, fileId} = parseFigmaNodeUrl(src); | ||
const imagePath = `${FigmaImageDir}/${fileId}-${nodeId}.png` | ||
// return image component | ||
return (<figure className="FigmaImage" style={cssStyles}> | ||
<img src={imagePath} {...props}/> | ||
<figcaption> | ||
{caption} | ||
<Link sx={{fontSize: '12px'}} className="link" href={src}><StyledOcticon icon={PencilIcon} sx={{mr: 2}} size="small"/>Edit in Figma</Link> | ||
</figcaption> | ||
</figure>) | ||
} |
Oops, something went wrong.