juxscript 1.0.15 → 1.0.17
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/lib/components/docs-data.json +7 -1
- package/package.json +1 -1
- package/presets/notion.css +1143 -288
- package/lib/components/hero1/hero1.ts +0 -196
- package/lib/components/hero1/index.js +0 -4
- package/presets/global.css +0 -1130
- package/presets/notion.jux +0 -27
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { getOrCreateContainer } from '../helpers.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Hero component options
|
|
5
|
-
*/
|
|
6
|
-
export interface HeroOptions {
|
|
7
|
-
title?: string;
|
|
8
|
-
subtitle?: string;
|
|
9
|
-
cta?: string;
|
|
10
|
-
ctaLink?: string;
|
|
11
|
-
backgroundImage?: string;
|
|
12
|
-
variant?: 'default' | 'centered' | 'split';
|
|
13
|
-
style?: string;
|
|
14
|
-
class?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Hero component state
|
|
19
|
-
*/
|
|
20
|
-
type HeroState = {
|
|
21
|
-
title: string;
|
|
22
|
-
subtitle: string;
|
|
23
|
-
cta: string;
|
|
24
|
-
ctaLink: string;
|
|
25
|
-
backgroundImage: string;
|
|
26
|
-
variant: string;
|
|
27
|
-
style: string;
|
|
28
|
-
class: string;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Hero component
|
|
33
|
-
*
|
|
34
|
-
* Usage:
|
|
35
|
-
* const hero = jux.hero('myHero', {
|
|
36
|
-
* title: 'Welcome',
|
|
37
|
-
* subtitle: 'Get started today',
|
|
38
|
-
* cta: 'Learn More'
|
|
39
|
-
* });
|
|
40
|
-
* hero.render();
|
|
41
|
-
*/
|
|
42
|
-
export class Hero1 {
|
|
43
|
-
state: HeroState;
|
|
44
|
-
container: HTMLElement | null = null;
|
|
45
|
-
_id: string;
|
|
46
|
-
id: string;
|
|
47
|
-
|
|
48
|
-
constructor(id: string, options: HeroOptions = {}) {
|
|
49
|
-
this._id = id;
|
|
50
|
-
this.id = id;
|
|
51
|
-
|
|
52
|
-
this.state = {
|
|
53
|
-
title: options.title ?? '',
|
|
54
|
-
subtitle: options.subtitle ?? '',
|
|
55
|
-
cta: options.cta ?? '',
|
|
56
|
-
ctaLink: options.ctaLink ?? '#',
|
|
57
|
-
backgroundImage: options.backgroundImage ?? '',
|
|
58
|
-
variant: options.variant ?? 'default',
|
|
59
|
-
style: options.style ?? '',
|
|
60
|
-
class: options.class ?? ''
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/* -------------------------
|
|
65
|
-
* Fluent API
|
|
66
|
-
* ------------------------- */
|
|
67
|
-
|
|
68
|
-
title(value: string): this {
|
|
69
|
-
this.state.title = value;
|
|
70
|
-
return this;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
subtitle(value: string): this {
|
|
74
|
-
this.state.subtitle = value;
|
|
75
|
-
return this;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
cta(value: string): this {
|
|
79
|
-
this.state.cta = value;
|
|
80
|
-
return this;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
ctaLink(value: string): this {
|
|
84
|
-
this.state.ctaLink = value;
|
|
85
|
-
return this;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
backgroundImage(value: string): this {
|
|
89
|
-
this.state.backgroundImage = value;
|
|
90
|
-
return this;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
variant(value: string): this {
|
|
94
|
-
this.state.variant = value;
|
|
95
|
-
return this;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
style(value: string): this {
|
|
99
|
-
this.state.style = value;
|
|
100
|
-
return this;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
class(value: string): this {
|
|
104
|
-
this.state.class = value;
|
|
105
|
-
return this;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/* -------------------------
|
|
109
|
-
* Render
|
|
110
|
-
* ------------------------- */
|
|
111
|
-
|
|
112
|
-
render(targetId?: string): this {
|
|
113
|
-
let container: HTMLElement;
|
|
114
|
-
|
|
115
|
-
if (targetId) {
|
|
116
|
-
const target = document.querySelector(targetId);
|
|
117
|
-
if (!target || !(target instanceof HTMLElement)) {
|
|
118
|
-
throw new Error(`Hero: Target element "${targetId}" not found`);
|
|
119
|
-
}
|
|
120
|
-
container = target;
|
|
121
|
-
} else {
|
|
122
|
-
container = getOrCreateContainer(this._id);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
this.container = container;
|
|
126
|
-
const { title, subtitle, cta, ctaLink, backgroundImage, variant, style, class: className } = this.state;
|
|
127
|
-
|
|
128
|
-
const hero = document.createElement('div');
|
|
129
|
-
hero.className = `jux-hero jux-hero-${variant}`;
|
|
130
|
-
hero.id = this._id;
|
|
131
|
-
|
|
132
|
-
if (className) {
|
|
133
|
-
hero.className += ` ${className}`;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (style) {
|
|
137
|
-
hero.setAttribute('style', style);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (backgroundImage) {
|
|
141
|
-
hero.style.backgroundImage = `url(${backgroundImage})`;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const content = document.createElement('div');
|
|
145
|
-
content.className = 'jux-hero-content';
|
|
146
|
-
|
|
147
|
-
if (title) {
|
|
148
|
-
const titleEl = document.createElement('h1');
|
|
149
|
-
titleEl.className = 'jux-hero-title';
|
|
150
|
-
titleEl.textContent = title;
|
|
151
|
-
content.appendChild(titleEl);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (subtitle) {
|
|
155
|
-
const subtitleEl = document.createElement('p');
|
|
156
|
-
subtitleEl.className = 'jux-hero-subtitle';
|
|
157
|
-
subtitleEl.textContent = subtitle;
|
|
158
|
-
content.appendChild(subtitleEl);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (cta) {
|
|
162
|
-
const ctaEl = document.createElement('a');
|
|
163
|
-
ctaEl.className = 'jux-hero-cta jux-button jux-button-primary';
|
|
164
|
-
ctaEl.href = ctaLink;
|
|
165
|
-
ctaEl.textContent = cta;
|
|
166
|
-
content.appendChild(ctaEl);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
hero.appendChild(content);
|
|
170
|
-
container.appendChild(hero);
|
|
171
|
-
|
|
172
|
-
return this;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Render to another Jux component's container
|
|
177
|
-
*/
|
|
178
|
-
renderTo(juxComponent: any): this {
|
|
179
|
-
if (!juxComponent || typeof juxComponent !== 'object') {
|
|
180
|
-
throw new Error('Hero.renderTo: Invalid component - not an object');
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (!juxComponent._id || typeof juxComponent._id !== 'string') {
|
|
184
|
-
throw new Error('Hero.renderTo: Invalid component - missing _id (not a Jux component)');
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return this.render(`#${juxComponent._id}`);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Factory helper
|
|
193
|
-
*/
|
|
194
|
-
export function hero1(id: string, options: HeroOptions = {}): Hero1 {
|
|
195
|
-
return new Hero1(id, options);
|
|
196
|
-
}
|