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 basic heading block #423

Merged
merged 5 commits into from
Apr 17, 2017
Merged

Add basic heading block #423

merged 5 commits into from
Apr 17, 2017

Conversation

ellatrix
Copy link
Member

See #313.

Props @BE-Webdesign for initial PR in #337.

@jasmussen
Copy link
Contributor

Looks great!

screen shot 2017-04-14 at 12 18 31

Really ties the room together.

@ellatrix
Copy link
Member Author

Notes:

  • Updates Editable component to allow tag changes.
  • Adds text piece to the IconButton (feel free to suggest different naming).
  • Temporarily uses different icon while waiting for a heading icon.

},

controls: [
...'123456'.split( '' ).map( ( level ) => ( {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need [ ...array ]. We could just use array

Copy link
Member Author

Choose a reason for hiding this comment

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

Future controls?

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough

const classes = classnames( 'editor-icon-button', className );

return (
<Button { ...additionalProps } aria-label={ label } className={ classes }>
<Dashicon icon={ icon } />
{ text ? <span>{ text }</span> : null }
Copy link
Contributor

@youknowriad youknowriad Apr 15, 2017

Choose a reason for hiding this comment

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

Using children for this is more appropriate to me, don't you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

Could you give an example?

Copy link
Contributor

Choose a reason for hiding this comment

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

The exact same thing, just replace text with children in order to use this like this:

<IconButton>MyText</IconButton>

I've done something similar in #429 but without the span(I don't mind keeping the span)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure I understand. Could you give an example?

Copy link
Contributor

@youknowriad youknowriad Apr 15, 2017

Choose a reason for hiding this comment

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

function IconButton( { icon, children, label, className, ...additionalProps } ) {
  // ...
  { children ? <span>{ children }</span> : null } // This replaces the line 19
  // ..
}

And now instead of writing <IconButton text="My Text" />, you'd write <IconButton>My Text</IconButton>.

Copy link
Member Author

@ellatrix ellatrix Apr 15, 2017

Choose a reason for hiding this comment

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

Ah I see :) Thought you meant writing { text ? <span>{ text }</span> : null } differently.

@ellatrix ellatrix force-pushed the add/heading-block branch from 99344e9 to 8502267 Compare April 17, 2017 08:35
@ellatrix ellatrix requested a review from jasmussen April 17, 2017 08:56
@ellatrix
Copy link
Member Author

@joen I can't seem to get the heading level text just right.

@jasmussen
Copy link
Contributor

I can't seem to get the heading level text just right.

I'll take a look!

@ellatrix ellatrix requested a review from youknowriad April 17, 2017 09:07
Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

👍 Nice work. The sizing toolbar needs We could use some design ❤️ but this is good enough for me.

@jasmussen
Copy link
Contributor

Feel free to merge in, I'll take a look at the numbers in a separate PR.

@ellatrix ellatrix merged commit e0b5bfa into master Apr 17, 2017
const classes = classnames( 'editor-icon-button', className );

return (
<Button { ...additionalProps } aria-label={ label } className={ classes }>
<Dashicon icon={ icon } />
{ children ? <span>{ children }</span> : null }
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the span wrapper on children?

@@ -14,4 +14,8 @@
color: $blue-medium;
}
}

span {
font-size: 12px;
Copy link
Member

Choose a reason for hiding this comment

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

This styling seems very targeted at the heading use-case. Is IconButton with small adjacent text a common enough pattern it should be engrained into the IconButton component itself?

Copy link
Contributor

Choose a reason for hiding this comment

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

Great question to be asking. The icon-button should be just that, an icon button, so any text added should not so much be a label as it should be something to go with the icon itself. In this case, implying a heading size. But it could also be used for quote styles, or possibly even gallery styles (i.e. quote 2 or gallery 3).

Tying together with your comment #436 (review), I will open a PR to add a label that makes this clear.

@jasmussen jasmussen deleted the add/heading-block branch April 17, 2017 12:51
jasmussen added a commit that referenced this pull request Apr 17, 2017
The IconButton can optionally have a number indicating the level. For example heading might have this, quote has two styles, galleries might have multiple styles also. This PR adds a classname to indicate this, and moves the style to the iconbutton itself.

This intends to address feedback in #423 (comment) and #436 (comment).
...'123456'.split( '' ).map( ( level ) => ( {
icon: 'heading',
text: level,
title: wp.i18n.sprintf( wp.i18n.__( 'Heading %s' ), level ),
Copy link
Member

Choose a reason for hiding this comment

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

Should we use %d placeholder instead of %s?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good too. Does it matter much? Sorry for my ignorance.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good too. Does it matter much? Sorry for my ignorance.

I'll not claim to be a localization expert, but perhaps as a hint to the translator that it's expected to be translated with a number vs. any arbitrary string could affect the translated text. Also prevents said arbitrary strings if we're very intentional that it's not to be expected (as a result of some potentially buggy code).

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.

4 participants