typescript-components
A TypeScript Framework for non-pwa pages
Installation
npm install typescript-components --save
Node
import "typescript-components";
Why not Angular, React, Vue.js etc?
Have you ever had to develop a project that you could not develop as a singe-page project?
I have encountered this problem many times already. Every time I wanted to use one of the above frameworks, but could not, because these are based on client-side rendering.
This framework is based on simple components, which can be set to an element via data attribute and thus extend this to various functionalities.
Usage
First, the component must be declared. Here we declare a simple "scroll to top" button.
import {AbstractComponent, Component, ElementAttribute, EventListener, smoothScroll} from "typescript-components";
@Component({
selector: 'scroll-top'
})
export class ScrollTopComponent extends AbstractComponent {
@ElementAttribute()
protected duration = 500;
@EventListener()
public click() {
smoothScroll(0, +this.duration);
}
}
Then we need to register the created component for bootstrapping.
import {ComponentFactory} from "typescript-components";
import {ScrollTopComponent} from "./scroll-top.component";
ComponentFactory.registerComponents([
ScrollTopComponent
]);
Now we just have to define the html and call the page (after building the javascript of cause).
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"/>
<title>TypeScript Components</title>
</head>
<body>
<button scroll-top duration="1000">To Top 1000ms</button>
<script src="build.js"></script>
</body>
</html>
Take a look at the examples if you want to see more advanced component configurations.
A documentation will follow soon to show you all programming possibilities.