Skip to content

Conversation

@gksander
Copy link
Contributor

Description

This PR allows the user to pass a componentProps prop to the Markdown suite of components, and these props will be passed down to each individual component generated by the MD conversion process. E.g.,

<MarkdownSlide componentProps={{ backgroundColor: 'red', color: 'blue' }}># Ugly header</MarkdownSlide>

will style the header with a color of blue, background of red. This gives the user some control over how their markdown components render elements.

Type of Change

Please delete options that are not relevant (including this descriptive text).

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Tests added to markdown.test.js to test these changes. You can also try the componentProps prop out within the JS example slides.

size: number;
}>;

type MdComponentProps = { [key: string]: any };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not thrilled about how loose this type is, but technically any props from valid MD components can be passed here, and the user can supply their own component map (in which case, we can't account for the prop types their components will accept). Seems like it'd be hard to make this as strict as possible - and making this unnecessarily strict is also a bad idea (since TS will yell about it not recognizing props that might actually be valid).

Copy link
Contributor

Choose a reason for hiding this comment

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

I also think leaving it open gives us API flexibility. We could also use the Record type but I think that's two sides of the same coin here.

Copy link
Contributor

@carloskelly13 carloskelly13 left a comment

Choose a reason for hiding this comment

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

This is great, but let's actually add back the example of this to examples/js/index.js perhaps on line 195.

@ryan-roemer
Copy link
Member

Great work @gksander and great suggestion @carlos-kelly !

One extra tip -- when changing examples/js make sure to run yarn build-one-page after and commit the changes to example/one-page.html which is generated from examples/js

@gksander gksander merged commit 8e33b72 into main Mar 18, 2021
@gksander gksander deleted the md-prop-passdown branch March 18, 2021 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants