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 HeadingSelectControl component #24

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

tfrommen
Copy link
Contributor

@tfrommen tfrommen commented Nov 14, 2022

The HeadingSelectControl component allows for choosing one of a pre-defined list of heading levels.
It is intended to be used for blocks or plugin sidebars where some text element needs to be rendered as a user-defined heading.
The component wraps a regular SelectControl component.

image
HeadingSelectControl component.
image
HeadingSelectControl component with custom min and max value specified.

@tfrommen tfrommen requested a review from mattheu November 14, 2022 09:52
@tfrommen tfrommen self-assigned this Nov 14, 2022
@tomjn
Copy link
Contributor

tomjn commented Nov 16, 2022

Core has icons and options for H1/2/3/etc does it make sense to use those? I can foresee a toggle with these as buttons next to each other would be nice to have and avoid the need for translations

@tfrommen
Copy link
Contributor Author

Core has icons and options for H1/2/3/etc does it make sense to use those? I can foresee a toggle with these as buttons next to each other would be nice to have and avoid the need for translations

Yep, I know the SVGs. But I don't think I'd want to use them here.

Core uses the icons in a single Toolbar Button. This component, however, is a sidebar control (because you might want/have to use it multiple times for a specific, more complex block). I don't really like a button group with those icons, especially given they would wrap into two lines if you used multiple/all heading levels.

Also, the icons only work/exist for the default heading levels. This component also allows for using heading levels higher than 6, which will then be used to indicate some special form of a subheading or super paragraph or whatever. The project this component is coming from uses a total of 7 heading levels.

I just added a commit yesterday that allows for passing a custom function to create the label text for a given heading level. Maybe this better explains/justifies the way the component is set up (as a dropdown of text options).

Do you have any (other) thoughts on the current implemenation, @tomjn?

@tfrommen tfrommen requested a review from tomjn December 20, 2022 08:47
@tfrommen tfrommen removed their assignment Mar 25, 2024
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