New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

alter242

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

alter242

A lightweight frontend UI framework using Vanilla JavaScript

unpublished
latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
0
Created
Source

Alter242 Framework

Alter242 is a lightweight UI framework that converts a simple syntax into frontend elements.

🚀 Features

  • Supports Tables, Buttons, Inputs, Modals, Dropdowns, Cards, Lists, and Images
  • Handles event listeners like onClick
  • Implements two-way data binding
  • Reactive state management
  • Custom components
  • Custom directives
  • Built-in API fetching
  • Virtual DOM for optimized rendering
  • Client-side routing
  • Nested components
  • Custom events
  • Built-in animations
  • Global styles
  • Dynamic data fetching
  • Component-based architecture

📦 Installation

You can install Alter242 via NPM:

npm install alter242

Or include the script in your HTML file:

<script src="https://cdn.jsdelivr.net/npm/alter242"></script>

🛠 Usage

<!DOCTYPE html>
<html>
<head>
    <script defer src="path/to/miniUI.js"></script>
    <script defer src="script.js"></script>
</head>
<body>
    <h1>Alter242 Framework Demo</h1>
    <div id="app"></div>
</body>
</html>
document.addEventListener("DOMContentLoaded", () => {
    const ui = new MiniUI("app");

    ui.registerComponent('button', {
        template: `<button>{{ text }}</button>`,
        onMount: () => console.log('Button Mounted!'),
        onDestroy: () => console.log('Button Destroyed!')
    });

    ui.registerComponent('user-card', {
        template: `
        <div class="card">
            <h3>{{ name }}</h3>
            <p>Age: {{ age }}</p>
        </div>
        `,
        onMount: () => console.log('User Card Mounted!'),
        onDestroy: () => console.log('User Card Destroyed!')
    });

    // Set global styles
    ui.setGlobalStyles({
        '.card': {
            'border': '1px solid #ddd',
            'padding': '10px',
            'margin': '10px',
            'border-radius': '5px',
            'box-shadow': '2px 2px 5px rgba(0,0,0,0.1)'
        },
        '.fadeIn': {
            'animation': 'fadeIn 1s ease-in-out'
        },
        '@keyframes fadeIn': {
            'from': { 'opacity': 0 },
            'to': { 'opacity': 1 }
        }
    });

    ui.registerRoute('/', `
    Table:
    row=3, column=3, border=1px solid black

    Button:
    text=Click Me, color=blue, onclick=Hello World!

    Link:
    text=Go to About, to=about

    Card:
    title=Welcome, content=This is a card with nested components., ui-animate=fadeIn

    List:
    items={{items}}

    UserCard:
    name=John Doe, age=30
    `);

    ui.registerRoute('about', `
    Input:
    placeholder=Type your name, model=username

    Link:
    text=Go Back, to=/
    `);

    ui.loadRoute();

    // Example of custom event
    ui.root.addEventListener('Hello World!', () => {
        alert('Button was clicked!');
    });

    // Fetch data and update state
    ui.fetchData('https://jsonplaceholder.typicode.com/todos', 'items');
});

📄 License

This project is licensed under the MIT License.

Keywords

UI

FAQs

Package last updated on 04 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts