Skip to content

Commit

Permalink
Update buttons and icons buttons size and consistency (#19058)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored Dec 12, 2019
1 parent b2ef0f5 commit bfc58f5
Show file tree
Hide file tree
Showing 86 changed files with 535 additions and 238 deletions.
2 changes: 1 addition & 1 deletion packages/base-styles/_z-index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ $z-layers: (
".wp-block-site-title__save-button": 1,

// Active pill button
".components-button.is-button {:focus or .is-primary}": 1,
".components-button {:focus or .is-primary}": 1,

// The draggable element should show up above the entire UI
".components-draggable__clone": 1000000000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const BlockView = ( { title, rawContent, renderedContent, action, actionText, cl
</div>

<div className="block-editor-block-compare__action">
<Button isLarge tabIndex="0" onClick={ action }>{ actionText }</Button>
<Button isSecondary tabIndex="0" onClick={ action }>{ actionText }</Button>
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ exports[`BlockView should match snapshot 1`] = `
className="block-editor-block-compare__action"
>
<ForwardRef(Button)
isLarge={true}
isSecondary={true}
onClick={[Function]}
tabIndex="0"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ export class BlockInvalidWarning extends Component {
<>
<Warning
actions={ [
<Button key="convert" onClick={ this.onCompare } isLarge isPrimary={ ! hasHTMLBlock }>
<Button key="convert" onClick={ this.onCompare } isSecondary={ hasHTMLBlock } isPrimary={ ! hasHTMLBlock }>
{
// translators: Button to fix block content
_x( 'Resolve', 'imperative verb' )
}
</Button>,
hasHTMLBlock && (
<Button key="edit" onClick={ convertToHTML } isLarge isPrimary>
<Button key="edit" onClick={ convertToHTML } isPrimary>
{ __( 'Convert to HTML' ) }
</Button>
),
Expand Down
10 changes: 5 additions & 5 deletions packages/block-editor/src/components/block-mover/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
@include break-small() {
color: $dark-opacity-300;

&:not(:disabled):not([aria-disabled="true"]):not(.is-default):hover {
&:not(:disabled):not([aria-disabled="true"]):not(.is-secondary):hover {
background-color: transparent;
box-shadow: none;
}
Expand All @@ -97,15 +97,15 @@
fill: currentColor;

&,
&:not(:disabled):not([aria-disabled="true"]):not(.is-default):hover,
&:not(:disabled):not([aria-disabled="true"]):not(.is-default):active,
&:not(:disabled):not([aria-disabled="true"]):not(.is-default):focus {
&:not(:disabled):not([aria-disabled="true"]):not(.is-secondary):hover,
&:not(:disabled):not([aria-disabled="true"]):not(.is-secondary):active,
&:not(:disabled):not([aria-disabled="true"]):not(.is-secondary):focus {
box-shadow: none;
background: none;
color: $dark-opacity-500;
}

&:not(:disabled):not([aria-disabled="true"]):not(.is-default):active {
&:not(:disabled):not([aria-disabled="true"]):not(.is-secondary):active {
cursor: grabbing;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function BlockPatternPicker( {
{ patterns.map( ( pattern ) => (
<li key={ pattern.name }>
<IconButton
isLarge
isSecondary
icon={ pattern.icon }
size={ 48 }
onClick={ () => onSelect( pattern ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
// icon horizontally.
justify-content: center;

&.is-default {
&.is-secondary {
background-color: $white;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@

// Hide the box shadow that appears on hover.
// All the :not() rules are needed to override default iconButton styles.
&:not(:disabled):not([aria-disabled="true"]):not(.is-default):hover {
&:not(:disabled):not([aria-disabled="true"]):not(.is-secondary):hover {
box-shadow: none;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
transition: all 0.05s ease-in-out;
@include reduce-motion("transition");
position: relative;
height: auto;

&:disabled {
@include block-style__disabled();
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/components/link-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ function LinkControl( {
<span className="block-editor-link-control__search-item-info">{ filterURLForDisplay( safeDecodeURI( currentLink.url ) ) || '' }</span>
</span>

<Button isDefault onClick={ setMode( MODE_EDIT ) } className="block-editor-link-control__search-item-action block-editor-link-control__search-item-action--edit">
<Button isSecondary onClick={ setMode( MODE_EDIT ) } className="block-editor-link-control__search-item-action block-editor-link-control__search-item-action--edit">
{ __( 'Change' ) }
</Button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
text-align: left;
padding: 10px 15px;
border-radius: 5px;
height: auto;

&:hover,
&:focus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export class MediaPlaceholder extends Component {
className="block-editor-media-placeholder__button"
onClick={ this.openURLInput }
isPressed={ isURLInputVisible }
isLarge
isSecondary
>
{ __( 'Insert from URL' ) }
</Button>
Expand Down Expand Up @@ -315,7 +315,7 @@ export class MediaPlaceholder extends Component {
render={ ( { open } ) => {
return (
<Button
isLarge
isSecondary
onClick={ ( event ) => {
event.stopPropagation();
open();
Expand All @@ -340,7 +340,7 @@ export class MediaPlaceholder extends Component {
const content = (
<>
<IconButton
isLarge
isSecondary
className={ classnames(
'block-editor-media-placeholder__button',
'block-editor-media-placeholder__upload-button'
Expand All @@ -366,7 +366,7 @@ export class MediaPlaceholder extends Component {
<>
{ this.renderDropZone() }
<FormFileUpload
isLarge
isSecondary
className={ classnames(
'block-editor-media-placeholder__button',
'block-editor-media-placeholder__upload-button'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
width: 30px;
}

&:not(:disabled):not([aria-disabled="true"]):not(.is-default):hover {
&:not(:disabled):not([aria-disabled="true"]):not(.is-secondary):hover {
box-shadow: none;

> svg {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const SkipToSelectedBlock = ( { selectedBlockClientId } ) => {

return (
selectedBlockClientId &&
<Button isDefault className="block-editor-skip-to-selected-block" onClick={ onClick }>
<Button isSecondary className="block-editor-skip-to-selected-block" onClick={ onClick }>
{ __( 'Skip to the selected block' ) }
</Button>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/block-editor/src/components/url-popover/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
border-top: $border-width solid $light-gray-500;
}

.block-editor-url-popover__additional-controls > div[role="menu"] .components-icon-button:not(:disabled):not([aria-disabled="true"]):not(.is-default) > svg {
.block-editor-url-popover__additional-controls > div[role="menu"] .components-icon-button:not(:disabled):not([aria-disabled="true"]):not(.is-secondary) > svg {
box-shadow: none;
}

Expand Down Expand Up @@ -31,7 +31,7 @@
width: 30px;
}

&:not(:disabled):not([aria-disabled="true"]):not(.is-default):hover {
&:not(:disabled):not([aria-disabled="true"]):not(.is-secondary):hover {
box-shadow: none;

> svg {
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/block/edit-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ReusableBlockEditPanel extends Component {
</b>
<Button
ref={ this.editButton }
isLarge
isSecondary
className="reusable-block-edit-panel__button"
disabled={ isEditDisabled }
onClick={ onEdit }
Expand Down Expand Up @@ -93,7 +93,7 @@ class ReusableBlockEditPanel extends Component {
/>
<Button
type="submit"
isLarge
isSecondary
isBusy={ isSaving }
disabled={ ! title || isSaving }
className="reusable-block-edit-panel__button"
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/cover/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ function CoverEdit( {
) }
<PanelRow>
<Button
isDefault
isSecondary
isSmall
className="block-library-cover__reset-button"
onClick={ () => setAttributes( {
Expand Down
7 changes: 4 additions & 3 deletions packages/block-library/src/embed/embed-placeholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ const EmbedPlaceholder = ( props ) => {
placeholder={ __( 'Enter URL to embed here…' ) }
onChange={ onChange } />
<Button
isLarge
type="submit">
isSecondary
type="submit"
>
{ _x( 'Embed', 'button label' ) }
</Button>
{ cannotEmbed &&
<p className="components-placeholder__error">
{ __( 'Sorry, this content could not be embedded.' ) }<br />
<Button isLarge onClick={ tryAgain }>{ _x( 'Try again', 'button label' ) }</Button> <Button isLarge onClick={ fallback }>{ _x( 'Convert to link', 'button label' ) }</Button>
<Button isSecondary onClick={ tryAgain }>{ _x( 'Try again', 'button label' ) }</Button> <Button isSecondary onClick={ fallback }>{ _x( 'Convert to link', 'button label' ) }</Button>
</p>
}
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ exports[`core/embed block edit matches snapshot 1`] = `
value=""
/>
<button
class="components-button is-button is-default is-large"
class="components-button is-secondary"
type="submit"
>
Embed
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/file/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class FileEdit extends Component {
</div>
{ isSelected &&
<ClipboardButton
isDefault
isSecondary
text={ href }
className={ 'wp-block-file__copy-url-button' }
onCopy={ this.confirmCopyURL }
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/gallery/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ figure.wp-block-gallery {
height: $icon-button-size-small;

// Remove hover box shadows, since they clash with the container.
&:not(:disabled):not([aria-disabled="true"]):not(.is-default):hover {
&:not(:disabled):not([aria-disabled="true"]):not(.is-secondary):hover {
box-shadow: none;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/navigation/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function Navigation( {
>
<div className="wp-block-navigation-placeholder__buttons">
<Button
isDefault
isSecondary
className="wp-block-navigation-placeholder__button"
onClick={ handleCreateFromExistingPages }
disabled={ ! hasPages }
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/rss/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class RSSEdit extends Component {
onChange={ ( value ) => setAttributes( { feedURL: value } ) }
className={ 'components-placeholder__input' }
/>
<Button isLarge type="submit">
<Button isSecondary type="submit">
{ __( 'Use URL' ) }
</Button>
</form>
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/table/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ export class TableEdit extends Component {
min="1"
className="wp-block-table__placeholder-input"
/>
<Button className="wp-block-table__placeholder-button" isDefault type="submit">{ __( 'Create Table' ) }</Button>
<Button className="wp-block-table__placeholder-button" isSecondary type="submit">{ __( 'Create Table' ) }</Button>
</form>
</Placeholder>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/video/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class VideoEdit extends Component {
allowedTypes={ VIDEO_POSTER_ALLOWED_MEDIA_TYPES }
render={ ( { open } ) => (
<Button
isDefault
isSecondary
onClick={ open }
ref={ this.posterImageButton }
aria-describedby={ videoPosterDescription }
Expand Down
12 changes: 11 additions & 1 deletion packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# 8.3.0 (Unreleased)
## Master

### New Features

- Added a new `Guide` component which allows developers to easily present a user guide.

### Breaking Change

- `is-button` classname has been removed from the Button component.
- The `is-default` classname is not applied automatically anymore.
- By default Button components come with a fixed height and hover styles.

### Deprecations

- `isDefault` prop in `Button` has been deprecated. Consider using `isSecondary` instead.

## 8.2.0 (2019-08-29)

### New Features
Expand Down
6 changes: 3 additions & 3 deletions packages/components/src/button-group/style.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
.components-button-group {
display: inline-block;

.components-button.is-button {
.components-button {
border-radius: 0;
display: inline-flex;

& + .components-button.is-button {
& + .components-button {
margin-left: -1px;
}

Expand All @@ -22,7 +22,7 @@
&:focus,
&.is-primary {
position: relative;
z-index: z-index(".components-button.is-button {:focus or .is-primary}");
z-index: z-index(".components-button {:focus or .is-primary}");
}

// The active button should look pressed.
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/button/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Renders a button with default style.
import { Button } from "@wordpress/components";

const MyButton = () => (
<Button isDefault>
<Button isSecondary>
Click me!
</Button>
);
Expand All @@ -128,7 +128,7 @@ Name | Type | Default | Description
--- | --- | --- | ---
`disabled` | `bool` | `false` | Whether the button is disabled. If `true`, this will force a `button` element to be rendered.
`href` | `string` | `undefined` | If provided, renders `a` instead of `button`.
`isDefault` | `bool` | `false` | Renders a default button style.
`isSecondary` | `bool` | `false` | Renders a default button style.
`isPrimary` | `bool` | `false` | Renders a primary button style.
`isTertiary` | `bool` | `false` | Renders a text-based button style.
`isDestructive` | `bool` | `false` | Renders a red text-based button style to indicate destructive behavior.
Expand Down
Loading

0 comments on commit bfc58f5

Please sign in to comment.