@grayscale-dev/dragon 0.1.2 → 0.1.4

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.
Files changed (3) hide show
  1. package/README.md +6 -1
  2. package/dist/index.js +29 -24
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -83,15 +83,19 @@ CSS custom properties:
83
83
  - `--ui-input-color`
84
84
  - `--ui-input-placeholder-color`
85
85
  - `--ui-input-focus-ring`
86
+ - `--ui-input-label-font-size`
87
+
88
+ Default size values in `<dui-input>` are pixel-based.
86
89
 
87
90
  Example:
88
91
 
89
92
  ```css
90
93
  dui-input {
91
- --ui-input-padding: 0.75rem 1rem;
94
+ --ui-input-padding: 12px 16px;
92
95
  --ui-input-border: 1px solid #94a3b8;
93
96
  --ui-input-radius: 999px;
94
97
  --ui-input-focus-ring: 0 0 0 3px rgba(59, 130, 246, 0.35);
98
+ --ui-input-label-font-size: 14px;
95
99
  }
96
100
 
97
101
  dui-input::part(input) {
@@ -105,6 +109,7 @@ dui-input::part(input) {
105
109
 
106
110
  - `label-position="above"` (default): label sits above the field.
107
111
  - `label-position="floating"`: label sits like a placeholder and floats to the top-left on focus or when the input has a value.
112
+ - Floating mode hides placeholder text to avoid overlap with the label.
108
113
 
109
114
  **Form Behavior**
110
115
 
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { css as h, LitElement as c, html as d } from "lit";
2
2
  import { property as l, query as f, customElement as b } from "lit/decorators.js";
3
- import { ifDefined as p } from "lit/directives/if-defined.js";
4
- var g = Object.defineProperty, m = Object.getOwnPropertyDescriptor, a = (t, i, o, n) => {
5
- for (var r = n > 1 ? void 0 : n ? m(i, o) : i, s = t.length - 1, u; s >= 0; s--)
6
- (u = t[s]) && (r = (n ? u(i, o, r) : u(r)) || r);
7
- return n && r && g(i, o, r), r;
3
+ import { ifDefined as u } from "lit/directives/if-defined.js";
4
+ var g = Object.defineProperty, v = Object.getOwnPropertyDescriptor, a = (t, i, n, r) => {
5
+ for (var o = r > 1 ? void 0 : r ? v(i, n) : i, s = t.length - 1, p; s >= 0; s--)
6
+ (p = t[s]) && (o = (r ? p(i, n, o) : p(o)) || o);
7
+ return r && o && g(i, n, o), o;
8
8
  };
9
9
  let e = class extends c {
10
10
  constructor() {
@@ -56,9 +56,9 @@ let e = class extends c {
56
56
  this.value = i.value, this.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 }));
57
57
  }
58
58
  render() {
59
- const t = this.label.length > 0, i = t && this.labelPosition === "floating", o = this.value.length > 0;
59
+ const t = this.label.length > 0, i = t && this.labelPosition === "floating", n = this.value.length > 0, r = i ? void 0 : this.placeholder || void 0;
60
60
  return d`
61
- <div class="field ${i ? "floating" : ""}" data-has-value=${o}>
61
+ <div class="field ${i ? "floating" : ""}" data-has-value=${n}>
62
62
  ${t ? d`<label for="input">${this.label}</label>` : null}
63
63
  <input
64
64
  id="input"
