@mccustomapps/helaui 0.1.0 → 0.1.2
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/README.md +339 -0
- package/package.json +4 -3
- package/src/assets/rain/builtinImages.ts +7 -0
- package/src/assets/rain/fritter.png +0 -0
- package/src/assets/rain/kokis.png +0 -0
- package/src/assets/rain/leaf.png +0 -0
- package/src/assets/rain/swirl.png +0 -0
- package/src/assets/sun-mandala/builtinImage.ts +4 -0
- package/src/assets/sun-mandala/ira-handa.jpg +0 -0
- package/src/assets/sun-mandala/ira-handa.png +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
# HelaUI — `@mccustomapps/helaui`
|
|
2
|
+
|
|
3
|
+
> Sri Lankan-flavoured UI component library with **Sinhala font** support, a traditional **Sinhala calendar**, a **rain background** effect, and the iconic **Ira Handa sun mandala** (ඉර හඳ / සූර්ය මණ්ඩලය).
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@mccustomapps/helaui)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://www.npmjs.com/package/@mccustomapps/helaui)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Table of Contents
|
|
12
|
+
|
|
13
|
+
- [Installation](#installation)
|
|
14
|
+
- [Quick Start](#quick-start)
|
|
15
|
+
- [Components](#components)
|
|
16
|
+
- [TextField](#textfield)
|
|
17
|
+
- [Calendar](#calendar)
|
|
18
|
+
- [SunMandala](#sunmandala)
|
|
19
|
+
- [RainBackground](#rainbackground)
|
|
20
|
+
- [Theming](#theming)
|
|
21
|
+
- [i18n / Localisation](#i18n--localisation)
|
|
22
|
+
- [CSS Imports](#css-imports)
|
|
23
|
+
- [TypeScript](#typescript)
|
|
24
|
+
- [License](#license)
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install @mccustomapps/helaui
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
// Import the CSS for the components you use
|
|
40
|
+
import '@mccustomapps/helaui/textfield.css';
|
|
41
|
+
import '@mccustomapps/helaui/calendar.css';
|
|
42
|
+
import '@mccustomapps/helaui/sun-mandala.css';
|
|
43
|
+
import '@mccustomapps/helaui/rain-background.css';
|
|
44
|
+
import '@mccustomapps/helaui/sinhala.css'; // Sinhala font face
|
|
45
|
+
import '@mccustomapps/helaui/theme.css'; // CSS custom-property tokens
|
|
46
|
+
|
|
47
|
+
// Import components
|
|
48
|
+
import { TextField, Calendar, SunMandala, RainBackground } from '@mccustomapps/helaui';
|
|
49
|
+
|
|
50
|
+
// Mount components
|
|
51
|
+
const field = new TextField({ variant: 'name' });
|
|
52
|
+
document.body.appendChild(field.element);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Components
|
|
58
|
+
|
|
59
|
+
### TextField
|
|
60
|
+
|
|
61
|
+
A locale-aware text input with built-in Sinhala font support.
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
import { TextField } from '@mccustomapps/helaui';
|
|
65
|
+
import '@mccustomapps/helaui/textfield.css';
|
|
66
|
+
|
|
67
|
+
const field = new TextField({
|
|
68
|
+
variant: 'name', // 'name' | 'password' | 'email' | 'disabled'
|
|
69
|
+
type: 'text', // 'text' | 'password' | 'email'
|
|
70
|
+
label: 'Your Name', // explicit label (overrides variant)
|
|
71
|
+
placeholder: 'Enter name',
|
|
72
|
+
value: '',
|
|
73
|
+
sinhala: true, // force Sinhala font
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
document.getElementById('container').appendChild(field.element);
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Options — `TextFieldOptions`**
|
|
80
|
+
|
|
81
|
+
| Option | Type | Default | Description |
|
|
82
|
+
|---|---|---|---|
|
|
83
|
+
| `variant` | `TextFieldVariant` | — | Resolves label & placeholder from locale |
|
|
84
|
+
| `label` | `string` | — | Explicit label text |
|
|
85
|
+
| `placeholder` | `string` | — | Explicit placeholder text |
|
|
86
|
+
| `type` | `'text' \| 'password' \| 'email'` | `'text'` | Input type |
|
|
87
|
+
| `value` | `string` | — | Initial value |
|
|
88
|
+
| `id` | `string` | auto | HTML id attribute |
|
|
89
|
+
| `sinhala` | `boolean` | auto | Force Sinhala font class |
|
|
90
|
+
| `labelKey` | `string` | — | i18n dot-path for label |
|
|
91
|
+
| `placeholderKey` | `string` | — | i18n dot-path for placeholder |
|
|
92
|
+
|
|
93
|
+
**Methods**
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
field.getValue() // → string
|
|
97
|
+
field.setValue('hello')
|
|
98
|
+
field.setLabel('Name / නම')
|
|
99
|
+
field.setPlaceholder('Type here…')
|
|
100
|
+
field.setDisabled(true)
|
|
101
|
+
field.setSinhala(true)
|
|
102
|
+
field.focus()
|
|
103
|
+
field.destroy() // removes locale subscription
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
### Calendar
|
|
109
|
+
|
|
110
|
+
A from-scratch **Sinhala calendar** with Buddhist Era (බුද්ධ වර්ෂ) and Poya day support.
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
import { Calendar } from '@mccustomapps/helaui';
|
|
114
|
+
import '@mccustomapps/helaui/calendar.css';
|
|
115
|
+
|
|
116
|
+
const calendar = new Calendar({
|
|
117
|
+
value: new Date(),
|
|
118
|
+
showBuddhistEra: true,
|
|
119
|
+
onSelect: (date, sinhalaFormatted) => {
|
|
120
|
+
console.log(sinhalaFormatted); // e.g. "2567 දුරුතු 15"
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
document.getElementById('container').appendChild(calendar.element);
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Options — `CalendarOptions`**
|
|
128
|
+
|
|
129
|
+
| Option | Type | Default | Description |
|
|
130
|
+
|---|---|---|---|
|
|
131
|
+
| `value` | `Date` | today | Initially selected date |
|
|
132
|
+
| `showBuddhistEra` | `boolean` | `false` | Prefix year with Buddhist Era |
|
|
133
|
+
| `onSelect` | `(date: Date, formatted: string) => void` | — | Selection callback |
|
|
134
|
+
|
|
135
|
+
**Methods**
|
|
136
|
+
|
|
137
|
+
```js
|
|
138
|
+
calendar.setShowBuddhistEra(true)
|
|
139
|
+
calendar.getValue() // → Date | null
|
|
140
|
+
calendar.destroy()
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Helpers**
|
|
144
|
+
|
|
145
|
+
```js
|
|
146
|
+
import { formatSinhalaNumeral, SINHALA_MONTH_NAMES } from '@mccustomapps/helaui';
|
|
147
|
+
|
|
148
|
+
formatSinhalaNumeral(2025); // → 'ෲ෦ෲ'
|
|
149
|
+
SINHALA_MONTH_NAMES; // ['දුරුතු', 'නවම්', …]
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
### SunMandala
|
|
155
|
+
|
|
156
|
+
The traditional Sri Lankan **Ira Handa** (ඉර හඳ) sun face mandala. The central face stays **stationary** while the surrounding **aura** (rays, lotus rings, and sacred motifs) rotates continuously.
|
|
157
|
+
|
|
158
|
+
```js
|
|
159
|
+
import { SunMandala } from '@mccustomapps/helaui';
|
|
160
|
+
import '@mccustomapps/helaui/sun-mandala.css';
|
|
161
|
+
|
|
162
|
+
const mandala = new SunMandala({
|
|
163
|
+
size: '320px', // width & height — any CSS length
|
|
164
|
+
duration: 30, // rotation cycle in seconds (lower = faster)
|
|
165
|
+
faceRadius: '22%', // clip radius of the stationary face overlay
|
|
166
|
+
paused: false, // start paused?
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
document.getElementById('container').appendChild(mandala.element);
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Options — `SunMandalaOptions`**
|
|
173
|
+
|
|
174
|
+
| Option | Type | Default | Description |
|
|
175
|
+
|---|---|---|---|
|
|
176
|
+
| `src` | `string` | built-in | Custom image URL |
|
|
177
|
+
| `alt` | `string` | `'Sri Lankan Ira Handa sun mandala'` | ARIA label |
|
|
178
|
+
| `size` | `string` | `'280px'` | Width & height (any CSS unit) |
|
|
179
|
+
| `duration` | `number` | `36` | Full rotation time in seconds |
|
|
180
|
+
| `faceRadius` | `string` | `'22%'` | Clip radius of the static face overlay |
|
|
181
|
+
| `paused` | `boolean` | `false` | Start with rotation paused |
|
|
182
|
+
|
|
183
|
+
**Methods**
|
|
184
|
+
|
|
185
|
+
```js
|
|
186
|
+
mandala.setPaused(true) // pause / resume
|
|
187
|
+
mandala.isPaused() // → boolean
|
|
188
|
+
mandala.setDuration(10) // change speed (seconds per full rotation)
|
|
189
|
+
mandala.setSize('400px') // resize
|
|
190
|
+
mandala.setFaceRadius('20%') // adjust face clip radius
|
|
191
|
+
mandala.destroy() // remove from DOM
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**Use your own image**
|
|
195
|
+
|
|
196
|
+
```js
|
|
197
|
+
import { SunMandala, BUILTIN_SUN_MANDALA_IMAGE } from '@mccustomapps/helaui';
|
|
198
|
+
|
|
199
|
+
// Built-in Ira Handa artwork
|
|
200
|
+
const mandala = new SunMandala({ src: BUILTIN_SUN_MANDALA_IMAGE });
|
|
201
|
+
|
|
202
|
+
// Or bring your own circular mandala image
|
|
203
|
+
const mandala = new SunMandala({ src: '/my-mandala.png' });
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
### RainBackground
|
|
209
|
+
|
|
210
|
+
An animated **tropical rain** background with randomly falling rain streaks over a looping food-photography image.
|
|
211
|
+
|
|
212
|
+
```js
|
|
213
|
+
import { RainBackground } from '@mccustomapps/helaui';
|
|
214
|
+
import '@mccustomapps/helaui/rain-background.css';
|
|
215
|
+
|
|
216
|
+
const rain = new RainBackground();
|
|
217
|
+
document.body.insertBefore(rain.element, document.body.firstChild);
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
**Options — `RainBackgroundOptions`**
|
|
221
|
+
|
|
222
|
+
| Option | Type | Default | Description |
|
|
223
|
+
|---|---|---|---|
|
|
224
|
+
| `images` | `string[]` | built-in set | Background image URLs |
|
|
225
|
+
| `interval` | `number` | `5000` | Image crossfade interval (ms) |
|
|
226
|
+
|
|
227
|
+
**Helpers**
|
|
228
|
+
|
|
229
|
+
```js
|
|
230
|
+
import {
|
|
231
|
+
BUILTIN_RAIN_IMAGES,
|
|
232
|
+
DEFAULT_RAIN_IMAGES,
|
|
233
|
+
getDefaultRainImageUrls,
|
|
234
|
+
} from '@mccustomapps/helaui';
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Theming
|
|
240
|
+
|
|
241
|
+
HelaUI uses **CSS custom properties** for its design tokens.
|
|
242
|
+
|
|
243
|
+
```js
|
|
244
|
+
import '@mccustomapps/helaui/theme.css';
|
|
245
|
+
import { applyTheme, resetTheme, defaultTheme } from '@mccustomapps/helaui';
|
|
246
|
+
|
|
247
|
+
// Apply a custom palette to a container (or document.body)
|
|
248
|
+
applyTheme({
|
|
249
|
+
primary: '#8d153a',
|
|
250
|
+
secondary: '#f5a623',
|
|
251
|
+
success: '#27ae60',
|
|
252
|
+
accent: '#e74c3c',
|
|
253
|
+
black: '#111111',
|
|
254
|
+
white: '#ffffff',
|
|
255
|
+
grey: '#888888',
|
|
256
|
+
}, document.getElementById('app'));
|
|
257
|
+
|
|
258
|
+
// Reset to defaults
|
|
259
|
+
resetTheme(document.getElementById('app'));
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**`HelaTheme` keys:** `primary` · `secondary` · `success` · `accent` · `black` · `white` · `grey`
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## i18n / Localisation
|
|
267
|
+
|
|
268
|
+
HelaUI ships with **English** (`en`) and **Sinhala** (`si`) built-in.
|
|
269
|
+
|
|
270
|
+
```js
|
|
271
|
+
import {
|
|
272
|
+
applyTranslations,
|
|
273
|
+
setLocale,
|
|
274
|
+
getLocale,
|
|
275
|
+
subscribeLocaleChange,
|
|
276
|
+
t,
|
|
277
|
+
} from '@mccustomapps/helaui';
|
|
278
|
+
|
|
279
|
+
// Switch locale
|
|
280
|
+
setLocale('si');
|
|
281
|
+
|
|
282
|
+
// Translate a key
|
|
283
|
+
t('textField.name.label'); // → 'නම'
|
|
284
|
+
|
|
285
|
+
// Override / extend translations
|
|
286
|
+
applyTranslations({
|
|
287
|
+
locale: 'en',
|
|
288
|
+
overrides: {
|
|
289
|
+
en: {
|
|
290
|
+
textField: { name: { label: 'Full Name', placeholder: 'Enter full name' } },
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
// React to locale changes
|
|
296
|
+
const unsub = subscribeLocaleChange(() => {
|
|
297
|
+
console.log('Locale changed to', getLocale());
|
|
298
|
+
});
|
|
299
|
+
unsub(); // unsubscribe
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## CSS Imports
|
|
305
|
+
|
|
306
|
+
Import only what you need:
|
|
307
|
+
|
|
308
|
+
```js
|
|
309
|
+
import '@mccustomapps/helaui/theme.css'; // design tokens (required)
|
|
310
|
+
import '@mccustomapps/helaui/sinhala.css'; // Sinhala font face
|
|
311
|
+
import '@mccustomapps/helaui/textfield.css'; // TextField styles
|
|
312
|
+
import '@mccustomapps/helaui/calendar.css'; // Calendar styles
|
|
313
|
+
import '@mccustomapps/helaui/sun-mandala.css'; // SunMandala styles
|
|
314
|
+
import '@mccustomapps/helaui/rain-background.css'; // RainBackground styles
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
## TypeScript
|
|
320
|
+
|
|
321
|
+
Full TypeScript definitions are included. No `@types/` package needed.
|
|
322
|
+
|
|
323
|
+
```ts
|
|
324
|
+
import type {
|
|
325
|
+
TextFieldOptions,
|
|
326
|
+
CalendarOptions,
|
|
327
|
+
SunMandalaOptions,
|
|
328
|
+
RainBackgroundOptions,
|
|
329
|
+
HelaTheme,
|
|
330
|
+
HelaThemeKey,
|
|
331
|
+
HelaLocale,
|
|
332
|
+
} from '@mccustomapps/helaui';
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
## License
|
|
338
|
+
|
|
339
|
+
MIT © [mccustomapps](https://github.com/mccustomapps)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mccustomapps/helaui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "HelaUI components with Sinhala font support",
|
|
5
5
|
"author": "mccustomapps",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"./assets/sun-mandala/*": "./dist/assets/sun-mandala/*"
|
|
32
32
|
},
|
|
33
33
|
"files": [
|
|
34
|
-
"dist"
|
|
34
|
+
"dist",
|
|
35
|
+
"src/assets/**"
|
|
35
36
|
],
|
|
36
37
|
"sideEffects": [
|
|
37
38
|
"**/*.css"
|
|
@@ -49,4 +50,4 @@
|
|
|
49
50
|
"typescript": "^5.8.2",
|
|
50
51
|
"vite": "^6.2.0"
|
|
51
52
|
}
|
|
52
|
-
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import fritter from './fritter.png';
|
|
2
|
+
import kokis from './kokis.png';
|
|
3
|
+
import leaf from './leaf.png';
|
|
4
|
+
import swirl from './swirl.png';
|
|
5
|
+
|
|
6
|
+
/** Built-in rain sprite URLs shipped with HelaUI. */
|
|
7
|
+
export const BUILTIN_RAIN_IMAGES = [fritter, swirl, kokis, leaf] as const;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|