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

Chore: style gutenberg button same as c-button #729

Merged
merged 24 commits into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
00d269c
WIP
derekshirk May 21, 2020
072b227
Merge branch 'v-next' of https://github.com/cloudfour/cloudfour.com-p…
derekshirk May 21, 2020
b55ca6b
experimenting with options for styling focus
derekshirk May 22, 2020
7744ae8
removes unused (focus related) @use statements
derekshirk May 22, 2020
7141e78
Merge branch 'v-next' of https://github.com/cloudfour/cloudfour.com-p…
derekshirk May 22, 2020
f08601f
Merge branch 'v-next' of https://github.com/cloudfour/cloudfour.com-p…
derekshirk May 26, 2020
e03ce67
Merge branch 'v-next' of https://github.com/cloudfour/cloudfour.com-p…
derekshirk May 26, 2020
76c6589
Merge branch 'v-next' of https://github.com/cloudfour/cloudfour.com-p…
derekshirk May 26, 2020
5c6345a
adds href to story example / simplfies CSS
derekshirk May 27, 2020
0e0cb7f
Merge branch 'v-next' of https://github.com/cloudfour/cloudfour.com-p…
derekshirk May 27, 2020
795c69a
adds developer comment
derekshirk May 27, 2020
f2ee131
adds missing sass docs numerical indicator
derekshirk May 27, 2020
42751eb
moves and edits comment
derekshirk May 27, 2020
ca21d02
removes border-radius override
derekshirk May 27, 2020
d5b2527
adds display flex and padding with negative margins for layout
derekshirk May 27, 2020
f80c4bf
lint fixes
derekshirk May 27, 2020
2f21ae9
improves pattern layout and spacing
derekshirk May 27, 2020
fa980f1
Merge branch 'v-next' of https://github.com/cloudfour/cloudfour.com-p…
derekshirk May 29, 2020
fc56fa5
converts underscores to hyphens
derekshirk May 29, 2020
231e128
removes extra button in from story markup
derekshirk May 29, 2020
79c52b9
improves variable usage
derekshirk May 29, 2020
fa9e8bd
Merge branch 'v-next' of https://github.com/cloudfour/cloudfour.com-p…
derekshirk May 29, 2020
8615c42
Merge branch 'v-next' of https://github.com/cloudfour/cloudfour.com-p…
derekshirk May 29, 2020
e99492b
Merge branch 'v-next' of https://github.com/cloudfour/cloudfour.com-p…
derekshirk May 29, 2020
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
98 changes: 4 additions & 94 deletions src/components/button/button.scss
Original file line number Diff line number Diff line change
@@ -1,111 +1,21 @@
@use "../../design-tokens/colors.yml";
@use "../../design-tokens/font.yml";
@use "../../design-tokens/motion.yml";
@use "../../design-tokens/sizes.yml";
@use "../../mixins/focus";
@use "../../mixins/ms";
@use "../../mixins/unit";

/**
* Button object
*
* 1. More overtly actionable cursor appearance. Recently this tweak has come
* with some contention, but our experience has been that the average user
* doesn't differentiate cursor styles between different styles of action.
* 2. Although we will be overtly setting some typographic properties, the
* shorthand is helpful for completely overriding all system font styles as
* a starting point.
* 3. We set a height to coordinate consistently with `c-input`. Unfortunately
* browsers don't consistently size inputs without setting `height`.
*/
@use "../../mixins/button";

.c-button {
background: colors.$primary-brand;
border-color: colors.$primary-brand-dark;
border-radius: sizes.$radius-medium;
border-style: solid;
border-width: sizes.$edge-medium;
color: colors.$text-light-emphasis;
cursor: pointer; /* 1 */
display: inline-block;
font: inherit; /* 2 */
font-style: normal;
font-weight: font.$weight-semibold;
height: sizes.$control-height; /* 3 */
line-height: normal;
padding: sizes.$control-pad-vertical sizes.$control-pad-horizontal;
position: relative;
text-align: center;
text-decoration: none;
transition: filter motion.$speed-slow motion.$ease-out,
transform motion.$speed-quick motion.$ease-out;
user-select: none;

/**
* Transform, opacity and filter changes are performant and will work across
* many more stylistic modifiers than specific color shifts.
*/

&:hover {
filter: brightness(motion.$control-brighten);
transform: scale(motion.$control-grow);
}

&:active {
filter: brightness(motion.$control-dim);
transform: scale(motion.$control-shrink);
}

&:disabled {
cursor: not-allowed;
filter: grayscale(60%);
opacity: 0.85;
transform: none;
}

@include focus.focus-visible {
box-shadow: 0 0 0 sizes.$edge-large colors.$primary-brand-lighter;
}

.t-dark & {
background-color: colors.$primary-brand-dark;
border-color: colors.$primary-brand-darker;
}
@include button.default;
}

/**
* Modifier: Secondary
*/

.c-button--secondary {
border-color: colors.$primary-brand-light;
color: colors.$primary-brand;

&,
.t-dark & {
background-color: transparent;
}

.t-dark & {
border-color: colors.$primary-brand-dark;
color: colors.$text-light-emphasis;
}
@include button.secondary;
}

