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

Add default value documentation to props #44

Merged
merged 1 commit into from
Oct 26, 2022
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
12 changes: 11 additions & 1 deletion scripts/generate-mjml-react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ function buildTypesForComponent(mjmlComponent: IMjmlComponent): string {
const {
componentName,
allowedAttributes,
defaultAttributes,
endingTag: isEndingTag,
} = mjmlComponent;
const typesFromMjmlAttributes: Record<string, string> = {};
Expand Down Expand Up @@ -179,7 +180,16 @@ function buildTypesForComponent(mjmlComponent: IMjmlComponent): string {
}

const typeStrings = Object.entries(typesFromMjmlAttributes).map(
([attributes, type]) => `${attributes}?: ${type}`
([attributes, type]) => {
const definition = `${attributes}?: ${type}`;
const defaultValue =
defaultAttributes && attributes in defaultAttributes
? defaultAttributes[attributes]
: undefined;
return defaultValue
? `/** MJML default value: ${defaultValue} */\n${definition}`
: definition;
}
);

// allow any property
Expand Down
2 changes: 2 additions & 0 deletions src/mjml/MjmlAccordion.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/mjml/MjmlAccordionText.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/mjml/MjmlAccordionTitle.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/mjml/MjmlBody.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/mjml/MjmlButton.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/mjml/MjmlCarousel.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/mjml/MjmlCarouselImage.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/mjml/MjmlColumn.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/mjml/MjmlDivider.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/mjml/MjmlGroup.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/mjml/MjmlHero.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/mjml/MjmlImage.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/mjml/MjmlNavbar.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/mjml/MjmlNavbarLink.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/mjml/MjmlSection.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/mjml/MjmlSocial.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/mjml/MjmlSocialElement.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/mjml/MjmlSpacer.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/mjml/MjmlTable.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/mjml/MjmlText.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/mjml/MjmlWrapper.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.