Skip to content

feat: introduce wrapperDiv option #61

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

Merged
merged 3 commits into from
Jan 30, 2025

Conversation

michaelmcandrew
Copy link
Contributor

This PR adds a boolean option wrapperDiv that makes the wrapper div optional in a way that doesn't break the existing API.

I can see the value of the wrapper div in some situations but don't see a reason for it to be required.

And when a wrapperComponent is specified the extra div feels especially unnecessary and gets in the way.

Making it optional allows for cleaner simpler markup and makes, for example, styling easier.

Apologies - I made the PR before discussing but let me know what you think / if it is mergable (or not)

Also, just to say, thanks for a great plugin!!

Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@antfu antfu changed the title make the wrapper div optional feat: introduce wrapperDiv option Jan 30, 2025
src/types.ts Outdated
@@ -177,7 +184,7 @@ export interface Options {
wrapperClasses?: string | string[] | undefined | null | ((id: string, code: string) => string | string[] | undefined | null)

/**
* Component name to wrapper with
* Component name to wrap with (will wrap the wrapperDiv if present)
Copy link
Member

Choose a reason for hiding this comment

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

What does this mean?

Copy link
Contributor Author

@michaelmcandrew michaelmcandrew Jan 30, 2025

Choose a reason for hiding this comment

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

I wanted to clarify the relationship between wrapperDiv and wrapperComponent. i.e. explain that if wrapperDiv is set to true and a wrapperComponent is defined, the output will look like this:

<WrapperComponent>
  <div class='markdown-body'>
    [markdown here]
  </div>
</WrapperComponent>

We could maybe expand the text in the brackets to 'this will wrap the wrapper div when wrapperDiv=true'

Alternatively, we could remove if it is not worth mentioning (and assume that it is fairly easy to work out what combination of options will generate the desired behaviour).

Copy link
Member

Choose a reason for hiding this comment

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

I see, if you mean on the wrapping order, I think it's fine to keep as-is, as it doesn't make much sense to wrap <div outside of the components anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for merging :)

@antfu antfu merged commit 0d8df1e into unplugin:main Jan 30, 2025
2 checks passed
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.

2 participants