chore(ui,icons,ui-preset,toolbox): Move design system packages to monorepo (#5470)
This commit is contained in:
committed by
GitHub
parent
71853eafdd
commit
e4ce2f4e07
1
packages/design-system/toolbox/src/transformers/index.ts
Normal file
1
packages/design-system/toolbox/src/transformers/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./transform-svg"
|
||||
@@ -0,0 +1,56 @@
|
||||
import { transform } from "@svgr/core"
|
||||
import jsx from "@svgr/plugin-jsx"
|
||||
import prettier from "@svgr/plugin-prettier"
|
||||
import svgo from "@svgr/plugin-svgo"
|
||||
|
||||
import { defaultTemplate, fixedTemplate } from "@/templates"
|
||||
|
||||
type TransformArgs = {
|
||||
code: string
|
||||
componentName: string
|
||||
fixed?: boolean
|
||||
}
|
||||
|
||||
export async function transformSvg({
|
||||
code,
|
||||
componentName,
|
||||
fixed = false,
|
||||
}: TransformArgs) {
|
||||
return await transform(
|
||||
code,
|
||||
{
|
||||
typescript: true,
|
||||
replaceAttrValues: !fixed
|
||||
? {
|
||||
"#030712": "{color}",
|
||||
}
|
||||
: undefined,
|
||||
svgProps: {
|
||||
ref: "{ref}",
|
||||
},
|
||||
expandProps: "end",
|
||||
plugins: [svgo, jsx, prettier],
|
||||
jsxRuntime: "classic",
|
||||
prettierConfig: {
|
||||
semi: false,
|
||||
parser: "typescript",
|
||||
},
|
||||
svgoConfig: {
|
||||
plugins: [
|
||||
{
|
||||
name: "preset-default",
|
||||
params: {
|
||||
overrides: {
|
||||
removeTitle: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
template: fixed ? fixedTemplate : defaultTemplate,
|
||||
},
|
||||
{
|
||||
componentName,
|
||||
}
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user