/**
* Modifier: Tertiary
*/

.c-button--tertiary {
color: colors.$primary-brand;

&,
.t-dark & {
background-color: transparent;
border-color: transparent;
}

.t-dark & {
color: colors.$text-light-emphasis;
}
@include button.tertiary;
}
111 changes: 111 additions & 0 deletions src/mixins/_button.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
@use "../design-tokens/colors.yml";
@use "../design-tokens/font.yml";
@use "../design-tokens/motion.yml";
@use "../design-tokens/sizes.yml";
@use "./focus";
@use "./ms";
@use "./unit";

/**
* Button object
*
* 1. More overtly actionable cursor appearance. Recently this tweak has come
* with some contention, but our experience has been that the average user
* doesn't differentiate cursor styles between different styles of action.
* 2. Although we will be overtly setting some typographic properties, the
* shorthand is helpful for completely overriding all system font styles as
* a starting point.
* 3. We set a height to coordinate consistently with `c-input`. Unfortunately
* browsers don't consistently size inputs without setting `height`.
*/

@mixin default {
background: colors.$primary-brand;
border-color: colors.$primary-brand-dark;
border-radius: sizes.$radius-medium;
border-style: solid;
border-width: sizes.$edge-medium;
color: colors.$text-light-emphasis;
cursor: pointer; /* 1 */
display: inline-block;
font: inherit; /* 2 */
font-style: normal;
font-weight: font.$weight-semibold;
height: sizes.$control-height; /* 3 */
line-height: normal;
padding: sizes.$control-pad-vertical sizes.$control-pad-horizontal;
position: relative;
text-align: center;
text-decoration: none;
transition: filter motion.$speed-slow motion.$ease-out,
transform motion.$speed-quick motion.$ease-out;
user-select: none;

/**
* Transform, opacity and filter changes are performant and will work across
* many more stylistic modifiers than specific color shifts.
*/

&:hover {
filter: brightness(motion.$control-brighten);
transform: scale(motion.$control-grow);
}

&:active {
filter: brightness(motion.$control-dim);
transform: scale(motion.$control-shrink);
}

&:disabled {
cursor: not-allowed;
filter: grayscale(60%);
opacity: 0.85;
transform: none;
}

@include focus.focus-visible {
box-shadow: 0 0 0 sizes.$edge-large colors.$primary-brand-lighter;
}

.t-dark & {
background-color: colors.$primary-brand-dark;
border-color: colors.$primary-brand-darker;
}
}

/**
* Modifier: Secondary
*/

@mixin secondary {
border-color: colors.$primary-brand-light;
color: colors.$primary-brand;

&,
.t-dark & {
background-color: transparent;
}

.t-dark & {
border-color: colors.$primary-brand-dark;
color: colors.$text-light-emphasis;
}
}

/**
* Modifier: Tertiary
*/

@mixin tertiary {
color: colors.$primary-brand;

&,
.t-dark & {
background-color: transparent;
border-color: transparent;
}

.t-dark & {
color: colors.$text-light-emphasis;
}
}
24 changes: 24 additions & 0 deletions src/vendor/wordpress/_wordpress.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@use "../../mixins/button";
@use "../../design-tokens/sizes.yml";

/**
* Gutenberg block: Button
* Applies our pattern library styles to buttons generated via Gutenberg blocks.
*
* 1. The block editor allows editors to adjust button border radius. This style
* is applied via an inline style on the `wp-block-button__link` element. In
* order to prevent unwanted border-radius we apply an `!important` tag.
derekshirk marked this conversation as resolved.
Show resolved Hide resolved
*/

.wp-block-button {
display: inline-block;
derekshirk marked this conversation as resolved.
Show resolved Hide resolved

.wp-block-button__link {
@include button.default;
border-radius: sizes.$radius-medium !important; /* 1 */
derekshirk marked this conversation as resolved.
Show resolved Hide resolved
}

&.is-style-outline .wp-block-button__link {
@include button.secondary;
}
}
12 changes: 8 additions & 4 deletions src/vendor/wordpress/gutenberg.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ container.

## Button

The button block adds call-to-action-style links to a post. Container elements provide
layout.
The button block adds call-to-action-style links to a post. When multiple buttons are added the `wp-block-buttons` container controls layout.

If chosen, a button can have only an outline (no fill color), which adds the `is-style-outline`
class on the `.wp-block-button` element.
Expand All @@ -65,11 +64,16 @@ and border radius.
<Preview>
<Story name="core/button" height="100px">
{`<div class="wp-block-buttons">
<div class="wp-block-button">
<a class="wp-block-button__link" href="https:/end wp-themes.com/twentytwenty/" style="border-radius:50px" target="_blank" rel="noopener noreferrer">
<div class="wp-block-button is-style-fill">
<a class="wp-block-button__link" href="#">
Button
</a>
</div>
<div class="wp-block-button is-style-outline">
<a class="wp-block-button__link" href="#">
Another Outlined button
</a>
</div>
</div>`}
</Story>
</Preview>
Expand Down