@@ -68,9 +68,9 @@ let e = class extends c {
68
68
  .name=${this.name}
69
69
  ?disabled=${this.disabled}
70
70
  ?required=${this.required}
71
- placeholder=${p(this.placeholder || void 0)}
72
- autocomplete=${p(this.autocomplete)}
73
- aria-label=${p(this.label || this.placeholder || void 0)}
71
+ placeholder=${u(r)}
72
+ autocomplete=${u(this.autocomplete)}
73
+ aria-label=${u(this.label || this.placeholder || void 0)}
74
74
  @input=${this.handleInput}
75
75
  @change=${this.handleChange}
76
76
  @keydown=${this.handleKeydown}
@@ -94,39 +94,40 @@ e.styles = h`
94
94
 
95
95
  label {
96
96
  display: block;
97
- font-size: 0.875rem;
97
+ font-size: var(--ui-input-label-font-size, 14px);
98
98
  color: var(--ui-input-label-color, #475569);
99
- margin-bottom: 0.4rem;
99
+ margin-bottom: 6px;
100
100
  line-height: 1.2;
101
101
  }
102
102
 
103
103
  .field.floating label {
104
104
  position: absolute;
105
- left: var(--ui-input-floating-label-left, 0.75rem);
105
+ left: var(--ui-input-floating-label-left, var(--ui-input-floating-padding-left, 12px));
106
106
  top: 50%;
107
107
  transform: translateY(-50%);
108
+ transform-origin: left center;
108
109
  margin: 0;
109
- padding: 0 0.25rem;
110
+ padding: 0;
110
111
  background: var(--ui-input-bg, #ffffff);
111
112
  color: var(--ui-input-placeholder-color, #9aa4b2);
112
113
  pointer-events: none;
113
114
  transition: transform 120ms ease, top 120ms ease, color 120ms ease;
114
115
  }
115
116
 
116
- .field.floating[data-has-value="true"] label,
117
+ .field.floating[data-has-value='true'] label,
117
118
  :host(:focus-within) .field.floating label {
118
- top: 0.35rem;
119
- transform: translateY(0) scale(0.85);
119
+ top: 7px;
120
+ transform: scale(0.85);
120
121
  color: var(--ui-input-label-color, #475569);
121
122
  }
122
123
 
123
124
  input {
124
125
  box-sizing: border-box;
125
126
  width: 100%;
126
- padding: var(--ui-input-padding, 0.5rem 0.75rem);
127
- font-size: var(--ui-input-font-size, 1rem);
127
+ padding: var(--ui-input-padding, 8px 12px);
128
+ font-size: var(--ui-input-font-size, 16px);
128
129
  border: var(--ui-input-border, 1px solid #c6ccd5);
129
- border-radius: var(--ui-input-radius, 0.5rem);
130
+ border-radius: var(--ui-input-radius, 8px);
130
131
  background: var(--ui-input-bg, #ffffff);
131
132
  color: var(--ui-input-color, #1f2937);
132
133
  outline: none;
@@ -137,6 +138,10 @@ e.styles = h`
137
138
  color: var(--ui-input-placeholder-color, #9aa4b2);
138
139
  }
139
140
 
141
+ .field.floating input::placeholder {
142
+ color: transparent;
143
+ }
144
+
140
145
  input:focus {
141
146
  box-shadow: var(--ui-input-focus-ring, 0 0 0 3px rgba(24, 98, 255, 0.25));
142
147
  }
@@ -147,10 +152,10 @@ e.styles = h`
147
152
  }
148
153
 
149
154
  .field.floating input {
150
- padding-top: var(--ui-input-floating-padding-top, 0.95rem);
151
- padding-right: var(--ui-input-floating-padding-right, 0.75rem);
152
- padding-bottom: var(--ui-input-floating-padding-bottom, 0.45rem);
153
- padding-left: var(--ui-input-floating-padding-left, 0.75rem);
155
+ padding-top: var(--ui-input-floating-padding-top, 22px);
156
+ padding-right: var(--ui-input-floating-padding-right, 12px);
157
+ padding-bottom: var(--ui-input-floating-padding-bottom, 8px);
158
+ padding-left: var(--ui-input-floating-padding-left, 12px);
154
159
  }
155
160
  `;
156
161
  a([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grayscale-dev/dragon",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Framework-agnostic Web Components built with Lit.",
5
5
  "type": "module",
6
6
  "files": [