Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HorizontalRule component for cross-platform separator block (#14361)
* Port separator block to mobile * Default style for Hr on native * Rename Hr primitive to HorizontalRule * Improved prop handling on HorizontalRule * Fix HorizontalRule import after renaming * Add HorizontalRule README * Add Usage section to HorizontalRule README * Add Changelog entry for HorizontalRule * Expand definition of HorizontalRule from MDN documentation Co-Authored-By: koke <jbernal@gmail.com>
- Loading branch information
Showing
8 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { HorizontalRule } from '@wordpress/components'; | ||
|
||
export default function SeparatorEdit( { className } ) { | ||
return <hr className={ className } />; | ||
return <HorizontalRule className={ className } />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 7.4.0 (Unreleased) | ||
|
||
- Added a new `HorizontalRule` component. | ||
|
||
## 7.3.0 (2019-04-16) | ||
|
||
### New Features | ||
|
13 changes: 13 additions & 0 deletions
13
packages/components/src/primitives/horizontal-rule/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# HorizontalRule | ||
|
||
A drop-in replacement for the HTML [hr](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/hr) element that works both on the web and in the mobile apps. It represents a thematic break between paragraph-level elements: for example, a change of scene in a story, or a shift of topic within a section. | ||
|
||
## Usage | ||
|
||
```jsx | ||
import { HorizontalRule } from '@wordpress/components'; | ||
|
||
const MyHorizontalRule = () => ( | ||
<HorizontalRule /> | ||
); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const HorizontalRule = 'hr'; |
16 changes: 16 additions & 0 deletions
16
packages/components/src/primitives/horizontal-rule/index.native.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import Hr from 'react-native-hr'; | ||
|
||
export const HorizontalRule = ( props ) => { | ||
const lineStyle = { | ||
backgroundColor: '#555d66', | ||
height: 2, | ||
...props.lineStyle, | ||
}; | ||
|
||
return ( | ||
<Hr { ...props } lineStyle={ lineStyle } /> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './svg'; | ||
export * from './horizontal-rule'; |