-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not use an <hr /> as a divider
- Loading branch information
1 parent
2850470
commit 331495e
Showing
2 changed files
with
43 additions
and
6 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,36 @@ | ||
import React from "react"; | ||
import { Divider } from "."; | ||
import { Text } from "../Type"; | ||
|
||
export default { | ||
title: "Components/Divider", | ||
component: Divider, | ||
}; | ||
|
||
export const _Divider = () => <Divider />; | ||
export const Default = () => ( | ||
<div> | ||
<Text>Section A</Text> | ||
<Divider /> | ||
<Text>Section B</Text> | ||
</div> | ||
); | ||
|
||
export const WithCustomColourAndSpacing = () => ( | ||
<div> | ||
<Text>Section A</Text> | ||
<Divider borderColor="darkBlue" my="x1" /> | ||
<Text>Section B</Text> | ||
</div> | ||
); | ||
|
||
export const WithCustomProperties = () => ( | ||
<div> | ||
<Text>Section A</Text> | ||
<Divider | ||
borderColor="none" | ||
height="2px" | ||
backgroundImage={`linear-gradient(90deg, hsl(292deg 100% 97%) 0%, hsl(329deg 100% 19%) 17%, hsl(343deg 100% 36%) 33%, hsl(0deg 100% 50%) 50%, hsl(345deg 100% 69%) 67%, hsl(325deg 100% 84%) 83%, hsl(292deg 100% 97%) 100%);`} | ||
/> | ||
<Text>Section B</Text> | ||
</div> | ||
); |
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,9 +1,19 @@ | ||
import React from "react"; | ||
import { Box } from "../Box"; | ||
import { BoxProps } from "../Box/Box"; | ||
import styled from "styled-components"; | ||
import { addStyledProps, StyledProps } from "../StyledProps"; | ||
|
||
const Divider = ({ borderColor = "lightGrey", ...props }: BoxProps) => ( | ||
<Box as="hr" borderTop="1px solid" borderColor={borderColor} {...props} /> | ||
type Props = StyledProps; | ||
|
||
const Divider = styled.div<Props>( | ||
({ theme, color }) => ({ | ||
display: "flex", | ||
marginTop: theme.space.x2, | ||
marginBottom: theme.space.x2, | ||
marginLeft: "0", | ||
marginRight: "0", | ||
borderBottom: "1px solid", | ||
borderColor: color ? color : theme.colors.lightGrey, | ||
}), | ||
addStyledProps | ||
); | ||
|
||
export default Divider; |