Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions .changeset/fifty-pigs-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cloudfour/patterns': minor
---

Add default hr styles and improved WordPress Separator block styles
19 changes: 19 additions & 0 deletions src/base/_defaults.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@use 'sass:math';
@use '../compiled/tokens/scss/color';
@use '../compiled/tokens/scss/size';
@use '../mixins/border-radius';
Expand Down Expand Up @@ -268,3 +269,21 @@ figcaption {
address {
font-style: normal;
}

/**
* Horizontal rules
*
* We use border styles and `currentColor` for greater compatibility with
* the WordPress Gutenberg "Separator" block.
*
* 1. Our goal is for the borders to add together to form the total desired
* width. We do this because that's what WordPress's Gutenberg block does
* in order to support weird border+background style combinations.
*/

hr {
border-color: currentColor;
border-style: solid;
border-width: math.div(size.$edge-medium, 2) 0; /* 1 */
color: var(--theme-color-border-text-group);
}
14 changes: 14 additions & 0 deletions src/design/defaults.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,17 @@ For syntax highlighting, see [our Prism theme](/docs/vendor-prism--bash-shell).
}}
</Story>
</Canvas>

## Horizontal rule

Only use `hr` elements to represent a "thematic break" in content, such as a change in topic within a section. For divisions that are purely presentational, use CSS instead.

To add space between the `hr` and adjacent elements, consider wrapping the section of content in [a Rhythm object](/docs/objects-rhythm--default-story).

<Canvas>
<Story name="Horizontal rule">
{`<p>…and so ends this topic.</p>
<hr>
<p>Shifting our focus to something else entirely…</p>`}
</Story>
</Canvas>
24 changes: 18 additions & 6 deletions src/vendor/wordpress/core-blocks.stories.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Story, Canvas, Meta } from '@storybook/addon-docs';
import { Story, Canvas, Meta, ArgsTable } from '@storybook/addon-docs';
import blockImageDemo from './demo/image.twig';
const alignmentClasses = {
None: '',
Expand Down Expand Up @@ -502,15 +502,27 @@ The separator block adds the `wp-block-separator` class to an `hr` element.

Styles controls add `is-style-default`, `is-style-wide` or `is-style-dots` classes.

The color controls, if used, can add both `has-text-color` and `has-background`
classes, as well as modifier classes for predefined color choices.
The color controls, if used, can add both `has-text-color` and `has-background` classes, as well as modifier classes for predefined color choices. For consistency with [our default hr](/docs/design-defaults--horizontal-rule), we only support the text color option.

<Canvas>
<Story name="Separator">
{`<hr class="wp-block-separator has-text-color has-background has-subtle-background-background-color has-subtle-background-color is-style-wide">`}
<Canvas isColumn>
<Story
name="Separator"
args={{ style: 'default' }}
argTypes={{
style: {
options: ['default', 'wide', 'dots'],
control: {
type: 'select',
},
},
}}
>
{(args) => `<hr class="wp-block-separator is-style-${args.style}">`}
</Story>
</Canvas>

<ArgsTable story="Separator" />

## Spacer

The spacer block is a `div` with a class of `wp-block-spacer`.
Expand Down
13 changes: 13 additions & 0 deletions src/vendor/wordpress/styles/_core-blocks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,16 @@ $wp-button-gap: size.$spacing-gap-button-group-default;
text-align: left;
}
}

/**
* Gutenberg block: Separator
*
* The default separator is intended to be partial-width, so we apply those
* styles selectively here rather than un-applying them to the other modifiers.
*/

.wp-block-separator.is-style-default {
margin-left: auto;
margin-right: auto;
Comment on lines +293 to +294
Copy link
Member

Choose a reason for hiding this comment

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

Is our browser support good enough to use margin-inline?

Copy link
Member Author

Choose a reason for hiding this comment

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

@spaceninja Good question. It looks like we currently have 104 occurrences of traditional margin properties in the project already, so I think I'll create a separate issue about investigating this. Maybe also look into a linting error depending on where that lands?

Copy link
Member Author

@tylersticka tylersticka Nov 8, 2021

Choose a reason for hiding this comment

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

width: calc(100% / 3);
}