Comments (2)
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.
There are two possible solutions for us:
- 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.
- 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)
- Icons not visible when using Windows High Contrast Mode
- Site: Add sitemap
- Pharos should not allow buttons which only have an icon and no accessible label HOT 1
- Storybook: Controls don't load in composed Storybook HOT 1
- Storybook: Tab loses selected state on window resize in React Reports page example
- Storybook: Component state change doesn't sync back to Storybook control in some stories
- Storybook: Controls revert themselves in some Docs pages, causing invalid state
- Infra: The release process order of operations may be broken under Yarn 4 HOT 3
- Storybook: Upgrade to Storybook 8 HOT 1
- PharosLoadingSpinner: `TypeError: this._spinner.animate is not a function` error in unit tests with TypeScript Vue
- Site: Upgrade to Gatsby 5
- Upgrade to MDX 3 HOT 1
- Table empty column header incorrect element
- Use @lit/react to build React components instead of doing it manually ourselves HOT 3
- Infra: Allow alpha/beta releases HOT 3
- Coachmark: Emit event when dismissed
- Individual component imports regression
- Get on latest scoped web component-related dependencies
- Button: `display` + `contain` values lead to extra space in containing element
- Popover / DropdownMenu: Make click handling more friendly to consumers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pharos.