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

Expose LevelContext.Provider for portalled elements #42

Open
ysulyma opened this issue Oct 5, 2023 · 2 comments · May be fixed by #43
Open

Expose LevelContext.Provider for portalled elements #42

ysulyma opened this issue Oct 5, 2023 · 2 comments · May be fixed by #43

Comments

@ysulyma
Copy link

ysulyma commented Oct 5, 2023

Great library! One feature request: I want to be able to explicitly reset the heading level to 2 on dialogs. Since these get portalled to the end of <body>, these should always start at <h2>.

@alexnault
Copy link
Owner

Hey @ysulyma, thanks for the kind words!

I think that's a great idea. I'll see what I can do.

@alexnault alexnault linked a pull request Oct 6, 2023 that will close this issue
@alexnault
Copy link
Owner

alexnault commented Oct 7, 2023

@ysulyma

This proposal (#43) I've created adds a level prop to <Section> which allows overriding the current level, like so:

function App() {
  return (
    <Section component={<H>My H1</H>}>
      <Section component={<H>My H2</H>}>
        <Section component={<H>My H3</H>}>
          My content
          <Dialog>
            <Section level={2} component={<H>My H2 (dialog title)</H>}>
              <Section component={<H>My H3</H>}>
                My dialog content
              </Section>
            </Section>
          </Dialog>
        </Section>
      </Section>
    </Section>
  );
}

Could you please try it in your project and let me know how it goes? To install it, you can:

npm install "https://github.com/alexnault/react-headings.git#custom-level" 

Thanks!

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 a pull request may close this issue.

2 participants