Coder Social home page Coder Social logo

Comments (2)

Niznikr avatar Niznikr commented on June 13, 2024 1

Lit itself also provides a separate mixin that integrates with the CustomElementRegistry polyfill. Because shadow roots are used as registration scopes in the proposal, we need to perhaps provide a helper for consumers to scope their version of Pharos. This helper would attach a shadow root to a given element and then define Pharos components on it for folks to use and scope their app/page.

from pharos.

Niznikr avatar Niznikr commented on June 13, 2024

There are two possible solutions for us:

  1. We create a <pharos-registry> component that utilizes the @lit-labs/scoped-registry-mixin to scope our components within its shadow root. Consumers could then use the component as such:
<template id="my-template">
  <h1>My page template</h1>
  <pharos-button>hi</pharos-button>
</template>
<pharos-registry></pharos-registry>

And in their JS entry file:

import { PharosRegistry } from '@ithaka/pharos/lib/components/core/pharos-registry';
customElements.define('pharos-registry', PharosRegistry);

document.querySelector('pharos-registry').shadowRoot.append(document.querySelector('#my-template').content);

This would remove the need for consumers to import individual components but at the cost of needing for their template to exist in the shadow DOM which would require changes to references of document.querySelector and integration tests.

  1. Only use @lit-labs/scoped-registry-mixin within our own components that import other Pharos components and remove the @customElement decorator to stop self-registering. Instead we only export the component class and let consumers define a unique tag for their app:
import { PharosButton } from '@ithaka/pharos/lib/components/button/pharos-button';
customElements.define('pharos-button-homepage', PharosButton);

This would place responsibility on the consumer to define a unique tag. Any integration test helpers would need to allow configuration for custom tags because of this new flexibility.

from pharos.

Related Issues (20)

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.