Gathering detailed insights and metrics for @lifeart/gxt
Gathering detailed insights and metrics for @lifeart/gxt
Gathering detailed insights and metrics for @lifeart/gxt
Gathering detailed insights and metrics for @lifeart/gxt
npm install @lifeart/gxt
Typescript
Module System
Node Version
NPM Version
TypeScript (97.35%)
JavaScript (2.02%)
CSS (0.4%)
HTML (0.22%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
30 Stars
496 Commits
3 Forks
6 Watchers
27 Branches
4 Contributors
Updated on Feb 26, 2025
Latest Version
0.0.59
Package Id
@lifeart/gxt@0.0.59
Unpacked Size
241.70 kB
Size
57.57 kB
File Count
62
NPM Version
10.9.0
Node Version
20.11.0
Published on
Jan 12, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
29
GXT
is a cutting-edge, compilable runtime environment designed as glimmer-vm
alternative, showcasing the power and flexibility of modern web component development. This repo includes a live example of how GXT
can be used in real-world applications, providing developers with a practical and interactive experience. Explore our sample at netlify.
Based on template imports RFC
1import { RemoveIcon } from "./RemoveIcon.gts"; 2import type { Item } from "@/utils/data"; 3import { type Cell, cellFor, Component } from "@lifeart/gxt"; 4 5type RowArgs = { 6 Args: { 7 item: Item; 8 selectedCell: Cell<number>; 9 onRemove: (item: Item) => void; 10 }; 11}; 12 13export class Row extends Component<RowArgs> { 14 get labelCell() { 15 return cellFor(this.args.item, "label"); 16 } 17 get id() { 18 return this.args.item.id; 19 } 20 get selected() { 21 return this.args.selectedCell.value; 22 } 23 set selected(value: number) { 24 this.args.selectedCell.value = value; 25 } 26 get isSelected() { 27 return this.selected === this.id; 28 } 29 get className() { 30 return this.isSelected ? "danger" : ""; 31 } 32 onClick = () => { 33 this.selected = this.isSelected ? 0 : this.id; 34 }; 35 onClickRemove = (e: Event) => { 36 this.args.onRemove(this.args.item); 37 }; 38 <template> 39 <tr class={{this.className}}> 40 <td class="col-md-1">{{this.id}}</td> 41 <td class="col-md-4"> 42 <a {{on "click" this.onClick}} data-test-select>{{this.labelCell}}</a> 43 </td> 44 <td class="col-md-1"> 45 <a {{on "click" this.onClickRemove}} data-test-remove> 46 <RemoveIcon /> 47 </a> 48 </td> 49 <td class="col-md-6"></td> 50 </tr> 51 </template> 52}
cell<T>
: Use cellformula
: Create derived states that automatically update when dependencies change, ensuring reactive and responsive UIs.gNext serves as a powerful tool for web developers looking to harness the capabilities of Glimmer-VM in a real-world setting. Its benefits and use cases include:
gNext is not just a library; it's a gateway to building modern, efficient, and reactive web applications using Glimmer-VM. Whether you are building dynamic user interfaces, complex single-page applications, or just experimenting with new front-end technologies, gNext provides the tools and capabilities to bring your ideas to life.
Explore gNext and elevate your web development experience!
1function modifier(element: Element, ...args: Args) {
2 return () => {
3 // destructor
4 }
5}
1function helper(...args: Args): string | boolean | number | null {
2 // helper logic
3 return 3 + 2;
4}
@tracked
- decorator to mark class property as reactive primitive. It's autotrack dependencies and update when any of them changed. Note, to use it you need to add import 'decorator-transforms/globals';
in top-level file.
cell<T>(value)
- reactive primitive, for mutable state. We could update cel calling cell.update(value)
, to get cell value we could use cell.value
.
formula(fn: () => unknown)
- reactive primitive, for derived state.
formula
could be used to create derived state from Cell
's. It's autotrack dependencies and update when any of them changed.
scope
function is used to suspend ts
error about unused variables. It's not required for runtime, but required for ts
compilation.
destructors
supported.
1import { registerDestructor, hbs, scope } from "@lifeart/gxt"; 2 3export function Icon() { 4 registerDestructor(this, () => { 5 console.log("destructor"); 6 }); 7 8 return hbs`<i class="glyphicon glyphicon-remove"></i>`; 9}
Start project from this template: https://github.com/lifeart/template-gxt
or
pnpm create vite my-app --template vanilla-ts
pnpm install @lifeart/gxt
Edit vite.config.mts
to import compiler:
1import { defineConfig } from "vite"; 2import { compiler } from "@lifeart/gxt/compiler"; 3 4export default defineConfig(({ mode }) => ({ 5 plugins: [compiler(mode)], 6}));
To render root component, use renderComponent
function.
1import { renderComponent } from "@lifeart/gxt"; 2import App from "./App.gts"; 3 4const Instance = renderComponent( 5 new App().template(), 6 document.getElementById("app"), 7);
To destroy component, use destroyElement
function.
1import { destroyElement } from "@lifeart/gxt"; 2 3destroyElement(Instance);
No vulnerabilities found.
No security vulnerabilities found.