Skip to content

Commit

Permalink
feat(Divider): Added variant prop with horizontal/vertical STC-545 (#156
Browse files Browse the repository at this point in the history
)
  • Loading branch information
VagnerNico authored Nov 16, 2021
1 parent 74f3232 commit 3ac38fb
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 13 deletions.
27 changes: 27 additions & 0 deletions src/components/Divider/Divider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
The Divider component is used as a separator horizontally or vertically.

### Example
```jsx
;(
<div>
Item 1
<Divider />
Item 2
</div>
)
```

### Vertical
```jsx
;(
<div style={{ display: "flex", gap: 8 }}>
Item 1
<Divider variant="vertical" />
Item 2
<Divider variant="vertical" />
Item 3
<Divider variant="vertical" />
Item 4
</div>
)
```
15 changes: 15 additions & 0 deletions src/components/Divider/Divider.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ const Template: Story = (props) => (
</div>
)

const TemplateVertical: Story = (props) => (
<div style={{ display: "flex", gap: 8 }}>
Item 1
<Divider {...props} variant="vertical" />
Item 2
<Divider {...props} variant="vertical" />
Item 3
<Divider {...props} variant="vertical" />
Item 4
</div>
)

// Each story then reuses that template
export const Default = Template.bind({})
Default.args = {}

export const Vertical = TemplateVertical.bind({})
Vertical.args = {}
46 changes: 33 additions & 13 deletions src/components/Divider/Divider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,41 @@ import { HTMLAttributes } from "react"

export interface DividerProps {
className?: HTMLAttributes<HTMLHRElement>["className"]
variant?: "horizontal" | "vertical"
}

const Divider = ({ className }: DividerProps) => {
return (
<hr
className={className}
sx={{
border: "none",
height: "1px",
margin: 0,
flexShrink: 0,
backgroundColor: "text.90",
}}
/>
)
const Divider = ({ className, variant = "horizontal" }: DividerProps) => {
switch (variant) {
case "vertical":
return (
<hr
className={className}
sx={{
border: "none",
minWidth: "1px",
maxWidth: "1px",
height: "auto",
minHeight: "100%",
margin: 0,
flexShrink: 0,
backgroundColor: "text.90",
}}
/>
)
default:
return (
<hr
className={className}
sx={{
border: "none",
height: "1px",
margin: 0,
flexShrink: 0,
backgroundColor: "text.90",
}}
/>
)
}
}

export default Divider
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

1 comment on commit 3ac38fb

@github-actions
Copy link

Choose a reason for hiding this comment

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

Deploy preview for herzui ready!

✅ Preview
https://herzui-kcwqachdx-micromed.vercel.app

Built with commit 3ac38fb.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.