presets-bar
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

presets-bar

Presets bar Web Component.

npm i presets-bar pnpm add presets-bar yarn add presets-bar

Examples

# web
    # view source example/web.tsx

    /** @jsxImportSource sigl */
    import $ from 'sigl'
    
    import { cheapRandomId } from 'everyday-utils'
    import { PresetElement, PresetsBarElement, randomName } from 'presets-bar'
    
    type PresetDetail = {
      whatever: string
    }
    
    interface PresetsContainerElement extends $.Element<PresetsContainerElement> {}
    @$.element()
    class PresetsContainerElement extends HTMLElement {
      PresetsBar = $.element(PresetsBarElement<PresetDetail>)
      presets = new $.RefSet<PresetElement<PresetDetail>>([
        { name: randomName(), id: cheapRandomId() },
        { name: randomName(), id: cheapRandomId() },
        { name: randomName(), id: cheapRandomId() },
        { name: randomName(), id: cheapRandomId() },
        { name: randomName(), id: cheapRandomId() },
        { name: randomName(), id: cheapRandomId() },
        { name: randomName(), id: cheapRandomId() },
        { name: randomName(), id: cheapRandomId() },
        { name: randomName(), id: cheapRandomId() },
        { name: randomName(), id: cheapRandomId() },
      ])
    
      mounted($: PresetsContainerElement['$']) {
        $.render(({ PresetsBar, presets }) => <PresetsBar presets={presets} />)
      }
    }
    
    const PresetsContainer = $.element(PresetsContainerElement)
    
    $.render(
      <PresetsContainer style="width=300px;height:400px;resize:both;overflow:hidden;display:inline-flex" />,
      document.body
    )
    
    // console.log(JSON.stringify(document.body.querySelector('' + PresetsBar)))

API

Credits

Contributing

Fork or edit and submit a PR.

All contributions are welcome!

License

MIT © 2022 stagas

Readme

Keywords

none

Package Sidebar

Install

npm i presets-bar

Weekly Downloads

24

Version

1.0.0

License

MIT

Unpacked Size

1.24 MB

Total Files

23

Last publish

Collaborators

  • stagas