-
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.
* add max width/height to svg viewer, add key to traitTable * adjust rawSvg/formattedSvg naming
- Loading branch information
Showing
7 changed files
with
66 additions
and
58 deletions.
There are no files selected for viewing
Submodule forge-std
updated
from c19dfd to 87c27a
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
21 changes: 10 additions & 11 deletions
21
packages/inspector/hooks/useSVG.tsx → packages/inspector/hooks/useFormattedSVG.tsx
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,37 +1,36 @@ | ||
import { useState, useEffect } from "react"; | ||
// import babelParser from 'prettier/parser-babel' | ||
import htmlParser from 'prettier/parser-html' | ||
import prettier from 'prettier/standalone' | ||
import htmlParser from "prettier/parser-html"; | ||
import prettier from "prettier/standalone"; | ||
|
||
const options = { | ||
parser: 'html', | ||
parser: "html", | ||
plugins: [htmlParser], | ||
tabWidth: 2, | ||
semi: false, | ||
singleQuote: false, | ||
bracketSameLine: true, | ||
} | ||
}; | ||
|
||
function formatSVG(code: string) { | ||
return prettier.format(code, options) | ||
return prettier.format(code, options); | ||
} | ||
|
||
|
||
export const useSvg = (svg: string) => { | ||
const [formatted, setFormatted] = useState(""); | ||
export const useFormattedSvg = (svg: string) => { | ||
const [formattedSvg, setFormattedSvg] = useState(""); | ||
const [error, setError] = useState(""); | ||
|
||
useEffect(() => { | ||
try { | ||
if (svg === null) { | ||
setFormatted(""); | ||
setFormattedSvg(""); | ||
} else { | ||
setFormatted(formatSVG(svg)); | ||
setFormattedSvg(formatSVG(svg)); | ||
} | ||
} catch (e) { | ||
setError(e.message); | ||
} | ||
}, [svg]); | ||
|
||
return { formatted, error }; | ||
return { formattedSvg, error }; | ||
}; |
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