From 20a7107964ae90af0d00509622d8158af23535cf Mon Sep 17 00:00:00 2001 From: FullGreaM Date: Mon, 27 Apr 2026 02:14:27 +0300 Subject: [PATCH] Update readme.md for Gefest --- frontend/src/modules/Gefest/README.md | 46 +++++++++++++++++++++------ 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/frontend/src/modules/Gefest/README.md b/frontend/src/modules/Gefest/README.md index 43e16c6..d0f2563 100644 --- a/frontend/src/modules/Gefest/README.md +++ b/frontend/src/modules/Gefest/README.md @@ -8,17 +8,18 @@ Gefest is a lightweight, TypeScript-based framework for building and managing HT - **Attribute Management**: Easy setting, getting, and removing of HTML attributes - **CSS Class Handling**: Add and remove classes dynamically - **Style System**: Extensible styling with custom style classes -- **Event Handling**: Built-in click event management +- **Event Handling**: Built-in click event management with automatic re-rendering - **Element Registration**: Automatic ID generation and DOM integration - **Primitive Components**: Pre-built HTML element wrappers +- **Dynamic Updates**: Re-render elements on the fly ## Installation Gefest is included as a module in this project. To use it in your TypeScript files: ```typescript -import { GefestEngine, GefestElement } from './modules/Gefest/engine'; -import { GefestButton } from './modules/Gefest/primitives/button'; +import { GefestEngine, GefestElement } from './engine'; +import { GefestButton } from './primitives/button'; // ... other imports as needed ``` @@ -33,6 +34,7 @@ The base abstract class for all Gefest elements. It provides: - Class management - Style application - Event binding +- Automatic re-rendering on updates ### GefestEngine @@ -41,6 +43,7 @@ Manages the lifecycle of Gefest elements: - Registers elements with unique IDs - Activates event handlers on DOM elements - Provides the main entry point for applications +- Handles re-rendering of updated elements ### GefestStyle @@ -89,9 +92,17 @@ button.isHidden = true; // Sets the 'hidden' attribute on the element const button = new GefestButton("Click me!"); button.onClick = () => { console.log('Button clicked!'); + // The framework automatically re-renders after click }; ``` +### Updating Elements + +```typescript +const button = new GefestButton("Initial"); +button.update(); // Re-renders the element in the DOM +``` + ### Running the Application ```typescript @@ -131,6 +142,15 @@ const link = new GefestA("Visit site", "https://example.com"); link.setAttribute('target', '_blank'); ``` +### GefestImg + +Wraps HTML `` elements. + +```typescript +const image = new GefestImg("", "path/to/image.jpg"); +image.setAttribute('alt', 'Description'); +``` + ### Other Primitives - `GefestP`: Paragraph (`

`) @@ -138,7 +158,7 @@ link.setAttribute('target', '_blank'); - `GefestHeader`: Header (`

`) - `GefestI`: Italic (``) - `GefestSmall`: Small text (``) -- `GefestCenter`: Centered content (custom wrapper) +- `GefestCenter`: Centered content (`
`) ## Advanced Features @@ -202,14 +222,15 @@ const element = GefestElement.fromHTML(''); ### GefestElement #### Properties -- `gefestId: string` - Unique identifier for the element +- `gefestId: string` - Unique identifier for the element (readonly) - `style: GefestStyle | null` - Style to apply to the element -- `onClick: (() => void) | null` - Click event handler +- `onClick: (() => void) | null` - Click event handler (getter/setter) - `isHidden: boolean` - Whether the element should be hidden (sets the 'hidden' attribute when true) #### Methods - `constructor(content: (GefestElement | string)[] | string)` - `build(isFromStyle?: boolean): string` +- `update(): void` - Re-renders the element in the DOM - `setAttribute(key: string, value: string): void` - `getAttribute(key: string): string | undefined` - `removeAttribute(key: string): void` @@ -227,6 +248,7 @@ const element = GefestElement.fromHTML(''); - `register(element: GefestElement): string` - `activateOnClick(): Promise` - `main(main: () => Promise): Promise` +- `reRenderByGI(gefestId: string): void` ### GefestStyle @@ -238,8 +260,8 @@ const element = GefestElement.fromHTML(''); ### Complete Application ```typescript -import { GefestEngine } from './modules/Gefest/engine'; -import { GefestButton, GefestP } from './modules/Gefest/primitives'; +import { GefestEngine } from './engine'; +import { GefestButton, GefestP } from './primitives'; async function main() { const title = new GefestP("Welcome to Gefest!"); @@ -251,7 +273,13 @@ async function main() { alert('Welcome!'); }; - const container = new GefestDiv([title, button]); + // For custom elements, define them as shown above + const container = new (class extends GefestElement { + protected wrapHTML(content: string): string { + const attrString = this.attributesToString(); + return `
${content}
`; + } + })([title, button]); container.addClass('container'); document.body.innerHTML = container.build();