2021-06-02 22:32:30 +02:00
|
|
|
# Kalker Web Component
|
2021-01-04 20:56:12 +01:00
|
|
|
![npm](https://img.shields.io/npm/v/@paddim8/kalk-component)
|
|
|
|
![license](https://img.shields.io/npm/l/@paddim8/kalk-component)
|
|
|
|
|
2021-06-02 22:32:30 +02:00
|
|
|
A web component built with Svelte that uses the kalk library (WebAssembly).
|
2021-01-04 20:56:12 +01:00
|
|
|
|
|
|
|
![preview](preview.png)
|
|
|
|
|
|
|
|
## Installation & Setup
|
|
|
|
`npm install --save @paddim8/kalk-component`
|
|
|
|
|
|
|
|
### Module
|
|
|
|
```js
|
|
|
|
import { KalkCalculator, ConsoleLine } from "@paddim8/kalk-component"
|
|
|
|
```
|
|
|
|
If your bundler doesn't include all the files in the output folder,
|
|
|
|
you may need to eg. modify your build script to copy them over manually.
|
|
|
|
I am not aware of a better way.
|
|
|
|
|
|
|
|
### Or only with HTML
|
|
|
|
```html
|
|
|
|
<script type="text/javascript" src="some/path/bundle.js"></script>
|
|
|
|
```
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
```html
|
|
|
|
<div class="kalk"> <!-- Apply css rules for position/size/font/etc. to this -->
|
|
|
|
<kalk-calculator>
|
2021-06-02 22:32:30 +02:00
|
|
|
<console-line>kalker</console-line>
|
2021-01-04 20:56:12 +01:00
|
|
|
<console-line>
|
|
|
|
<span class="hint">Type 'help' for instructions.</span>
|
|
|
|
</console-line>
|
|
|
|
</kalk-calculator>
|
|
|
|
</div>
|
|
|
|
```
|
|
|
|
|
|
|
|
## Customizing
|
|
|
|
The colours in the component can be changed by using these attributes.
|
|
|
|
```html
|
|
|
|
<kalk-calculator
|
2021-01-05 01:38:56 +01:00
|
|
|
hinttext="Type something..."
|
2021-01-05 15:09:08 +01:00
|
|
|
autofocus="true"
|
2021-01-05 01:38:56 +01:00
|
|
|
identifiercolor="cornflowerblue"
|
|
|
|
operatorcolor="darkorange"
|
|
|
|
promptcolor="mediumseagreen"
|
|
|
|
errorcolor="tomato"
|
|
|
|
hintcolor="#9c9c9c"
|
|
|
|
linkcolor="cornflowerblue"
|
|
|
|
backgroundcolor="#424242" />
|
2021-01-04 20:56:12 +01:00
|
|
|
```
|