@whykusanagi/corrupted-theme 0.1.2 → 0.1.3
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/CHANGELOG.md +133 -0
- package/README.md +6 -0
- package/docs/CAPABILITIES.md +209 -0
- package/docs/CHARACTER_LEVEL_CORRUPTION.md +264 -0
- package/docs/CORRUPTION_PHRASES.md +529 -0
- package/docs/FUTURE_WORK.md +189 -0
- package/docs/IMPLEMENTATION_VALIDATION.md +401 -0
- package/docs/LLM_PROVIDERS.md +345 -0
- package/docs/PERSONALITY.md +128 -0
- package/docs/ROADMAP.md +266 -0
- package/docs/ROUTING.md +324 -0
- package/docs/STYLE_GUIDE.md +605 -0
- package/docs/brand/BRAND_OVERVIEW.md +413 -0
- package/docs/brand/COLOR_SYSTEM.md +583 -0
- package/docs/brand/DESIGN_TOKENS.md +1009 -0
- package/docs/brand/TRANSLATION_FAILURE_AESTHETIC.md +525 -0
- package/docs/brand/TYPOGRAPHY.md +624 -0
- package/docs/components/ANIMATION_GUIDELINES.md +901 -0
- package/docs/components/COMPONENT_LIBRARY.md +1061 -0
- package/docs/components/GLASSMORPHISM.md +602 -0
- package/docs/components/INTERACTIVE_STATES.md +766 -0
- package/docs/governance/CONTRIBUTION_GUIDELINES.md +593 -0
- package/docs/governance/DESIGN_SYSTEM_GOVERNANCE.md +451 -0
- package/docs/governance/VERSION_MANAGEMENT.md +447 -0
- package/docs/governance/VERSION_REFERENCES.md +229 -0
- package/docs/platforms/CLI_IMPLEMENTATION.md +1025 -0
- package/docs/platforms/COMPONENT_MAPPING.md +579 -0
- package/docs/platforms/NPM_PACKAGE.md +854 -0
- package/docs/platforms/WEB_IMPLEMENTATION.md +1221 -0
- package/docs/standards/ACCESSIBILITY.md +715 -0
- package/docs/standards/ANTI_PATTERNS.md +554 -0
- package/docs/standards/SPACING_SYSTEM.md +549 -0
- package/examples/button.html +1 -1
- package/examples/card.html +1 -1
- package/examples/form.html +1 -1
- package/examples/index.html +2 -2
- package/examples/layout.html +1 -1
- package/examples/nikke-team-builder.html +1 -1
- package/examples/showcase-complete.html +840 -15
- package/examples/showcase.html +1 -1
- package/package.json +4 -2
- package/src/css/components.css +676 -0
- package/src/lib/character-corruption.js +563 -0
- package/src/lib/components.js +283 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Helpers
|
|
3
|
+
* JavaScript utilities for interactive Bootstrap-equivalent components
|
|
4
|
+
*
|
|
5
|
+
* Provides helper functions for:
|
|
6
|
+
* - Accordion/Collapse
|
|
7
|
+
* - Toast Notifications
|
|
8
|
+
* - Auto-initialization
|
|
9
|
+
*
|
|
10
|
+
* @module components
|
|
11
|
+
* @version 1.0.0
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
// ========== ACCORDION / COLLAPSE ==========
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Initialize all accordions on the page
|
|
18
|
+
* Auto-called on DOMContentLoaded
|
|
19
|
+
*/
|
|
20
|
+
export function initAccordions() {
|
|
21
|
+
document.querySelectorAll('.accordion').forEach(accordion => {
|
|
22
|
+
// Skip if already initialized
|
|
23
|
+
if (accordion.dataset.accordionInitialized === 'true') {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
accordion.querySelectorAll('.accordion-item').forEach(item => {
|
|
28
|
+
const header = item.querySelector('.accordion-header');
|
|
29
|
+
if (!header) return;
|
|
30
|
+
|
|
31
|
+
header.addEventListener('click', () => {
|
|
32
|
+
const wasActive = item.classList.contains('active');
|
|
33
|
+
|
|
34
|
+
// Close all items in this accordion (unless it's already active)
|
|
35
|
+
accordion.querySelectorAll('.accordion-item').forEach(otherItem => {
|
|
36
|
+
if (otherItem !== item) {
|
|
37
|
+
otherItem.classList.remove('active');
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Toggle this item
|
|
42
|
+
if (wasActive) {
|
|
43
|
+
item.classList.remove('active');
|
|
44
|
+
} else {
|
|
45
|
+
item.classList.add('active');
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
accordion.dataset.accordionInitialized = 'true';
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Toggle a collapse element
|
|
56
|
+
* @param {HTMLElement|string} element - Element or selector
|
|
57
|
+
*/
|
|
58
|
+
export function toggleCollapse(element) {
|
|
59
|
+
const el = typeof element === 'string' ? document.querySelector(element) : element;
|
|
60
|
+
if (!el) return;
|
|
61
|
+
|
|
62
|
+
el.classList.toggle('show');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Show a collapse element
|
|
67
|
+
* @param {HTMLElement|string} element - Element or selector
|
|
68
|
+
*/
|
|
69
|
+
export function showCollapse(element) {
|
|
70
|
+
const el = typeof element === 'string' ? document.querySelector(element) : element;
|
|
71
|
+
if (!el) return;
|
|
72
|
+
|
|
73
|
+
el.classList.add('show');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Hide a collapse element
|
|
78
|
+
* @param {HTMLElement|string} element - Element or selector
|
|
79
|
+
*/
|
|
80
|
+
export function hideCollapse(element) {
|
|
81
|
+
const el = typeof element === 'string' ? document.querySelector(element) : element;
|
|
82
|
+
if (!el) return;
|
|
83
|
+
|
|
84
|
+
el.classList.remove('show');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// ========== TOAST NOTIFICATIONS ==========
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Toast notification system
|
|
91
|
+
*/
|
|
92
|
+
class ToastManager {
|
|
93
|
+
constructor() {
|
|
94
|
+
this.container = null;
|
|
95
|
+
this.toasts = [];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Ensure toast container exists
|
|
100
|
+
*/
|
|
101
|
+
ensureContainer() {
|
|
102
|
+
if (!this.container || !document.contains(this.container)) {
|
|
103
|
+
this.container = document.querySelector('.toast-container');
|
|
104
|
+
|
|
105
|
+
if (!this.container) {
|
|
106
|
+
this.container = document.createElement('div');
|
|
107
|
+
this.container.className = 'toast-container';
|
|
108
|
+
document.body.appendChild(this.container);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return this.container;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Show a toast notification
|
|
117
|
+
* @param {Object} options - Toast configuration
|
|
118
|
+
* @param {string} options.title - Toast title
|
|
119
|
+
* @param {string} options.message - Toast message
|
|
120
|
+
* @param {string} [options.type='info'] - Toast type (success, warning, error, info)
|
|
121
|
+
* @param {number} [options.duration=5000] - Auto-dismiss duration (0 = no auto-dismiss)
|
|
122
|
+
* @param {Function} [options.onClose] - Callback when toast is closed
|
|
123
|
+
* @returns {HTMLElement} Toast element
|
|
124
|
+
*/
|
|
125
|
+
show(options) {
|
|
126
|
+
const {
|
|
127
|
+
title = '',
|
|
128
|
+
message = '',
|
|
129
|
+
type = 'info',
|
|
130
|
+
duration = 5000,
|
|
131
|
+
onClose = null
|
|
132
|
+
} = options;
|
|
133
|
+
|
|
134
|
+
const container = this.ensureContainer();
|
|
135
|
+
|
|
136
|
+
// Create toast element
|
|
137
|
+
const toast = document.createElement('div');
|
|
138
|
+
toast.className = `toast ${type}`;
|
|
139
|
+
|
|
140
|
+
// Create toast content
|
|
141
|
+
const content = `
|
|
142
|
+
${title ? `
|
|
143
|
+
<div class="toast-header">
|
|
144
|
+
<span>${title}</span>
|
|
145
|
+
</div>
|
|
146
|
+
` : ''}
|
|
147
|
+
<div class="toast-body">${message}</div>
|
|
148
|
+
<button class="toast-close" aria-label="Close">×</button>
|
|
149
|
+
`;
|
|
150
|
+
|
|
151
|
+
toast.innerHTML = content;
|
|
152
|
+
|
|
153
|
+
// Add close handler
|
|
154
|
+
const closeBtn = toast.querySelector('.toast-close');
|
|
155
|
+
closeBtn.addEventListener('click', () => {
|
|
156
|
+
this.dismiss(toast, onClose);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// Add to container
|
|
160
|
+
container.appendChild(toast);
|
|
161
|
+
this.toasts.push(toast);
|
|
162
|
+
|
|
163
|
+
// Auto-dismiss
|
|
164
|
+
if (duration > 0) {
|
|
165
|
+
setTimeout(() => {
|
|
166
|
+
this.dismiss(toast, onClose);
|
|
167
|
+
}, duration);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return toast;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Dismiss a toast
|
|
175
|
+
* @param {HTMLElement} toast - Toast element to dismiss
|
|
176
|
+
* @param {Function} [onClose] - Callback when toast is closed
|
|
177
|
+
*/
|
|
178
|
+
dismiss(toast, onClose = null) {
|
|
179
|
+
if (!toast || !document.contains(toast)) return;
|
|
180
|
+
|
|
181
|
+
toast.classList.add('hiding');
|
|
182
|
+
|
|
183
|
+
setTimeout(() => {
|
|
184
|
+
if (toast.parentNode) {
|
|
185
|
+
toast.parentNode.removeChild(toast);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Remove from tracking array
|
|
189
|
+
const index = this.toasts.indexOf(toast);
|
|
190
|
+
if (index > -1) {
|
|
191
|
+
this.toasts.splice(index, 1);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (onClose) {
|
|
195
|
+
onClose();
|
|
196
|
+
}
|
|
197
|
+
}, 300); // Match animation duration
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Dismiss all toasts
|
|
202
|
+
*/
|
|
203
|
+
dismissAll() {
|
|
204
|
+
this.toasts.forEach(toast => this.dismiss(toast));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Convenience methods for different toast types
|
|
208
|
+
|
|
209
|
+
success(message, title = 'Success', duration = 5000) {
|
|
210
|
+
return this.show({ message, title, type: 'success', duration });
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
warning(message, title = 'Warning', duration = 5000) {
|
|
214
|
+
return this.show({ message, title, type: 'warning', duration });
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
error(message, title = 'Error', duration = 7000) {
|
|
218
|
+
return this.show({ message, title, type: 'error', duration });
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
info(message, title = '', duration = 5000) {
|
|
222
|
+
return this.show({ message, title, type: 'info', duration });
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Create global toast instance
|
|
227
|
+
const toastManager = new ToastManager();
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Show a toast notification
|
|
231
|
+
* @param {Object} options - Toast configuration
|
|
232
|
+
* @returns {HTMLElement} Toast element
|
|
233
|
+
*/
|
|
234
|
+
export function showToast(options) {
|
|
235
|
+
return toastManager.show(options);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Toast convenience methods
|
|
240
|
+
*/
|
|
241
|
+
export const toast = {
|
|
242
|
+
success: (message, title, duration) => toastManager.success(message, title, duration),
|
|
243
|
+
warning: (message, title, duration) => toastManager.warning(message, title, duration),
|
|
244
|
+
error: (message, title, duration) => toastManager.error(message, title, duration),
|
|
245
|
+
info: (message, title, duration) => toastManager.info(message, title, duration),
|
|
246
|
+
dismiss: (toastEl, callback) => toastManager.dismiss(toastEl, callback),
|
|
247
|
+
dismissAll: () => toastManager.dismissAll()
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
// ========== AUTO-INITIALIZATION ==========
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Initialize all components on page load
|
|
254
|
+
*/
|
|
255
|
+
function initComponents() {
|
|
256
|
+
// Initialize accordions
|
|
257
|
+
if (document.querySelector('.accordion')) {
|
|
258
|
+
initAccordions();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Auto-initialize on DOM ready
|
|
263
|
+
if (typeof window !== 'undefined') {
|
|
264
|
+
if (document.readyState === 'loading') {
|
|
265
|
+
document.addEventListener('DOMContentLoaded', initComponents);
|
|
266
|
+
} else {
|
|
267
|
+
initComponents();
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// ========== EXPORTS ==========
|
|
272
|
+
|
|
273
|
+
export default {
|
|
274
|
+
// Accordion
|
|
275
|
+
initAccordions,
|
|
276
|
+
toggleCollapse,
|
|
277
|
+
showCollapse,
|
|
278
|
+
hideCollapse,
|
|
279
|
+
|
|
280
|
+
// Toast
|
|
281
|
+
showToast,
|
|
282
|
+
toast
|
|
283
|
+
};
|