Skip to content

feat(react): add events to react generated components#371

Merged
mimshins merged 9 commits intomainfrom
feat/react-components/add-events-to-jenerated-code
Mar 5, 2025
Merged

feat(react): add events to react generated components#371
mimshins merged 9 commits intomainfrom
feat/react-components/add-events-to-jenerated-code

Conversation

@amir78729
Copy link
Member

No description provided.

@amir78729 amir78729 added this to the V1 (stable) milestone Mar 4, 2025
@amir78729 amir78729 requested a review from mimshins March 4, 2025 15:57
@amir78729 amir78729 self-assigned this Mar 4, 2025
elementClass: ComponentNamespace.TapsiPinwheel,
react: React,
events: {},
events: { onChange: "change" },
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove the redundant events.


const cem = await generateCem();

const sidebarItemsMap: Record<string, DefaultTheme.SidebarItem> = {};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Encapsulate the following codes within its separated function.

"./packages/web-components/src",
);

const distDir = path.relative(cwd(), path.join(workspaceDir, "dist"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • Remove cwd.
  • Rename workspaceDir to packageDir.

Comment on lines 4 to 9
type Declaration,
type Package,
} from "custom-elements-manifest";
import { exec } from "node:child_process";
import * as fs from "node:fs";
import * as path from "node:path";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Move this script to packages/web-components/scripts.

Comment on lines +46 to +53
[
"cem",
"analyze",
"--litelement",
"--outdir",
distDir,
globs.map(g => `--globs ${g}`).join(" "),
].join(" "),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add --packagejson parameter.

Comment on lines 27 to 30
const metadataGeneratorPath = path.join(
workspaceDir,
"packages/web-components/src",
"scripts/generate-metadata.ts",
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove this in favor of pnpm --filter @tapsioss/web-components run gen:metadata.

const cemGeneratorPath = path.join(workspaceDir, "scripts/generate-cem.ts");
const componentTemplatePath = path.join(templatesDir, "component.txt");
const cemPath = path.join(workspaceDir, "dist/custom-elements.json");
const metadataPath = path.join(workspaceDir, "dist/components-metadata.json");
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will be:
path.resolve(packageDir, "../web-components/dist/components-metadata.json");

const { dirname } = getFileMeta(import.meta.url);

const packageDir = path.resolve(dirname, "..");
const workspaceDir = path.resolve(packageDir, "../../");
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is redundant now.

console.time("generate");
const { stdout, stderr } = await asyncExec(
["tsx", cemGeneratorPath].join(" "),
["tsx", metadataGeneratorPath].join(" "),
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will be replaced with pnpm --filter

@mimshins mimshins merged commit 590a760 into main Mar 5, 2025
2 checks passed
@mimshins mimshins deleted the feat/react-components/add-events-to-jenerated-code branch March 5, 2025 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants