Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions packages/generate-arg-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"dependencies": {
"@webstudio-is/html-data": "workspace:*",
"@webstudio-is/sdk": "workspace:*",
"@webstudio-is/react-sdk": "workspace:*",
"fast-glob": "^3.3.2",
"react-docgen-typescript": "^2.2.2",
"typescript": "5.8.2",
Expand Down
44 changes: 20 additions & 24 deletions packages/generate-arg-types/src/props/add-descriptions.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import {
domAttributesToReact,
reactPropsToDomAttributes,
} from "@webstudio-is/html-data";
import {
htmlPropsDescriptions,
overridePropsDescriptions,
} from "@webstudio-is/html-data";
reactPropsToStandardAttributes,
standardAttributesToReactProps,
} from "@webstudio-is/react-sdk";
import { ariaAttributes, attributesByTag } from "@webstudio-is/html-data";
import { propsToArgTypes } from "../arg-types";

const ignoreComponents = new Set(["Embed"]);
Expand All @@ -31,7 +28,6 @@ export const addDescriptions = (

Object.entries(argTypes).forEach(([propName, meta]) => {
const description = getDescription(
componenName,
propName,
meta.description,
customDescriptions
Expand All @@ -43,30 +39,30 @@ export const addDescriptions = (
});
};

const attributeDescriptions: Record<string, string> = {};
for (const attribute of Object.values(attributesByTag).flat()) {
if (attribute) {
attributeDescriptions[attribute.name] = attribute.description;
}
}
for (const attribute of ariaAttributes) {
attributeDescriptions[attribute.name] = attribute.description;
}

export const getDescription = (
componentName: string,
propName: string,
currentDescription: string | undefined,
customDescriptions: { [key in string]: string } = {}
): string | undefined => {
const name = (domAttributesToReact[
propName as keyof typeof domAttributesToReact
] ||
reactPropsToDomAttributes[propName] ||
propName.toLowerCase()) as keyof typeof htmlPropsDescriptions &
keyof typeof overridePropsDescriptions;

const name =
standardAttributesToReactProps[propName] ||
reactPropsToStandardAttributes[propName] ||
propName.toLowerCase();
return (
customDescriptions[propName] ||
customDescriptions[name] ||
overridePropsDescriptions[
propName as keyof typeof overridePropsDescriptions
] ||
overridePropsDescriptions[name] ||
currentDescription ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
htmlPropsDescriptions[`${componentName.toLowerCase()}:${name}`] ||
htmlPropsDescriptions[name]
attributeDescriptions[propName] ||
attributeDescriptions[name]
);
};
175 changes: 0 additions & 175 deletions packages/html-data/src/descriptions.ts

This file was deleted.

Loading