-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathseparator.ts
More file actions
62 lines (55 loc) · 1.5 KB
/
separator.ts
File metadata and controls
62 lines (55 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { LitElement, html, css } from "lit";
import { property } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js";
import { ComponentStyles as TailwindStyles } from "./tw-styles.js";
import { GlobalStyles } from "../../global.js";
// Utility function to combine class names
function cn(...classes: (string | undefined | false)[]) {
return classes.filter(Boolean).join(" ");
}
/**
* @summary A separator component that visually or semantically separates content
* @since 1.0.0
*
* @element ecc-utils-design-separator
*
* @csspart base - The component's base wrapper
*
* @slot - Default slot
*/
export class EccUtilsDesignSeparator extends LitElement {
static styles = [
css`
${TailwindStyles}
`,
css`
${GlobalStyles}
`,
];
/**
* The orientation of the separator.
*/
@property({ type: String }) orientation: "horizontal" | "vertical" =
"horizontal";
/**
* Whether the separator is decorative or semantically separates content.
*/
@property({ type: Boolean }) decorative = true;
render() {
const classes = cn(
"shrink-0 bg-border",
this.orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]"
);
return html`
<div
part="base"
class=${classes}
role=${this.decorative ? "none" : "separator"}
aria-orientation=${ifDefined(
this.decorative ? undefined : this.orientation
)}
></div>
`;
}
}
export default EccUtilsDesignSeparator;