Skip to content

Commit

Permalink
divider component
Browse files Browse the repository at this point in the history
  • Loading branch information
lerte committed Jun 7, 2024
1 parent 710b59e commit e8e5a1d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
2 changes: 1 addition & 1 deletion apps/docs/src/usages/divider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Divider } from 'actify'
export default () => {
return (
<div className="flex flex-col gap-2">
<Divider />
<Divider insetStart insetEnd />
</div>
)
}
26 changes: 19 additions & 7 deletions packages/actify/src/components/Divider/Divider.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import { MdDivider } from '@material/web/all'
import React from 'react'
import { createComponent } from '@lit/react'
import clsx from 'clsx'
import styles from './actify.module.css'

const Divider = createComponent({
react: React,
tagName: 'md-divider',
elementClass: MdDivider
})
interface DividerProps extends Omit<React.ComponentProps<'div'>, 'children'> {
inset?: boolean
insetStart?: boolean
insetEnd?: boolean
}
const Divider = (props: DividerProps) => {
const { className, inset, insetStart, insetEnd, ...rest } = props

const classes = clsx(
styles['divider'],
inset && styles['inset'],
insetStart && styles['inset-start'],
insetEnd && styles['inset-end']
)

return <div {...rest} className={classes} />
}

export { Divider }
20 changes: 20 additions & 0 deletions packages/actify/src/components/Divider/actify.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.divider {
color: var(--md-divider-color, var(--md-sys-color-outline-variant, #cac4d0));
display: flex;
height: var(--md-divider-thickness, 1px);
width: 100%;
&:before {
background: currentcolor;
content: '';
height: 100%;
width: 100%;
}
}
.divider.inset,
.divider.inset-start {
padding-inline-start: 16px;
}
.divider.inset,
.divider.inset-end {
padding-inline-end: 16px;
}

0 comments on commit e8e5a1d

Please sign in to comment.