@m3e/divider 1.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,130 @@
1
+ import { css, CSSResultGroup, LitElement } from "lit";
2
+ import { customElement, property } from "lit/decorators.js";
3
+
4
+ import { DesignToken, Role } from "@m3e/core";
5
+
6
+ /**
7
+ * @summary
8
+ * A thin line that separates content in lists or other containers.
9
+ *
10
+ * @description
11
+ * The `m3e-divider` component visually separates content within layouts, lists, or containers using a thin, unobtrusive line.
12
+ * It supports horizontal and vertical orientation, with optional inset variants to align with layout padding and visual hierarchy.
13
+ * The divider thickness, color, and inset behavior are customizable via CSS properties to maintain consistency across surfaces.
14
+ * It is designed to reinforce spatial relationships without drawing attention, preserving focus on primary content.
15
+ *
16
+ * @example
17
+ * The following example illustrates a basic horizontal divider.
18
+ * ```html
19
+ * <m3e-divider></m3e-divider>
20
+ * ```
21
+ *
22
+ * @tag m3e-divider
23
+ *
24
+ * @attr inset - Whether the divider is indented with equal padding on both sides.
25
+ * @attr inset-start - Whether the divider is indented with padding on the leading side.
26
+ * @attr inset-end - Whether the divider is indented with padding on the trailing side.
27
+ * @attr vertical - Whether the divider is vertically aligned with adjacent content.
28
+ *
29
+ * @cssprop --m3e-divider-thickness - Thickness of the divider line.
30
+ * @cssprop --m3e-divider-color - Color of the divider line.
31
+ * @cssprop --m3e-divider-inset-size - When inset, fallback inset size used when no specific start or end inset is provided.
32
+ * @cssprop --m3e-divider-inset-start-size - When inset, leading inset size.
33
+ * @cssprop --m3e-divider-inset-end-size - When inset, trailing inset size.
34
+ */
35
+ @customElement("m3e-divider")
36
+ export class M3eDividerElement extends Role(LitElement, "none") {
37
+ /** The styles of the element. */
38
+ static override styles: CSSResultGroup = css`
39
+ :host {
40
+ display: block;
41
+ position: relative;
42
+ }
43
+ :host(:not([vertical])) {
44
+ height: var(--m3e-divider-thickness, 1px);
45
+ width: 100%;
46
+ }
47
+ :host([vertical]) {
48
+ width: var(--m3e-divider-thickness, 1px);
49
+ height: 100%;
50
+ }
51
+ :host::before {
52
+ content: "";
53
+ box-sizing: border-box;
54
+ position: absolute;
55
+ }
56
+ :host(:not([vertical]))::before {
57
+ border-bottom: var(--m3e-divider-thickness, 1px) solid
58
+ var(--m3e-divider-color, ${DesignToken.color.outlineVariant});
59
+ height: inherit;
60
+ }
61
+ :host([vertical])::before {
62
+ border-right: var(--m3e-divider-thickness, 1px) solid
63
+ var(--m3e-divider-color, ${DesignToken.color.outlineVariant});
64
+ width: inherit;
65
+ }
66
+ :host([vertical][inset])::before,
67
+ :host([vertical][inset-start])::before {
68
+ top: var(--m3e-divider-inset-start-size, var(--m3e-divider-inset-size, 1rem));
69
+ }
70
+ :host(:not([vertical])[inset])::before,
71
+ :host(:not([vertical])[inset-start])::before {
72
+ left: var(--m3e-divider-inset-start-size, var(--m3e-divider-inset-size, 1rem));
73
+ }
74
+ :host([vertical][inset])::before,
75
+ :host([vertical][inset-start])::before {
76
+ bottom: var(--m3e-divider-inset-end-size, var(--m3e-divider-inset-size, 1rem));
77
+ }
78
+ :host(:not([vertical])[inset])::before,
79
+ :host(:not([vertical])[inset-start])::before {
80
+ right: var(--m3e-divider-inset-end-size, var(--m3e-divider-inset-size, 1rem));
81
+ }
82
+ :host([vertical]:not([inset]):not([inset-start]))::before {
83
+ top: 0;
84
+ }
85
+ :host(:not([vertical]):not([inset]):not([inset-start]))::before {
86
+ left: 0;
87
+ }
88
+ :host([vertical]:not([inset]):not([inset-end]))::before {
89
+ bottom: 0;
90
+ }
91
+ :host(:not([vertical]):not([inset]):not([inset-end]))::before {
92
+ right: 0;
93
+ }
94
+ @media (forced-colors: active) {
95
+ :host::before {
96
+ border-color: GrayText;
97
+ }
98
+ }
99
+ `;
100
+
101
+ /**
102
+ * Whether the divider is vertically aligned with adjacent content.
103
+ * @default false
104
+ */
105
+ @property({ type: Boolean, reflect: true }) vertical = false;
106
+
107
+ /**
108
+ * Whether the divider is indented with equal padding on both sides.
109
+ * @default false
110
+ */
111
+ @property({ type: Boolean, reflect: true }) inset = false;
112
+
113
+ /**
114
+ * Whether the divider is indented with padding on the leading side.
115
+ * @default false
116
+ */
117
+ @property({ attribute: "inset-start", type: Boolean, reflect: true }) insetStart = false;
118
+
119
+ /**
120
+ * Whether the divider is indented with padding on the trailing side.
121
+ * @default false
122
+ */
123
+ @property({ attribute: "inset-end", type: Boolean, reflect: true }) insetEnd = false;
124
+ }
125
+
126
+ declare global {
127
+ interface HTMLElementTagNameMap {
128
+ "m3e-divider": M3eDividerElement;
129
+ }
130
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./DividerElement";
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "./src",
5
+ "outDir": "./dist/src"
6
+ },
7
+ "include": ["src/**/*.ts", "**/*.mjs", "**/*.js"],
8
+ "exclude": []
9
+ }