Giter Site home page Giter Site logo

electrovir / element-vir Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 4.21 MB

Heroic, reactive, declarative, type safe, custom web components.

Home Page: https://electrovir.github.io/element-vir/

License: Creative Commons Zero v1.0 Universal

JavaScript 0.60% TypeScript 99.14% CSS 0.05% HTML 0.20%
typescript webcomponents

element-vir's Introduction

element-vir mono repo

See packages for each package.

element-vir's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

element-vir's Issues

Add error message or type checking for async render callback.

It would be helpful if an error gets thrown or the type checker catches it when you make the renderCallback asynchronous.
async renderCallback ({state, updateState, inputs}) {...

If you do this you get an [object Promise] but no errors are thrown explaining what [object Promise] means.

help prevent `[object object]` interpolation

Can we prevent object interpolations into templates (which get transformed into the '[object object]' string) by modifying the types on html?

It should allow:

  • primitives
  • Templates
  • arrays of either

But nothing else?

Set createPromise in asyncProp's init and pass in triggers

Like this:

const MyElement = defineElement<{userId: string}>()({
    tagName: 'my-element',
    stateInitStatic: {
        myProp: asyncProp({async createPromise({trigger}) {
            return await fetchThingById(trigger.id);
        }})
    },
    renderCallback({inputs, updateState}) {
        updateState({trigger: {id: inputs.userId}})
        return 'test';
    }
})

Error earlier if an element is interpolated in html but does not have inputs assigned to it

In #10, .assign is now chained directly off of element definitions. With this, we can now throw an error at template instantiation if an element that is expecting inputs does not get assigned inputs. This will make it much easier to prevent errors where inputs are forgotten.

Also try making this a type error, so devs can see the error in their editor before even executing any code. However, be sure to allow closing tag interpolation to work still.

add "setInputs" to observables

so they can be defined without inputs having been set yet

also add triggerUpdate method similar to async props

basically I want interval observable props to be async props with the same interface + interval updates

"listen directive can only be attached directly to an element." should tell me which file.

Here's an example of an error.

    at assertIsElementPartInfo (directive-helpers.js:9:15)
    at extractElement (directive-helpers.js:3:5)
    at new <anonymous> (listen.directive.js:14:24)
    at resolveDirective (lit-html.ts:1067:26)
    at ChildPart._$setValue (lit-html.ts:1357:13)
    at TemplateInstance._update (lit-html.ts:1187:16)
    at ChildPart._commitTemplateResult (lit-html.ts:1545:16)
    at ChildPart._$setValue (lit-html.ts:1379:12)
    at render (lit-html.ts:2175:8)
    at _a2.update (lit-element.ts:165:24)

I'm not sure which file this error is in. Can error messaging be improved to include the file path?

formatting tagged template

Prettier's formatting doesn't know what to do with interpolated tag names in the html tagged templates.

Create a Prettier plugin to fix this.

Better error messaging when "assign" is used incorrectly.

I had an error where it was saying I forgot to assign an input. I was going crazy trying to figure out where the issue was. I was assigning the input in my code. Took me about 10 minutes to figure out I typed it wrong.

What I should've typed:
${assign(HabitItem, {habit: inputs.habit})}

What I actually typed:
${assign(HabitItem), {habit: inputs.habit}}

add slot names to element definition inputs

like this:

export const MyElement = definElement<{input: string}>()({
    tagName: 'my-element',
    slotNames: [
        'my-element-slot-1',
    ],
    renderCallback({slotNames}) {
        return html`
            hi
            <slot name=${slotNames['my-element-slot-1']}>fallback</slot>
        `;
    }
})

add `asyncIntervalProp`

add a variation of asyncProp that automatically re-calls its callback by a user-set interval.

errors aren't so great

hard to track errors due to the deep stack trace

either make the stack trace better or include the element tag name in all errors

create mono-repo

merge the following packages into a mono-repo within element-vir:

  • vira
  • element-book
  • lit-css-vars

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.