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

Components: Fix the icon button level prop #444

Merged
merged 5 commits into from
Apr 18, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions blocks/library/heading/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ registerBlock( 'core/heading', {
controls: [
...'123456'.split( '' ).map( ( level ) => ( {
icon: 'heading',
text: level,
title: wp.i18n.sprintf( wp.i18n.__( 'Heading %s' ), level ),
isActive: ( { tag } ) => 'H' + level === tag,
onClick( attributes, setAttributes ) {
setAttributes( { tag: 'H' + level } );
}
},
level
} ) )
],

Expand Down
3 changes: 2 additions & 1 deletion editor/components/icon-button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ function IconButton( { icon, children, label, className, ...additionalProps } )
const classes = classnames( 'editor-icon-button', className );

return (
<Button { ...additionalProps } aria-label={ label } className={ classes } data-level={ children ? children : null }>
<Button { ...additionalProps } aria-label={ label } className={ classes }>
<Dashicon icon={ icon } />
{ children }
</Button>
);
}
Expand Down
10 changes: 0 additions & 10 deletions editor/components/icon-button/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,4 @@
color: $blue-medium;
}
}

&:after {
content: attr( data-level );
font-family: $default-font;
font-size: 10px;
font-weight: bold;
position: absolute;
bottom: 8px;
right: 4px;
}
}
5 changes: 2 additions & 3 deletions editor/components/toolbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ function Toolbar( { controls } ) {
key={ index }
icon={ control.icon }
label={ control.title }
data-level={ control.level }
onClick={ ( event ) => {
event.stopPropagation();
control.onClick();
} }
className={ classNames( 'editor-toolbar__control', {
'is-active': control.isActive && control.isActive()
} ) }>
{ control.text }
</IconButton>
} ) } />
) ) }
</ul>
);
Expand Down
10 changes: 10 additions & 0 deletions editor/components/toolbar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
background-color: $dark-gray-500;
color: $white;
}

&:after {
Copy link
Member

Choose a reason for hiding this comment

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

Likely no difference since styles ensure there's no impact on layout when empty, but this should probably only be applied if the control actually has a data-level attribute:

&[data-level]:after {

content: attr( data-level );
font-family: $default-font;
font-size: 10px;
font-weight: bold;
position: absolute;
bottom: 8px;
right: 5px;
}
}

.editor-toolbar__control .dashicon {
Expand Down
2 changes: 1 addition & 1 deletion languages/gutenberg.pot
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ msgstr ""
msgid "Heading"
msgstr ""

#: blocks/library/heading/index.js:26
#: blocks/library/heading/index.js:25
msgid "Heading %s"
msgstr ""

Expand Down