Files
Ritesh Kumar 1bd559514b Transform 2.0 (#101)
* feat(init): added EditorPanel with prettier, copy and settings support

* chore(static): ignore static

* feat: added navigator

* feat:

* feat(settings): added sessionStorage support for settings

* feat(message): add messaging support in editors

* feat(preview): added support for preview panel

* fix(settings): use localstorage for settings instead of session storage

* feat:

* feat(css-to-js): implemented React section

* feat(schema): add json to schema conversions

* feat(others): implemented xml, yaml and markdown conversions

* feat(babel): added flow to typescript converter

* feat(graphql): implemented graphql to typescript

* feat(graphql): added some transformations

* fix: add support for different default value in one language

* feat(graphql): added components, resolver signatures and mongodb

* feat:

* scala case class

* fix(memory): worker-loader patch applied to fix memory overflow crash

* feat: added json schema to typescript

*     icon: <GraphQLIcon />,

* feat(navigator): shorter naming and new categories

* route fixes

* navigator

* perf(workers): create separate file and remove fallback

* fix(navigator): completed

* build(snack):

* fixes

* fixes

* fix(safari):

* added json-to-mobx-state tree

* fix(native): snacksession

* fixes

* added logo

* navigator

* fixes

* custom header

* fixes

* refactor(settings): move settings to left side

* feat: set up redirects

* feat(seo): added title and description

* feat(error): added custom error page

* ga-script

* feat:

* fixes

* fixe

* fixes

* fixes

* fix:
2019-07-18 19:07:48 +05:30

96 lines
2.4 KiB
TypeScript

import { InputType } from "@components/Form";
import { lowerCase, omit } from "lodash";
export interface Settings {
removeTitle: boolean;
removeDesc: boolean;
removeUselessDefs: boolean;
removeEditorsNSData: boolean;
removeEmptyAttrs: boolean;
removeHiddenElems: boolean;
removeEmptyText: boolean;
removeEmptyContainers: boolean;
removeViewBox: boolean;
cleanupEnableBackground: boolean;
convertColors: boolean;
convertPathData: boolean;
convertTransform: boolean;
removeUnknownsAndDefaults: boolean;
removeNonInheritableGroupAttrs: boolean;
removeUselessStrokeAndFill: boolean;
removeUnusedNS: boolean;
cleanupIDs: boolean;
cleanupNumericValues: boolean;
moveElemsAttrsToGroup: boolean;
moveGroupAttrsToElems: boolean;
collapseGroups: boolean;
removeRasterImages: boolean;
mergePaths: boolean;
convertShapeToPath: boolean;
sortAttrs: boolean;
optimizeSvg: boolean;
}
export const nativeRequiredSettings = {
cleanupAttrs: true,
inlineStyles: true,
minifyStyles: true,
convertStyleToAttrs: true,
removeDoctype: true,
removeXMLProcInst: false,
removeComments: true,
removeMetadata: true,
removeDimensions: false
};
export const defaultSettings = {
optimizeSvg: true,
...nativeRequiredSettings,
removeComments: true,
removeMetadata: true,
removeTitle: true,
removeDesc: true,
removeUselessDefs: true,
removeEditorsNSData: true,
removeEmptyAttrs: true,
removeHiddenElems: true,
removeEmptyText: true,
removeEmptyContainers: true,
removeViewBox: false,
cleanupEnableBackground: true,
convertColors: true,
convertPathData: true,
convertTransform: true,
removeUnknownsAndDefaults: true,
removeNonInheritableGroupAttrs: true,
removeUselessStrokeAndFill: true,
removeUnusedNS: true,
cleanupIDs: true,
cleanupNumericValues: false,
moveElemsAttrsToGroup: true,
moveGroupAttrsToElems: true,
collapseGroups: true,
removeRasterImages: true,
mergePaths: true,
convertShapeToPath: true,
sortAttrs: true
};
export const defaultNativeSettings = omit(
defaultSettings,
Object.keys(nativeRequiredSettings)
);
export const formFields = settings =>
Object.keys(settings).map((property: keyof Settings) => ({
label: lowerCase(property),
type: InputType.SWITCH,
key: property,
...(property !== "optimizeSvg"
? {
isDisabled: values => !values.optimizeSvg,
props: { paddingLeft: 20, borderLeft: "2px solid #FDF8F3" }
}
: {})
}));