Skip to content

Commit

Permalink
Sage 10 editor scripts & styles (#2351)
Browse files Browse the repository at this point in the history
* adds alternate button style and super basic starter css

* Adds transition variable

* Add bootstrap max-width to editor-styles

* updates button scss, editor wrapper scss, and registration

* rename is-style-ghost to is-style-outline

* simplify structure and cleanup css

* Protect Ben Word's typographic holdings

* Remove scoping from .has-xyz-color classes

* Restore scss partial import structure

* rename partials, move color util, apply bootstrap font

* alphabetical selectors ¯\_(ツ)_/¯
  • Loading branch information
kellymears authored and retlehs committed Dec 7, 2019
1 parent 36b2c28 commit fdbe712
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 8 deletions.
15 changes: 15 additions & 0 deletions resources/assets/scripts/editor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import '@wordpress/edit-post';
import domReady from '@wordpress/dom-ready';
import {
unregisterBlockStyle,
registerBlockStyle,
} from '@wordpress/blocks';

domReady(() => {
unregisterBlockStyle('core/button', 'outline');

registerBlockStyle('core/button', {
name: 'outline',
label: 'Outline',
});
});
2 changes: 1 addition & 1 deletion resources/assets/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@import 'common/global';

/** Components */
@import 'components/button';
@import 'components';

/** Partials */
@import 'partials/header';
15 changes: 15 additions & 0 deletions resources/assets/styles/common/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,18 @@
a {
color: map-get($theme-colors, 'primary');
}


/**
* Block editor color palette utilities
* @see https://git.io/JeyD6
*/
@each $color-name, $color-value in $theme-colors {
.has-#{$color-name}-color {
color: $color-value;
}

.has-#{$color-name}-background-color {
background-color: $color-value;
}
}
37 changes: 34 additions & 3 deletions resources/assets/styles/components/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,38 @@
* Button
*/

.button {
background-color: map-get($theme-colors, 'primary');
color: #fff;
.wp-block-button {
// Base
&__link {
font-size: $btn-font-size;
line-height: $btn-line-height;
padding-bottom: $btn-padding-y;
padding-left: $btn-padding-x;
padding-right: $btn-padding-x;
padding-top: $btn-padding-y;

&:hover {
text-decoration: none;
}
}

// Button style: outline
&.is-style-outline {
.wp-block-button__link {
@include button-outline-variant(
map-get($theme-colors, 'primary'),
map-get($theme-colors, 'light')
);
}
}

// Button style: solid
&.is-style-solid {
.wp-block-button__link {
@include button-variant(
map-get($theme-colors, 'primary'),
map-get($theme-colors, 'light')
);
}
}
}
1 change: 1 addition & 0 deletions resources/assets/styles/components/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import 'button';
2 changes: 1 addition & 1 deletion resources/assets/styles/config/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
*/

$theme-colors: (
primary: #525ddc
primary: #525ddc,
);
9 changes: 6 additions & 3 deletions resources/assets/styles/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

@import 'config/variables';

@import '~bootstrap/scss/functions';
@import '~bootstrap/scss/variables';
@import '~bootstrap/scss/mixins';

.editor-styles-wrapper > * {
@import 'common/global';
@import 'components';

[example-block] {
@import 'components/button';
}
font-family: $font-family-base;
}

0 comments on commit fdbe712

Please # to comment.