-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
manually register shoelace components
- Loading branch information
Showing
3 changed files
with
38 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,30 @@ | ||
// Cherry-picked Shoelace components: | ||
import "@shoelace-style/shoelace/dist/components/alert/alert.js"; | ||
import "@shoelace-style/shoelace/dist/components/button/button.js"; | ||
import "@shoelace-style/shoelace/dist/components/copy-button/copy-button.js"; | ||
import "@shoelace-style/shoelace/dist/components/dialog/dialog.js"; | ||
import "@shoelace-style/shoelace/dist/components/dropdown/dropdown.js"; | ||
import "@shoelace-style/shoelace/dist/components/menu/menu.js"; | ||
import "@shoelace-style/shoelace/dist/components/menu-item/menu-item.js"; | ||
import kebabCase from "lodash/fp/kebabCase"; | ||
|
||
// Cherry-picked Shoelace components | ||
// Import .component and register manually to avoid name collision | ||
// See https://github.com/shoelace-style/shoelace/issues/705 | ||
import SlAlert from "@shoelace-style/shoelace/dist/components/alert/alert.component.js"; | ||
import SlButton from "@shoelace-style/shoelace/dist/components/button/button.component.js"; | ||
import SlCopyButton from "@shoelace-style/shoelace/dist/components/copy-button/copy-button.component.js"; | ||
import SlDialog from "@shoelace-style/shoelace/dist/components/dialog/dialog.component.js"; | ||
import SlDropdown from "@shoelace-style/shoelace/dist/components/dropdown/dropdown.component.js"; | ||
import SlMenu from "@shoelace-style/shoelace/dist/components/menu/menu.component.js"; | ||
import SlMenuItem from "@shoelace-style/shoelace/dist/components/menu-item/menu-item.component.js"; | ||
|
||
// Shoelace components should only be registered if needed | ||
// to prevent issues with callers, e.g. Browsertrix. | ||
[ | ||
SlAlert, | ||
SlButton, | ||
SlCopyButton, | ||
SlDialog, | ||
SlDropdown, | ||
SlMenu, | ||
SlMenuItem, | ||
].forEach((slClass) => { | ||
const name = kebabCase(slClass.name); | ||
|
||
if (!customElements.get(name)) { | ||
customElements.define(name, slClass); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters