بنقرة واحدة
add-other-module
Add a new optional JavaScript module to layx/others/ (e.g., scroll effects, trackers, utilities)
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Add a new optional JavaScript module to layx/others/ (e.g., scroll effects, trackers, utilities)
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
| name | add_other_module |
| description | Add a new optional JavaScript module to layx/others/ (e.g., scroll effects, trackers, utilities) |
Optional feature modules live in layx/others/<module-name>/. These are JavaScript-heavy or CSS+JS features that are not core to the layout system but enhance interactivity and UX.
The others/ directory contains:
Modules are used by importing them from user JS files:
import '/layx/others/<module-name>/<module-name>.js';
Or by the CLI add command.
layx/others/<module-name>/
├── <module-name>.js (required — main module)
└── <module-name>.css (optional — if CSS needed)
Use ES module syntax. Export a default class or function. Follow the single-responsibility principle.
Template — class-based module:
/**
* <ModuleName> - Brief description of what this does
*/
class <ModuleName> {
constructor(options = {}) {
this.options = {
// Default options
selector: '<module-name>',
...options
};
this.init();
}
init() {
const elements = document.querySelectorAll(this.options.selector);
elements.forEach(el => this._setup(el));
}
_setup(el) {
// Initialize individual element
}
destroy() {
// Cleanup listeners and state if needed
}
}
export default <ModuleName>;
Template — observer-based module (viewport triggers pattern):
/**
* <ModuleName> - Triggers class/event when element enters viewport
*/
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.setAttribute('visible', '');
entry.target.dispatchEvent(new CustomEvent('<module-name>-visible'));
}
});
}, {
threshold: 0.1
});
document.querySelectorAll('[data-<module-name>]').forEach(el => observer.observe(el));
export {};
Template — auto-initializing module (theme, scroll, etc.):
/**
* <ModuleName> - Auto-initializes on import
*/
(function() {
// Module logic runs immediately on import
function init() {
// Setup
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
})();
export {};
If the module needs CSS, always wrap in @layer others:
@layer others {
[data-<module-name>] {
/* Default state */
opacity: 0;
transition: opacity var(--duration, .6s);
&[visible] {
/* Active state */
opacity: 1;
}
}
}
The module should be imported from user JS files (not auto-loaded by layx.js unless it's a core feature). Document the import pattern:
// In assets/js/base.js or assets/js/pages/home.js:
import '/layx/others/<module-name>/<module-name>.js';
// Or with options:
import <ModuleName> from '/layx/others/<module-name>/<module-name>.js';
const instance = new <ModuleName>({ /* options */ });
| Module | Pattern | CSS? |
|---|---|---|
theme/ | Auto-init, listens to toggle clicks | Yes |
scroll_state/ | Auto-init, IntersectionObserver / scroll listener | No |
viewport_trigger/ | IntersectionObserver, adds visible attribute | Yes |
smooth_scroll/ | Event delegation on [data-smooth-scroll] links | Yes |
split_text/ | Transforms text nodes into span elements | No |
mouse_tracker/ | Adds CSS variables for mouse coordinates on root | No |
idb/ | Class-based async IndexedDB wrapper, exported | No |
component/ | Class-based, fetches and renders HTML components | No |
layx/others/<module-name>/export default or export {})@layer others (if CSS needed)import is documented in the file header commentlocalhost:81Add a new UI component to the Layx framework following established CSS/JS patterns
Add a new utility class group to the Layx framework (layx/utilities/) following established CSS layer patterns
Master reference skill for the Layx CSS-first framework — architecture, file structure, conventions, CSS patterns, JS patterns, CLI, and build system