@5even7/dlc-ui 0.1.0 → 0.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5even7/dlc-ui",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/styles/base.css CHANGED
@@ -7,24 +7,18 @@
7
7
  --hj-font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
8
8
  "PingFang SC", "Microsoft YaHei", sans-serif;
9
9
  --hj-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
10
- --hj-bg: #faf8f2;
11
- --hj-ink: #20231f;
12
- --hj-muted: #77786f;
13
- --hj-copy-width: 39%;
14
- --hj-copy-min-width: 164px;
15
- --hj-copy-pad-x: 24px;
16
- --hj-copy-gradient: linear-gradient(
17
- 90deg,
18
- #faf8f2 0%,
19
- #faf8f2 74%,
20
- rgba(250, 248, 242, 0.97) 84%,
21
- rgba(250, 248, 242, 0) 100%
22
- );
23
- --hj-shadow: 0 16px 42px rgba(32, 35, 31, 0.08), 0 3px 10px rgba(32, 35, 31, 0.04);
24
- --hj-name-size: 20px;
25
- --hj-copy-left: 30px;
26
- --hj-value-right: 30px;
27
- --hj-copy-max-width: 54%;
10
+ --hj-bg: #faf8f2;
11
+ --hj-ink: #20231f;
12
+ --hj-muted: #77786f;
13
+ /* Deprecated aliases, kept for cssVars compatibility. The canonical text
14
+ region width is --hj-text-width (set by the textRatio prop). */
15
+ --hj-copy-width: 39%;
16
+ --hj-copy-min-width: 164px;
17
+ --hj-copy-pad-x: 24px;
18
+ --hj-shadow: 0 16px 42px rgba(32, 35, 31, 0.08), 0 3px 10px rgba(32, 35, 31, 0.04);
19
+ --hj-copy-left: 30px;
20
+ --hj-value-right: 30px;
21
+ --hj-copy-max-width: 54%;
28
22
 
29
23
  position: relative;
30
24
  display: block;
@@ -1,81 +1,34 @@
1
- /* ---------- Cosmic capsule copy layer ---------- */
2
-
3
- .hj-capsule-copy {
4
- position: absolute;
5
- top: 0;
6
- bottom: 0;
7
- left: 0;
8
- z-index: 4;
9
- display: flex;
10
- width: var(--hj-copy-width);
11
- min-width: var(--hj-copy-min-width);
12
- flex-direction: column;
13
- justify-content: center;
14
- padding: 16px 12px 16px var(--hj-copy-pad-x);
15
- color: var(--hj-copy-color, var(--hj-ink));
16
- background: var(--hj-copy-bg, var(--hj-copy-gradient));
17
- pointer-events: none;
18
- }
19
-
20
- .hj-capsule-code {
21
- margin-bottom: 8px;
22
- color: var(--hj-muted);
23
- font-family: var(--hj-mono);
24
- font-size: 9px;
25
- letter-spacing: 0.16em;
26
- text-transform: uppercase;
27
- }
28
-
29
- .hj-capsule-name {
30
- display: block;
31
- font-size: var(--hj-name-size);
32
- font-weight: 650;
33
- line-height: 1;
34
- letter-spacing: 0.04em;
35
- white-space: nowrap;
36
- }
37
-
38
- .hj-capsule-brand {
39
- display: block;
40
- margin-top: 10px;
41
- font-size: 12px;
42
- font-weight: 520;
43
- }
44
-
45
- .hj-capsule-state {
46
- display: block;
47
- margin-top: 5px;
48
- color: #9d7a35;
49
- font-family: var(--hj-mono);
50
- font-size: 7px;
51
- letter-spacing: 0.14em;
52
- line-height: 1.4;
53
- text-transform: uppercase;
54
- }
55
-
56
- .hj-capsule-root[data-theme="dark"] {
57
- border: 0;
58
- background: #202126;
59
- box-shadow: none;
60
- }
61
-
62
- .hj-capsule-root[data-theme="dark"] .hj-capsule-copy {
63
- color: #ffffff;
64
- --hj-copy-gradient: linear-gradient(
65
- 90deg,
66
- #202126 0%,
67
- #202126 72%,
68
- rgba(32, 33, 38, 0.98) 84%,
69
- rgba(32, 33, 38, 0) 100%
70
- );
71
- background: var(--hj-copy-gradient);
72
- }
73
-
74
- .hj-capsule-root[data-theme="dark"] .hj-capsule-code,
75
- .hj-capsule-root[data-theme="dark"] .hj-capsule-brand {
76
- color: rgba(255, 255, 255, 0.72);
77
- }
78
-
79
- .hj-capsule-root[data-theme="dark"] .hj-capsule-state {
80
- color: #6be7dc;
81
- }
1
+ /* ---------- Cosmic capsule slot layers ---------- */
2
+
3
+ /* Text slot container: geometry only. No typography, padding or background
4
+ is imposed on slot content. .hj-capsule-copy is kept as a legacy alias for
5
+ user CSS; the old built-in text styles were removed with the copy API. */
6
+ .hj-capsule-text {
7
+ position: absolute;
8
+ top: 0;
9
+ bottom: 0;
10
+ left: 0;
11
+ z-index: 4;
12
+ width: var(--hj-text-width, var(--hj-copy-width, 39%));
13
+ min-width: var(--hj-text-min-width, var(--hj-copy-min-width, 164px));
14
+ border-radius: var(--hj-text-radius, 0);
15
+ overflow: hidden;
16
+ pointer-events: none;
17
+ }
18
+
19
+ /* Color slot container: the region right of the text area, above the canvas. */
20
+ .hj-capsule-visual {
21
+ position: absolute;
22
+ top: 0;
23
+ bottom: 0;
24
+ left: var(--hj-text-width, var(--hj-copy-width, 39%));
25
+ right: 0;
26
+ z-index: 3;
27
+ pointer-events: none;
28
+ }
29
+
30
+ .hj-capsule-root[data-theme="dark"] {
31
+ border: 0;
32
+ background: #202126;
33
+ box-shadow: none;
34
+ }
@@ -10,11 +10,20 @@
10
10
  user-select: none;
