liquid-xtal
TypeScript icon, indicating that this package has built-in type declarations

0.0.8 • Public • Published

liquid-xtal

import {tm, TemplMgmtBase} from '../TemplMgmtWithPEST.js';

export interface CounterSo extends  TemplMgmtBase{
    count: number;
}

const mainTemplate = tm.html`
<button part=down data-d=-1>-</button><span part=count></span><button part=up data-d=1>+</button>
<style>
    * {
      font-size: 200%;
    }

    span {
      width: 4rem;
      display: inline-block;
      text-align: center;
    }

    button {
      width: 4rem;
      height: 4rem;
      border: none;
      border-radius: 10px;
      background-color: seagreen;
      color: white;
    }
</style>
`;


tm.define<CounterSo>({
    //config should be JSON serializable, importable via JSON import
    config:  {
        tagName:'counter-so',
        initPropMerge:{
            initTransform: {
                buttonElements: [{}, {click:['changeCount', 'dataset.d', 'parseInt']}]
            },
            updateTransform: {
                "countParts": ["count"]
            },
            count: 30,
            renderOptions: {
                cacheQueries: true,
            },
        },
        actions: [
            ...tm.doInitTransform,
            {
                upon: ['count', 'updateTransform'],
                ...tm.doUpdateTransform
            }
        ],
    },
    //This is where non serializable stuff goes
    initComplexPropMerge:{
        mainTemplate: mainTemplate
    },
    mixins: [tm.TemplMgmtMixin, {
        changeCount: (self: CounterSo, d: number, e: Event) => self.count += d,
    }],
});

Package Sidebar

Install

npm i liquid-xtal

Weekly Downloads

2

Version

0.0.8

License

MIT

Unpacked Size

22.6 kB

Total Files

6

Last publish

Collaborators

  • bahrus