Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Refactor WDS custom widget #38038

Merged
merged 7 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
import css from "!!raw-loader!./reset.css";

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
import script from "!!raw-loader!./customWidgetscript.js";

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
import appsmithConsole from "!!raw-loader!./appsmithConsole.js";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Avoid using @ts-ignore directives

Instead of silencing TypeScript errors, consider properly typing the imports.

You can declare module definitions for these imports to resolve the TypeScript errors.

interface CreateHtmlTemplateProps {
cssTokens: string;
onConsole: boolean;
srcDoc: { html: string; js: string; css: string };
}

export const createHtmlTemplate = (props: CreateHtmlTemplateProps) => {
const { cssTokens, onConsole, srcDoc } = props;

return ` <html>
<head>
<style>${css}</style>
<style data-appsmith-theme>${cssTokens}</style>
</head>
<body>
${onConsole ? `<script type="text/javascript">${appsmithConsole}</script>` : ""}
<script type="module">
${script}
main();
</script>
${srcDoc.html}
<script type="module">${srcDoc.js}</script>
<style>${srcDoc.css}</style>
</body>
</html>`;
};

This file was deleted.

Loading
Loading