11
11
  }
12
12
 
13
- .hj-progress-root[data-draggable="false"] {
14
- cursor: default;
15
- }
16
-
17
- .hj-progress-root:focus-visible {
13
+ .hj-progress-root[data-draggable="false"] {
14
+ cursor: default;
15
+ }
16
+
17
+ .hj-progress-root.is-disabled {
18
+ cursor: default;
19
+ opacity: 0.55;
20
+ }
21
+
22
+ .hj-progress-root.is-disabled:focus-visible {
23
+ outline: none;
24
+ }
25
+
26
+ .hj-progress-root:focus-visible {
18
27
  outline: 2px solid rgba(255, 255, 255, 0.8);
19
28
  outline-offset: 4px;
20
29
  }
@@ -35,39 +44,29 @@
35
44
  filter: saturate(1.15) brightness(1.08);
36
45
  }
37
46
 
38
- .hj-progress-copy {
39
- position: absolute;
40
- top: 50%;
41
- left: var(--hj-copy-left);
42
- z-index: 4;
43
- display: flex;
44
- max-width: var(--hj-copy-max-width);
45
- flex-direction: column;
46
- gap: 5px;
47
- padding: var(--hj-progress-copy-pad, 0);
48
- border-radius: 8px;
49
- background: var(--hj-progress-copy-bg, transparent);
50
- color: var(--hj-progress-copy-color, #ffffff);
51
- transform: translateY(-50%);
52
- pointer-events: none;
53
- }
54
-
55
- .hj-progress-name {
56
- font-family: var(--hj-font);
57
- font-size: 20px;
58
- font-weight: 650;
59
- line-height: 1;
60
- letter-spacing: 0.10em;
61
- white-space: nowrap;
62
- }
63
-
64
- .hj-progress-subtitle {
65
- color: rgba(255, 255, 255, 0.42);
66
- font-size: 8px;
67
- font-weight: 600;
68
- letter-spacing: 0.08em;
69
- white-space: nowrap;
70
- }
47
+ /* Text slot container: geometry only (same convention as capsule). */
48
+ .hj-progress-text {
49
+ position: absolute;
50
+ top: 50%;
51
+ left: var(--hj-text-left, var(--hj-copy-left, 30px));
52
+ z-index: 4;
53
+ width: var(--hj-text-width, var(--hj-copy-max-width, 54%));
54
+ border-radius: var(--hj-text-radius, 0);
55
+ overflow: hidden;
56
+ transform: translateY(-50%);
57
+ pointer-events: none;
58
+ }
59
+
60
+ /* Color slot container: region right of the text area. */
61
+ .hj-progress-visual {
62
+ position: absolute;
63
+ top: 0;
64
+ bottom: 0;
65
+ left: var(--hj-text-width, var(--hj-copy-max-width, 54%));
66
+ right: 0;
67
+ z-index: 3;
68
+ pointer-events: none;
69
+ }
71
70
 
72
71
  .hj-progress-value {
73
72
  position: absolute;
@@ -86,22 +85,3 @@
86
85
  pointer-events: none;
87
86
  }
88
87
 
89
- .hj-progress-drag-label {
90
- position: absolute;
91
- right: 32px;
92
- bottom: 11px;
93
- z-index: 5;
94
- color: rgba(255, 255, 255, 0.28);
95
- font-family: var(--hj-mono);
96
- font-size: 7px;
97
- letter-spacing: 0.18em;
98
- opacity: 0;
99
- transition: opacity 160ms ease;
100
- pointer-events: none;
101
- }
102
-
103
- .hj-progress-root:hover .hj-progress-drag-label,
104
- .hj-progress-root:focus-visible .hj-progress-drag-label,
105
- .hj-progress-root.is-dragging .hj-progress-drag-label {
106
- opacity: 1;
107
- }
package/types/index.d.ts CHANGED
@@ -25,60 +25,59 @@ export interface ProgressPreset {
25
25
  colors: ColorTuple;
26
26
  }
27
27
 
28
- export interface Copy {
29
- brandName: string;
30
- dragLabel: string;
31
- valueSuffix: string;
32
- progressAria: string;
33
- capsuleAria: string;
34
- enabled?: boolean;
35
- code?: string;
36
- name?: string;
37
- subtitle?: string;
38
- state?: string;
39
- background?: string;
40
- color?: string;
41
- }
42
-
43
- export interface CapsuleOptions {
44
- preset?: string | CapsulePreset;
45
- width?: number | string;
28
+ export interface Copy {
29
+ brandName: string;
30
+ valueSuffix: string;
31
+ progressAria: string;
32
+ capsuleAria: string;
33
+ }
34
+
35
+ export interface CapsuleOptions {
36
+ preset?: string;
37
+ width?: number | string;
46
38
  height?: number | string;
47
- colors?: string[];
48
- seed?: number;
49
- speed?: number;
50
- interactive?: boolean;
51
- renderer?: 'auto' | 'webgl2' | 'canvas2d';
52
- showCopy?: boolean;
53
- quality?: Quality;
54
- respectReducedMotion?: boolean;
55
- copy?: Partial<Copy>;
56
- cssVars?: Record<string, string>;
57
- [key: string]: unknown;
58
- }
59
-
60
- export interface ProgressOptions {
61
- preset?: string | ProgressPreset;
39
+ colors?: string[];
40
+ seed?: number;
41
+ speed?: number;
42
+ textRatio?: number;
43
+ text?: string | Node | Node[];
44
+ colorContent?: string | Node | Node[];
45
+ label?: string;
46
+ mouseColor?: boolean;
47
+ renderer?: 'auto' | 'webgl2' | 'canvas2d';
48
+ quality?: Quality;
49
+ respectReducedMotion?: boolean;
50
+ cssVars?: Record<string, string>;
51
+ [key: string]: unknown;
52
+ }
53
+
54
+ export interface ProgressOptions {
55
+ preset?: string;
62
56
  width?: number | string;
63
57
  height?: number | string;
64
58
  value?: number;
65
59
  min?: number;
66
60
  max?: number;
67
- draggable?: boolean;
68
- keyboard?: boolean;
69
- edgeStyle?: 'flow' | 'tide';
70
- colors?: string[];
71
- renderer?: 'auto' | 'webgl2' | 'canvas2d';
72
- showCopy?: boolean;
73
- quality?: Quality;
74
- respectReducedMotion?: boolean;
75
- copy?: Partial<Copy>;
76
- cssVars?: Record<string, string>;
77
- [key: string]: unknown;
78
- }
79
-
80
- export interface ColorBackgroundOptions {
81
- preset?: string | CapsulePreset;
61
+ draggable?: boolean;
62
+ keyboard?: boolean;
63
+ disabled?: boolean;
64
+ valueSuffix?: string;
65
+ edgeStyle?: 'flow' | 'tide';
66
+ colors?: string[];
67
+ textRatio?: number;
68
+ text?: string | Node | Node[];
69
+ colorContent?: string | Node | Node[];
70
+ label?: string;
71
+ showValue?: boolean;
72
+ renderer?: 'auto' | 'webgl2' | 'canvas2d';
73
+ quality?: Quality;
74
+ respectReducedMotion?: boolean;
75
+ cssVars?: Record<string, string>;
76
+ [key: string]: unknown;
77
+ }
78
+
79
+ export interface ColorBackgroundOptions {
80
+ preset?: string;
82
81
  colors?: string[];
83
82
  seed?: number;
84
83
  speed?: number;
@@ -98,11 +97,18 @@ export interface Emitter {
98
97
 
99
98
  export interface CapsuleController extends Emitter {
100
99
  element: HTMLElement;
101
- canvas: HTMLCanvasElement;
102
- preset: CapsulePreset;
103
- setPreset(ref: string | CapsulePreset): this;
104
- setColors(colors: string[]): this;
105
- setSize(width?: number | string, height?: number | string): this;
100
+ canvas: HTMLCanvasElement;
101
+ preset: CapsulePreset;
102
+ setPreset(ref: string): this;
103
+ setColors(colors: string[]): this;
104
+ setSeed(seed: number): this;
105
+ setSpeed(speed: number): this;
106
+ setText(content: string | Node | Node[]): this;
107
+ setColorContent(content: string | Node | Node[]): this;
108
+ setTextRatio(ratio: number): this;
109
+ setCssVars(vars: Record<string, string>): this;
110
+ setLabel(label: string): this;
111
+ setSize(width?: number | string, height?: number | string): this;
106
112
  randomize(): this;
107
113
  pause(): this;
108
114
  resume(): this;
@@ -110,18 +116,25 @@ export interface CapsuleController extends Emitter {
110
116
  dispose(): void;
111
117
  }
112
118
 
113
- export interface ProgressController extends Emitter {
114
- element: HTMLElement;
115
- canvas: HTMLCanvasElement;
116
- preset: ProgressPreset;
117
- setValue(value: number, source?: string): this;
118
- getValue(): number;
119
- setRange(min: number, max: number): this;
120
- setPreset(ref: string | ProgressPreset): this;
121
- setColors(colors: string[]): this;
122
- setSize(width?: number | string, height?: number | string): this;
123
- randomize(): this;
124
- pause(): this;
119
+ export interface ProgressController extends Emitter {
120
+ element: HTMLElement;
121
+ canvas: HTMLCanvasElement;
122
+ preset: ProgressPreset;
123
+ setValue(value: number, source?: string): this;
124
+ getValue(): number;
125
+ setRange(min: number, max: number): this;
126
+ setPreset(ref: string): this;
127
+ setColors(colors: string[]): this;
128
+ setEdgeStyle(style: 'flow' | 'tide'): this;
129
+ setText(content: string | Node | Node[]): this;
130
+ setColorContent(content: string | Node | Node[]): this;
131
+ setTextRatio(ratio: number): this;
132
+ setCssVars(vars: Record<string, string>): this;
133
+ setLabel(label: string): this;
134
+ setValueSuffix(suffix: string): this;
135
+ setSize(width?: number | string, height?: number | string): this;
136
+ randomize(): this;
137
+ pause(): this;
125
138
  resume(): this;
126
139
  setQuality(quality: Quality): this;
127
140
  dispose(): void;
@@ -132,9 +145,13 @@ export interface ColorBackgroundController extends Emitter {
132
145
  layer: HTMLElement;
133
146
  canvas: HTMLCanvasElement;
134
147
  preset: CapsulePreset;
135
- setPreset(ref: string | CapsulePreset): this;
136
- setColors(colors: string[]): this;
137
- setQuality(quality: Quality): this;
148
+ setPreset(ref: string): this;
149
+ setColors(colors: string[]): this;
150
+ setSeed(seed: number): this;
151
+ setSpeed(speed: number): this;
152
+ setFallbackColor(value: boolean | string): this;
153
+ setMouseColor(value: boolean): this;
154
+ setQuality(quality: Quality): this;
138
155
  setOpacity(value: number): this;
139
156
  randomize(): this;
140
157
  pause(): this;
@@ -156,17 +173,15 @@ export declare function createCapsule(container: HTMLElement, options?: CapsuleO
156
173
  export declare function createProgressCapsule(container: HTMLElement, options?: ProgressOptions): ProgressController;
157
174
  export declare function createColorBackground(host: HTMLElement, options?: ColorBackgroundOptions): ColorBackgroundController;
158
175
 
159
- export declare const PRESETS: CapsulePreset[];
160
- export declare const PROGRESS_PRESETS: ProgressPreset[];
161
- export declare const ALL_PRESETS: Array<CapsulePreset | ProgressPreset>;
162
- export declare function validatePreset(preset: CapsulePreset): boolean;
163
- export declare function validateProgressPreset(preset: ProgressPreset): boolean;
164
- export declare function getPreset(kind: 'capsule' | 'progress', ref: string): CapsulePreset | ProgressPreset;
176
+ export declare const PRESETS: CapsulePreset[];
177
+ export declare const PROGRESS_PRESETS: ProgressPreset[];
178
+ export declare const ALL_PRESETS: Array<CapsulePreset | ProgressPreset>;
179
+ export declare function getPreset(kind: 'capsule' | 'progress', ref: string): CapsulePreset | ProgressPreset;
165
180
 
166
- export declare const DEFAULTS: {
167
- capsule: Required<Pick<CapsuleOptions, 'width' | 'height' | 'quality' | 'respectReducedMotion' | 'interactive' | 'mouseColor' | 'renderer' | 'showCopy'>>;
168
- progress: Required<Pick<ProgressOptions, 'width' | 'height' | 'min' | 'max' | 'draggable' | 'keyboard' | 'edgeStyle' | 'quality' | 'respectReducedMotion' | 'renderer' | 'showCopy'>>;
169
- };
181
+ export declare const DEFAULTS: {
182
+ capsule: Required<Pick<CapsuleOptions, 'width' | 'height' | 'quality' | 'respectReducedMotion' | 'mouseColor' | 'renderer' | 'textRatio'>>;
183
+ progress: Required<Pick<ProgressOptions, 'width' | 'height' | 'min' | 'max' | 'draggable' | 'keyboard' | 'disabled' | 'valueSuffix' | 'edgeStyle' | 'quality' | 'respectReducedMotion' | 'renderer' | 'textRatio' | 'showValue'>>;
184
+ };
170
185
 
171
186
  export declare const COPY: Copy;
172
187
  export declare function parseSize(value: number | string): string;
@@ -174,9 +189,10 @@ export declare const QUALITY_TIERS: Record<'low' | 'medium' | 'high', { dpr: num
174
189
  export declare function dprCapFor(quality: Quality): number;
175
190
  export declare function pauseAll(): void;
176
191
  export declare function resumeAll(): void;
177
- export declare function hexToRgb01(hex: string): [number, number, number];
178
- export declare function hexToRgba(hex: string, alpha?: number): string;
179
- export declare function validateColors(colors: unknown): boolean;
192
+ export declare function hexToRgb01(hex: string): [number, number, number];
193
+ export declare function hexToRgba(hex: string, alpha?: number): string;
194
+ export declare function normalizeColor(color: string): string | null;
195
+ export declare function validateColors(colors: unknown): boolean;
180
196
 
181
197
  export declare class CosmicRenderer {
182
198
  constructor(canvas: HTMLCanvasElement, preset: CapsulePreset, options?: { dprCap?: number });
package/types/vue3.d.ts CHANGED
@@ -11,10 +11,15 @@ export interface CosmicCapsuleComponent {
11
11
  randomize(): any;
12
12
  pause(): any;
13
13
  resume(): any;
14
- setPreset(preset: CapsuleOptions['preset']): any;
15
- setSize(width?: number | string, height?: number | string): any;
16
- setColors(colors: string[]): any;
17
- setQuality(quality: CapsuleOptions['quality']): any;
14
+ setPreset(preset: CapsuleOptions['preset']): any;
15
+ setSize(width?: number | string, height?: number | string): any;
16
+ setColors(colors: string[]): any;
17
+ setText(content: string | Node | Node[]): any;
18
+ setColorContent(content: string | Node | Node[]): any;
19
+ setTextRatio(ratio: number): any;
20
+ setCssVars(vars: Record<string, string>): any;
21
+ setLabel(label: string): any;
22
+ setQuality(quality: CapsuleOptions['quality']): any;
18
23
  getController(): any;
19
24
  };
20
25
  }
@@ -26,22 +31,56 @@ export interface ProgressCapsuleComponent {
26
31
  mounted: () => void;
27
32
  beforeUnmount: () => void;
28
33
  render: (h: Function) => any;
29
- methods: {
30
- setValue(value: number): any;
31
- getValue(): number | undefined;
32
- setRange(min: number, max: number): any;
34
+ methods: {
35
+ setValue(value: number): any;
36
+ getValue(): number | undefined;
37
+ setRange(min: number, max: number): any;
33
38
  randomize(): any;
34
39
  pause(): any;
35
40
  resume(): any;
36
- setPreset(preset: ProgressOptions['preset']): any;
37
- setSize(width?: number | string, height?: number | string): any;
38
- setColors(colors: string[]): any;
39
- setQuality(quality: ProgressOptions['quality']): any;
40
- getController(): any;
41
- };
42
- }
43
-
44
- export declare const CosmicCapsule: CosmicCapsuleComponent;
45
- export declare const ProgressCapsule: ProgressCapsuleComponent;
46
- declare const _default: { CosmicCapsule: CosmicCapsuleComponent; ProgressCapsule: ProgressCapsuleComponent };
47
- export default _default;
41
+ setPreset(preset: ProgressOptions['preset']): any;
42
+ setSize(width?: number | string, height?: number | string): any;
43
+ setColors(colors: string[]): any;
44
+ setText(content: string | Node | Node[]): any;
45
+ setColorContent(content: string | Node | Node[]): any;
46
+ setTextRatio(ratio: number): any;
47
+ setCssVars(vars: Record<string, string>): any;
48
+ setLabel(label: string): any;
49
+ setValueSuffix(suffix: string): any;
50
+ setQuality(quality: ProgressOptions['quality']): any;
51
+ getController(): any;
52
+ };
53
+ }
54
+
55
+ export interface ColorBackgroundComponent {
56
+ name: 'ColorBackground';
57
+ props: (keyof import('./index').ColorBackgroundOptions)[];
58
+ emits: string[];
59
+ mounted: () => void;
60
+ beforeUnmount: () => void;
61
+ render: (h: Function) => any;
62
+ methods: {
63
+ setPreset(preset: string): any;
64
+ setColors(colors: string[]): any;
65
+ setSeed(seed: number): any;
66
+ setSpeed(speed: number): any;
67
+ setQuality(quality: string): any;
68
+ setOpacity(value: number): any;
69
+ setFallbackColor(value: boolean | string): any;
70
+ setMouseColor(value: boolean): any;
71
+ randomize(): any;
72
+ pause(): any;
73
+ resume(): any;
74
+ getController(): any;
75
+ };
76
+ }
77
+
78
+ export declare const CosmicCapsule: CosmicCapsuleComponent;
79
+ export declare const ProgressCapsule: ProgressCapsuleComponent;
80
+ export declare const ColorBackground: ColorBackgroundComponent;
81
+ declare const _default: {
82
+ CosmicCapsule: CosmicCapsuleComponent;
83
+ ProgressCapsule: ProgressCapsuleComponent;
84
+ ColorBackground: ColorBackgroundComponent;
85
+ };
86
+ export default _default;