Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/marpple/rune

Web API based Front-end SDK
https://github.com/marpple/rune

Last synced: about 2 months ago
JSON representation

Web API based Front-end SDK

Awesome Lists containing this project

README

        

rune

# Rune - Web API based Front-end SDK

Rune is a fast and robust library for building high-quality frontend applications, serving as a modern web technology-based SDK.

- Object-oriented programming-based architecture
- Type-safe Generic Views & Enable
- Single-component Server-Side Rendering
- Sleek UI component development kit
- High portability and performance

# Getting Started

```shell
pnpm add rune-ts
npm install rune-ts
```

# Documentation

- [Website](https://marpple.github.io/rune/)
- [What is Rune?](https://marpple.github.io/rune/guide/what-is-rune.html)
- [Tutorial](https://marpple.github.io/rune/tutorial/view.html)

# Example

```typescript
interface Setting {
title: string;
on: boolean;
}

class SettingItemView extends View {
switchView = new SwitchView(this.data);

override template() {
return html`


${this.data.title}
${this.switchView}

`;
}
}

class SettingListView extends ListView {
ItemView = SettingItemView;
}

class SettingPage extends View {
private _listView = new SettingListView(this.data);
private _checkAllView = new SwitchView({ on: this._isCheckAll() });

override template() {
return html`



Setting


${this._checkAllView}

${this._listView}


`;
}

protected override onRender() {
this._checkAllView.addEventListener(Toggled, (e) => this._checkAll(e.detail.on));
this._listView.addEventListener(Toggled, () => this._syncCheckAll());
}

private _checkAll(on: boolean) {
this._listView.itemViews
.filter((itemView) => itemView.data.on !== on)
.forEach((itemView) => itemView.switchView.setOn(on));
}

private _syncCheckAll() {
this._checkAllView.setOn(this._isCheckAll());
}

private _isCheckAll() {
return this.data.every(({ on }) => on);
}
}
```

setting_controller