@rocket/js 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +224 -2
- package/dist-types/exports/MainMenu.d.ts +2 -0
- package/dist-types/exports/MainMenu.d.ts.map +1 -0
- package/dist-types/exports/PageData.d.ts +2 -0
- package/dist-types/exports/PageData.d.ts.map +1 -0
- package/dist-types/exports/RocketCodeBlock.d.ts +2 -0
- package/dist-types/exports/RocketCodeBlock.d.ts.map +1 -0
- package/dist-types/exports/RocketIcon.d.ts +2 -0
- package/dist-types/exports/RocketIcon.d.ts.map +1 -0
- package/dist-types/exports/RocketJsDemo.d.ts +2 -0
- package/dist-types/exports/RocketJsDemo.d.ts.map +1 -0
- package/dist-types/exports/RocketRequestDemo.d.ts +2 -0
- package/dist-types/exports/RocketRequestDemo.d.ts.map +1 -0
- package/dist-types/exports/SocialPreviewPlayground.d.ts +2 -0
- package/dist-types/exports/SocialPreviewPlayground.d.ts.map +1 -0
- package/dist-types/exports/adapters/netlify.d.ts +2 -0
- package/dist-types/exports/adapters/netlify.d.ts.map +1 -0
- package/dist-types/exports/asyncMessage.d.ts +2 -0
- package/dist-types/exports/asyncMessage.d.ts.map +1 -0
- package/dist-types/exports/component-hydration.d.ts +2 -0
- package/dist-types/exports/component-hydration.d.ts.map +1 -0
- package/dist-types/exports/components/web-awesome.d.ts +3 -0
- package/dist-types/exports/components/web-awesome.d.ts.map +1 -0
- package/dist-types/exports/components.d.ts +2 -0
- package/dist-types/exports/components.d.ts.map +1 -0
- package/dist-types/exports/config.d.ts +2 -0
- package/dist-types/exports/config.d.ts.map +1 -0
- package/dist-types/exports/debounce.d.ts +2 -0
- package/dist-types/exports/debounce.d.ts.map +1 -0
- package/dist-types/exports/define/RocketCodeBlock.d.ts +2 -0
- package/dist-types/exports/define/RocketCodeBlock.d.ts.map +1 -0
- package/dist-types/exports/define/RocketIcon.d.ts +2 -0
- package/dist-types/exports/define/RocketIcon.d.ts.map +1 -0
- package/dist-types/exports/define/RocketJsDemo.d.ts +2 -0
- package/dist-types/exports/define/RocketJsDemo.d.ts.map +1 -0
- package/dist-types/exports/define/RocketRequestDemo.d.ts +2 -0
- package/dist-types/exports/define/RocketRequestDemo.d.ts.map +1 -0
- package/dist-types/exports/define/menus.d.ts +2 -0
- package/dist-types/exports/define/menus.d.ts.map +1 -0
- package/dist-types/exports/extractCode.d.ts +2 -0
- package/dist-types/exports/extractCode.d.ts.map +1 -0
- package/dist-types/exports/globalData.d.ts +2 -0
- package/dist-types/exports/globalData.d.ts.map +1 -0
- package/dist-types/exports/hydration/hydrationLoader.d.ts +2 -0
- package/dist-types/exports/hydration/hydrationLoader.d.ts.map +1 -0
- package/dist-types/exports/icons.d.ts +2 -0
- package/dist-types/exports/icons.d.ts.map +1 -0
- package/dist-types/exports/layout-helper.d.ts +2 -0
- package/dist-types/exports/layout-helper.d.ts.map +1 -0
- package/dist-types/exports/layout.d.ts +2 -0
- package/dist-types/exports/layout.d.ts.map +1 -0
- package/dist-types/exports/layouts/atlasDoc.d.ts +2 -0
- package/dist-types/exports/layouts/atlasDoc.d.ts.map +1 -0
- package/dist-types/exports/layouts/atlasHero.d.ts +2 -0
- package/dist-types/exports/layouts/atlasHero.d.ts.map +1 -0
- package/dist-types/exports/layouts/atlasNotFound.d.ts +2 -0
- package/dist-types/exports/layouts/atlasNotFound.d.ts.map +1 -0
- package/dist-types/exports/loaded-page-module.d.ts +2 -0
- package/dist-types/exports/loaded-page-module.d.ts.map +1 -0
- package/dist-types/exports/markdownHook.d.ts +2 -0
- package/dist-types/exports/markdownHook.d.ts.map +1 -0
- package/dist-types/exports/menu.d.ts +2 -0
- package/dist-types/exports/menu.d.ts.map +1 -0
- package/dist-types/exports/menus.d.ts +6 -0
- package/dist-types/exports/menus.d.ts.map +1 -0
- package/dist-types/exports/page-runtime.d.ts +2 -0
- package/dist-types/exports/page-runtime.d.ts.map +1 -0
- package/dist-types/exports/pages.d.ts +2 -0
- package/dist-types/exports/pages.d.ts.map +1 -0
- package/dist-types/exports/resolve.d.ts +2 -0
- package/dist-types/exports/resolve.d.ts.map +1 -0
- package/dist-types/exports/ssr.d.ts +2 -0
- package/dist-types/exports/ssr.d.ts.map +1 -0
- package/dist-types/exports/standalone-demo-url.d.ts +2 -0
- package/dist-types/exports/standalone-demo-url.d.ts.map +1 -0
- package/dist-types/exports/transform.d.ts +2 -0
- package/dist-types/exports/transform.d.ts.map +1 -0
- package/dist-types/exports/types/hydration.d.ts +23 -0
- package/dist-types/exports/types/hydration.d.ts.map +1 -0
- package/dist-types/exports/types/rocket.d.ts +504 -0
- package/dist-types/exports/types/rocket.d.ts.map +1 -0
- package/dist-types/exports/types.d.ts +3 -0
- package/dist-types/exports/types.d.ts.map +1 -0
- package/dist-types/exports/wds-plugin.d.ts +2 -0
- package/dist-types/exports/wds-plugin.d.ts.map +1 -0
- package/dist-types/src/PageData.d.ts +82 -0
- package/dist-types/src/PageData.d.ts.map +1 -0
- package/dist-types/src/RocketCodeBlock.d.ts +64 -0
- package/dist-types/src/RocketCodeBlock.d.ts.map +1 -0
- package/dist-types/src/RocketIcon.d.ts +35 -0
- package/dist-types/src/RocketIcon.d.ts.map +1 -0
- package/dist-types/src/RocketJsDemo.d.ts +59 -0
- package/dist-types/src/RocketJsDemo.d.ts.map +1 -0
- package/dist-types/src/RocketJsDemo.test-browser.d.ts +3 -0
- package/dist-types/src/RocketJsDemo.test-browser.d.ts.map +1 -0
- package/dist-types/src/RocketRequestDemo.d.ts +57 -0
- package/dist-types/src/RocketRequestDemo.d.ts.map +1 -0
- package/dist-types/src/RocketRequestDemo.test-browser.d.ts +3 -0
- package/dist-types/src/RocketRequestDemo.test-browser.d.ts.map +1 -0
- package/dist-types/src/SocialPreviewPlayground.d.ts +102 -0
- package/dist-types/src/SocialPreviewPlayground.d.ts.map +1 -0
- package/dist-types/src/adapters/netlify.d.ts +54 -0
- package/dist-types/src/adapters/netlify.d.ts.map +1 -0
- package/dist-types/src/asyncMessage.d.ts +14 -0
- package/dist-types/src/asyncMessage.d.ts.map +1 -0
- package/dist-types/src/cli/RocketBuild.d.ts +78 -0
- package/dist-types/src/cli/RocketBuild.d.ts.map +1 -0
- package/dist-types/src/cli/RocketCli.d.ts +17 -0
- package/dist-types/src/cli/RocketCli.d.ts.map +1 -0
- package/dist-types/src/cli/RocketInit.d.ts +22 -0
- package/dist-types/src/cli/RocketInit.d.ts.map +1 -0
- package/dist-types/src/cli/RocketStart.d.ts +13 -0
- package/dist-types/src/cli/RocketStart.d.ts.map +1 -0
- package/dist-types/src/cli/cli.d.ts +3 -0
- package/dist-types/src/cli/cli.d.ts.map +1 -0
- package/dist-types/src/component-hydration.d.ts +26 -0
- package/dist-types/src/component-hydration.d.ts.map +1 -0
- package/dist-types/src/components/FeatureList.d.ts +15 -0
- package/dist-types/src/components/FeatureList.d.ts.map +1 -0
- package/dist-types/src/components/Footer.d.ts +17 -0
- package/dist-types/src/components/Footer.d.ts.map +1 -0
- package/dist-types/src/components/Header.d.ts +6 -0
- package/dist-types/src/components/Header.d.ts.map +1 -0
- package/dist-types/src/components/RocketDrawer.d.ts +20 -0
- package/dist-types/src/components/RocketDrawer.d.ts.map +1 -0
- package/dist-types/src/components/RocketSocialLink.d.ts +30 -0
- package/dist-types/src/components/RocketSocialLink.d.ts.map +1 -0
- package/dist-types/src/components.d.ts +5 -0
- package/dist-types/src/components.d.ts.map +1 -0
- package/dist-types/src/config.d.ts +6 -0
- package/dist-types/src/config.d.ts.map +1 -0
- package/dist-types/src/debounce.d.ts +8 -0
- package/dist-types/src/debounce.d.ts.map +1 -0
- package/dist-types/src/defaultSocialPreviewTemplate.d.ts +31 -0
- package/dist-types/src/defaultSocialPreviewTemplate.d.ts.map +1 -0
- package/dist-types/src/development-page-module-loader.d.ts +15 -0
- package/dist-types/src/development-page-module-loader.d.ts.map +1 -0
- package/dist-types/src/extractCode.d.ts +5 -0
- package/dist-types/src/extractCode.d.ts.map +1 -0
- package/dist-types/src/hydration/evaluate.d.ts +20 -0
- package/dist-types/src/hydration/evaluate.d.ts.map +1 -0
- package/dist-types/src/hydration/extractStrategies.d.ts +5 -0
- package/dist-types/src/hydration/extractStrategies.d.ts.map +1 -0
- package/dist-types/src/hydration/hydrationLoader.d.ts +64 -0
- package/dist-types/src/hydration/hydrationLoader.d.ts.map +1 -0
- package/dist-types/src/icons.d.ts +170 -0
- package/dist-types/src/icons.d.ts.map +1 -0
- package/dist-types/src/layouts/atlas/atlasDocLayout.d.ts +45 -0
- package/dist-types/src/layouts/atlas/atlasDocLayout.d.ts.map +1 -0
- package/dist-types/src/layouts/atlas/atlasHeroLayout.d.ts +7 -0
- package/dist-types/src/layouts/atlas/atlasHeroLayout.d.ts.map +1 -0
- package/dist-types/src/layouts/atlas/atlasNotFoundLayout.d.ts +5 -0
- package/dist-types/src/layouts/atlas/atlasNotFoundLayout.d.ts.map +1 -0
- package/dist-types/src/layouts/layout-helper.d.ts +16 -0
- package/dist-types/src/layouts/layout-helper.d.ts.map +1 -0
- package/dist-types/src/layouts/layout.d.ts +9 -0
- package/dist-types/src/layouts/layout.d.ts.map +1 -0
- package/dist-types/src/loaded-page-module.d.ts +51 -0
- package/dist-types/src/loaded-page-module.d.ts.map +1 -0
- package/dist-types/src/main.d.ts +2 -0
- package/dist-types/src/main.d.ts.map +1 -0
- package/dist-types/src/markdownCompiler.d.ts +22 -0
- package/dist-types/src/markdownCompiler.d.ts.map +1 -0
- package/dist-types/src/markdownHook.d.ts +6 -0
- package/dist-types/src/markdownHook.d.ts.map +1 -0
- package/dist-types/src/menu.d.ts +22 -0
- package/dist-types/src/menu.d.ts.map +1 -0
- package/dist-types/src/menus/MainMenu.d.ts +23 -0
- package/dist-types/src/menus/MainMenu.d.ts.map +1 -0
- package/dist-types/src/menus/RocketMenu.d.ts +23 -0
- package/dist-types/src/menus/RocketMenu.d.ts.map +1 -0
- package/dist-types/src/menus/RocketNextPage.d.ts +18 -0
- package/dist-types/src/menus/RocketNextPage.d.ts.map +1 -0
- package/dist-types/src/menus/RocketPreviousPage.d.ts +18 -0
- package/dist-types/src/menus/RocketPreviousPage.d.ts.map +1 -0
- package/dist-types/src/menus/RocketToc.d.ts +54 -0
- package/dist-types/src/menus/RocketToc.d.ts.map +1 -0
- package/dist-types/src/menus/pageNavigation.d.ts +41 -0
- package/dist-types/src/menus/pageNavigation.d.ts.map +1 -0
- package/dist-types/src/page-pagination.d.ts +69 -0
- package/dist-types/src/page-pagination.d.ts.map +1 -0
- package/dist-types/src/page-runtime.d.ts +110 -0
- package/dist-types/src/page-runtime.d.ts.map +1 -0
- package/dist-types/src/pages.d.ts +10 -0
- package/dist-types/src/pages.d.ts.map +1 -0
- package/dist-types/src/publicAssets.d.ts +70 -0
- package/dist-types/src/publicAssets.d.ts.map +1 -0
- package/dist-types/src/requestDemoMetadata.d.ts +19 -0
- package/dist-types/src/requestDemoMetadata.d.ts.map +1 -0
- package/dist-types/src/resolve.d.ts +7 -0
- package/dist-types/src/resolve.d.ts.map +1 -0
- package/dist-types/src/siteDiscoverability.d.ts +33 -0
- package/dist-types/src/siteDiscoverability.d.ts.map +1 -0
- package/dist-types/src/siteHeadMetadata.d.ts +20 -0
- package/dist-types/src/siteHeadMetadata.d.ts.map +1 -0
- package/dist-types/src/socialPreviewImages.d.ts +186 -0
- package/dist-types/src/socialPreviewImages.d.ts.map +1 -0
- package/dist-types/src/socialPreviewTemplatePreview.d.ts +22 -0
- package/dist-types/src/socialPreviewTemplatePreview.d.ts.map +1 -0
- package/dist-types/src/ssr.d.ts +6 -0
- package/dist-types/src/ssr.d.ts.map +1 -0
- package/dist-types/src/standalone-demo-url.d.ts +60 -0
- package/dist-types/src/standalone-demo-url.d.ts.map +1 -0
- package/dist-types/src/static-page-module-loader.d.ts +15 -0
- package/dist-types/src/static-page-module-loader.d.ts.map +1 -0
- package/dist-types/src/transform.d.ts +10 -0
- package/dist-types/src/transform.d.ts.map +1 -0
- package/dist-types/src/urlLifecycle.d.ts +23 -0
- package/dist-types/src/urlLifecycle.d.ts.map +1 -0
- package/dist-types/src/wds-plugin.d.ts +14 -0
- package/dist-types/src/wds-plugin.d.ts.map +1 -0
- package/docs/assets/home-background.svg +1 -0
- package/docs/assets/prism-one-light.css +368 -0
- package/docs/assets/rocket-logo-dark-with-text-below.svg +8 -0
- package/docs/assets/rocket-logo-dark-with-text.svg +7 -0
- package/docs/assets/rocket-logo-dark.svg +7 -0
- package/docs/assets/rocket-logo-light-with-text-below.svg +14 -0
- package/docs/assets/rocket-logo-light-with-text.svg +13 -0
- package/docs/assets/rocket-logo-light.svg +12 -0
- package/docs/assets/rocket-text-no-logo.svg +3 -0
- package/exports/MainMenu.js +1 -0
- package/exports/PageData.js +1 -0
- package/exports/RocketCodeBlock.js +1 -0
- package/exports/RocketIcon.js +1 -0
- package/exports/RocketJsDemo.js +1 -0
- package/exports/RocketRequestDemo.js +1 -0
- package/exports/SocialPreviewPlayground.js +1 -0
- package/exports/adapters/netlify.js +1 -0
- package/exports/asyncMessage.js +1 -0
- package/exports/component-hydration.js +1 -0
- package/exports/components/web-awesome.js +63 -0
- package/exports/components.js +1 -0
- package/exports/config.js +1 -0
- package/exports/debounce.js +1 -0
- package/exports/define/RocketCodeBlock.js +2 -0
- package/exports/define/RocketIcon.js +3 -0
- package/exports/define/RocketJsDemo.js +5 -0
- package/exports/define/RocketRequestDemo.js +5 -0
- package/exports/define/menus.js +14 -0
- package/exports/extractCode.js +1 -0
- package/exports/globalData.js +1 -0
- package/exports/hydration/hydrationLoader.js +1 -0
- package/exports/icons.js +8 -0
- package/exports/layout-helper.js +1 -0
- package/exports/layout.js +1 -0
- package/exports/layouts/_atlas.css +3 -0
- package/exports/layouts/atlasDoc.js +5 -0
- package/exports/layouts/atlasHero.js +1 -0
- package/exports/layouts/atlasNotFound.js +4 -0
- package/exports/loaded-page-module.js +5 -0
- package/exports/markdownHook.js +4 -0
- package/exports/menu.js +4 -0
- package/exports/menus.js +5 -0
- package/exports/page-runtime.js +5 -0
- package/exports/pages.js +1 -0
- package/exports/resolve.js +1 -0
- package/exports/ssr.js +1 -0
- package/exports/standalone-demo-url.js +10 -0
- package/exports/transform.js +1 -0
- package/exports/types/hydration.ts +26 -0
- package/exports/types/rocket.ts +598 -0
- package/exports/types.ts +71 -0
- package/exports/wds-plugin.js +1 -0
- package/package.json +192 -9
- package/src/PageData.js +244 -0
- package/src/RocketCodeBlock.js +516 -0
- package/src/RocketIcon.js +291 -0
- package/src/RocketJsDemo.js +397 -0
- package/src/RocketJsDemo.test-browser.js +228 -0
- package/src/RocketRequestDemo.js +439 -0
- package/src/RocketRequestDemo.test-browser.js +301 -0
- package/src/SocialPreviewPlayground.js +573 -0
- package/src/adapters/netlify.js +814 -0
- package/src/asyncMessage.js +21 -0
- package/src/cli/RocketBuild.js +545 -0
- package/src/cli/RocketCli.js +47 -0
- package/src/cli/RocketInit.js +323 -0
- package/src/cli/RocketStart.js +79 -0
- package/src/cli/cli.js +7 -0
- package/src/component-hydration.js +86 -0
- package/src/components/FeatureList.js +114 -0
- package/src/components/Footer.js +116 -0
- package/src/components/Header.js +122 -0
- package/src/components/RocketDrawer.js +193 -0
- package/src/components/RocketSocialLink.js +128 -0
- package/src/components/assets/discord.svg +7 -0
- package/src/components/assets/github.svg +4 -0
- package/src/components/assets/gitlab.svg +1 -0
- package/src/components/assets/info.txt +1 -0
- package/src/components/assets/license.svg +3 -0
- package/src/components/assets/npm.svg +5 -0
- package/src/components/assets/slack.svg +5 -0
- package/src/components/assets/telegram.svg +4 -0
- package/src/components/assets/twitter.svg +1 -0
- package/src/components.js +15 -0
- package/src/config.js +319 -0
- package/src/debounce.js +21 -0
- package/src/defaultSocialPreviewTemplate.js +118 -0
- package/src/development-page-module-loader.js +29 -0
- package/src/extractCode.js +41 -0
- package/src/hydration/evaluate.js +54 -0
- package/src/hydration/extractStrategies.js +91 -0
- package/src/hydration/hydrationLoader.js +330 -0
- package/src/icons.js +883 -0
- package/src/layouts/atlas/atlasDoc.css +877 -0
- package/src/layouts/atlas/atlasDocLayout.js +288 -0
- package/src/layouts/atlas/atlasHero.css +774 -0
- package/src/layouts/atlas/atlasHeroLayout.js +346 -0
- package/src/layouts/atlas/atlasNotFound.css +365 -0
- package/src/layouts/atlas/atlasNotFoundLayout.js +69 -0
- package/src/layouts/layout-helper.js +92 -0
- package/src/layouts/layout.js +62 -0
- package/src/loaded-page-module.js +97 -0
- package/src/main.js +55 -0
- package/src/markdownCompiler.js +303 -0
- package/src/markdownHook.js +148 -0
- package/src/menu.js +210 -0
- package/src/menus/MainMenu.js +58 -0
- package/src/menus/RocketMenu.js +191 -0
- package/src/menus/RocketNextPage.js +25 -0
- package/src/menus/RocketPreviousPage.js +29 -0
- package/src/menus/RocketToc.js +309 -0
- package/src/menus/pageNavigation.js +285 -0
- package/src/page-pagination.js +241 -0
- package/src/page-runtime.js +481 -0
- package/src/pages.js +537 -0
- package/src/publicAssets.js +336 -0
- package/src/requestDemoMetadata.js +97 -0
- package/src/resolve.js +15 -0
- package/src/siteDiscoverability.js +184 -0
- package/src/siteHeadMetadata.js +69 -0
- package/src/socialPreviewImages.js +482 -0
- package/src/socialPreviewTemplatePreview.js +352 -0
- package/src/ssr.js +14 -0
- package/src/standalone-demo-url.js +134 -0
- package/src/static-page-module-loader.js +29 -0
- package/src/transform.js +633 -0
- package/src/urlLifecycle.js +57 -0
- package/src/wds-plugin.js +302 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
/** Runs on: browser */
|
|
3
|
+
|
|
4
|
+
const SHADOW_ICON_STYLE =
|
|
5
|
+
':host{display:inline-block;width:1em;height:1em;vertical-align:-0.125em;line-height:1}' +
|
|
6
|
+
':host([hidden]){display:none}' +
|
|
7
|
+
'span[part="icon"]{display:inline-flex;width:100%;height:100%;line-height:1}' +
|
|
8
|
+
'span[part="icon"]>svg{display:block;width:100%;height:100%}';
|
|
9
|
+
|
|
10
|
+
/** @type {WeakMap<Document, { defaultLibrary?: string; icons: Record<string, string> } | null>} */
|
|
11
|
+
const manifestCache = new WeakMap();
|
|
12
|
+
|
|
13
|
+
export class RocketIcon extends HTMLElement {
|
|
14
|
+
static observedAttributes = ['name', 'library', 'icon-loading', 'aria-label', 'aria-labelledby'];
|
|
15
|
+
|
|
16
|
+
/** @type {Map<string, string | Promise<string>>} */
|
|
17
|
+
static svgCache = new Map();
|
|
18
|
+
|
|
19
|
+
/** @type {string | undefined} */
|
|
20
|
+
pendingUrl;
|
|
21
|
+
|
|
22
|
+
/** @type {IntersectionObserver | undefined} */
|
|
23
|
+
intersectionObserver;
|
|
24
|
+
|
|
25
|
+
hasCompletedInitialConnection = false;
|
|
26
|
+
|
|
27
|
+
hasSetIconRole = false;
|
|
28
|
+
|
|
29
|
+
connectedCallback() {
|
|
30
|
+
this.ensureShadowRoot();
|
|
31
|
+
this.syncAccessibilitySemantics();
|
|
32
|
+
this.hasCompletedInitialConnection = true;
|
|
33
|
+
if (this.hasRenderedIcon()) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
this.resolveIcon();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
disconnectedCallback() {
|
|
40
|
+
this.disconnectObserver();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {string} name
|
|
45
|
+
* @param {string | null} oldValue
|
|
46
|
+
* @param {string | null} newValue
|
|
47
|
+
*/
|
|
48
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
49
|
+
if (oldValue === newValue || !this.hasCompletedInitialConnection) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (name === 'aria-label' || name === 'aria-labelledby') {
|
|
53
|
+
this.syncAccessibilitySemantics();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
this.clearIcon();
|
|
57
|
+
if (this.isConnected) {
|
|
58
|
+
this.resolveIcon();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
ensureShadowRoot() {
|
|
63
|
+
if (!this.shadowRoot) {
|
|
64
|
+
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
65
|
+
shadowRoot.innerHTML = `<style>${SHADOW_ICON_STYLE}</style><span part="icon"></span>`;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (!this.iconSlot) {
|
|
69
|
+
this.shadowRoot.innerHTML = `<style>${SHADOW_ICON_STYLE}</style><span part="icon"></span>`;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
get iconSlot() {
|
|
74
|
+
return this.shadowRoot?.querySelector('[part="icon"]') || null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
hasRenderedIcon() {
|
|
78
|
+
return this.iconSlot?.hasChildNodes() === true;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
syncAccessibilitySemantics() {
|
|
82
|
+
const hasIconLabel =
|
|
83
|
+
hasNonEmptyAttribute(this, 'aria-label') || hasNonEmptyAttribute(this, 'aria-labelledby');
|
|
84
|
+
if (hasIconLabel) {
|
|
85
|
+
if (!this.hasAttribute('role')) {
|
|
86
|
+
this.setAttribute('role', 'img');
|
|
87
|
+
this.hasSetIconRole = true;
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (this.hasSetIconRole && this.getAttribute('role') === 'img') {
|
|
93
|
+
this.removeAttribute('role');
|
|
94
|
+
}
|
|
95
|
+
this.hasSetIconRole = false;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
clearIcon() {
|
|
99
|
+
this.disconnectObserver();
|
|
100
|
+
this.pendingUrl = undefined;
|
|
101
|
+
const iconSlot = this.iconSlot;
|
|
102
|
+
if (iconSlot) {
|
|
103
|
+
iconSlot.innerHTML = '';
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
resolveIcon() {
|
|
108
|
+
this.ensureShadowRoot();
|
|
109
|
+
const name = this.getAttribute('name')?.trim();
|
|
110
|
+
if (!name) {
|
|
111
|
+
warn('rocket-icon requires a non-empty name attribute.');
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const loading = this.getAttribute('icon-loading') || 'auto';
|
|
116
|
+
if (loading === 'server') {
|
|
117
|
+
warn('Browser-created rocket-icon cannot use icon-loading="server"; using client loading.');
|
|
118
|
+
} else if (loading !== 'auto' && loading !== 'client') {
|
|
119
|
+
warn(`Invalid rocket-icon icon-loading ${JSON.stringify(loading)}; using client loading.`);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const manifest = readManifest(this.ownerDocument);
|
|
123
|
+
if (!manifest) {
|
|
124
|
+
warn(`rocket-icon "${name}" cannot load because the Icon Manifest is missing.`);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const library = this.getAttribute('library')?.trim() || manifest.defaultLibrary;
|
|
129
|
+
if (!library) {
|
|
130
|
+
warn(`rocket-icon "${name}" has no Icon Library in the Icon Manifest.`);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const key = `${library}:${name}`;
|
|
135
|
+
const url = manifest.icons[key];
|
|
136
|
+
if (!url) {
|
|
137
|
+
warn(`rocket-icon "${key}" is absent from the Icon Manifest.`);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
this.pendingUrl = url;
|
|
142
|
+
this.observeVisibility(url);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @param {string} url
|
|
147
|
+
*/
|
|
148
|
+
observeVisibility(url) {
|
|
149
|
+
this.disconnectObserver();
|
|
150
|
+
if (!('IntersectionObserver' in globalThis)) {
|
|
151
|
+
warn('rocket-icon cannot load until IntersectionObserver is available.');
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this.intersectionObserver = new IntersectionObserver(entries => {
|
|
155
|
+
if (!entries.some(entry => entry.isIntersecting)) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
this.disconnectObserver();
|
|
159
|
+
this.loadSvg(url);
|
|
160
|
+
});
|
|
161
|
+
this.intersectionObserver.observe(this);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
disconnectObserver() {
|
|
165
|
+
this.intersectionObserver?.disconnect();
|
|
166
|
+
this.intersectionObserver = undefined;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @param {string} url
|
|
171
|
+
*/
|
|
172
|
+
async loadSvg(url) {
|
|
173
|
+
try {
|
|
174
|
+
const svg = await cachedSvg(url);
|
|
175
|
+
if (this.pendingUrl !== url) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const iconSlot = this.iconSlot;
|
|
179
|
+
if (iconSlot) {
|
|
180
|
+
iconSlot.innerHTML = svg;
|
|
181
|
+
}
|
|
182
|
+
} catch (error) {
|
|
183
|
+
warn(`rocket-icon failed to fetch ${url}.`, error);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* @param {string} url
|
|
190
|
+
*/
|
|
191
|
+
async function cachedSvg(url) {
|
|
192
|
+
const cached = RocketIcon.svgCache.get(url);
|
|
193
|
+
if (typeof cached === 'string') {
|
|
194
|
+
return cached;
|
|
195
|
+
}
|
|
196
|
+
if (cached) {
|
|
197
|
+
return cached;
|
|
198
|
+
}
|
|
199
|
+
const promise = fetch(url)
|
|
200
|
+
.then(response => {
|
|
201
|
+
if (!response.ok) {
|
|
202
|
+
throw new Error(`HTTP ${response.status}`);
|
|
203
|
+
}
|
|
204
|
+
return response.text();
|
|
205
|
+
})
|
|
206
|
+
.then(svg => {
|
|
207
|
+
RocketIcon.svgCache.set(url, svg);
|
|
208
|
+
return svg;
|
|
209
|
+
})
|
|
210
|
+
.catch(error => {
|
|
211
|
+
RocketIcon.svgCache.delete(url);
|
|
212
|
+
throw error;
|
|
213
|
+
});
|
|
214
|
+
RocketIcon.svgCache.set(url, promise);
|
|
215
|
+
return promise;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* @param {Document} document
|
|
220
|
+
*/
|
|
221
|
+
function readManifest(document) {
|
|
222
|
+
if (manifestCache.has(document)) {
|
|
223
|
+
return manifestCache.get(document);
|
|
224
|
+
}
|
|
225
|
+
const script = document.querySelector(
|
|
226
|
+
'script[type="application/json"][data-rocket-icon-manifest]',
|
|
227
|
+
);
|
|
228
|
+
if (!script?.textContent) {
|
|
229
|
+
manifestCache.set(document, null);
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
try {
|
|
233
|
+
const manifest = JSON.parse(script.textContent);
|
|
234
|
+
if (!manifest || typeof manifest !== 'object' || !isPlainRecord(manifest.icons)) {
|
|
235
|
+
manifestCache.set(document, null);
|
|
236
|
+
warn('rocket-icon Icon Manifest is invalid.');
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
const defaultLibrary =
|
|
240
|
+
typeof manifest.defaultLibrary === 'string' ? manifest.defaultLibrary : undefined;
|
|
241
|
+
const icons = /** @type {Record<string, string>} */ (manifest.icons);
|
|
242
|
+
manifestCache.set(document, { defaultLibrary, icons });
|
|
243
|
+
return { defaultLibrary, icons };
|
|
244
|
+
} catch (error) {
|
|
245
|
+
manifestCache.set(document, null);
|
|
246
|
+
warn('rocket-icon Icon Manifest could not be parsed.', error);
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* @param {unknown} value
|
|
253
|
+
* @returns {value is Record<string, unknown>}
|
|
254
|
+
*/
|
|
255
|
+
function isPlainRecord(value) {
|
|
256
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
const prototype = Object.getPrototypeOf(value);
|
|
260
|
+
return prototype === Object.prototype || prototype === null;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* @param {string} message
|
|
265
|
+
* @param {unknown} [error]
|
|
266
|
+
*/
|
|
267
|
+
function warn(message, error) {
|
|
268
|
+
if (!isDevelopment()) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (error) {
|
|
272
|
+
console.warn(message, error);
|
|
273
|
+
} else {
|
|
274
|
+
console.warn(message);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function isDevelopment() {
|
|
279
|
+
const hostname = globalThis.location?.hostname;
|
|
280
|
+
return (
|
|
281
|
+
!hostname || hostname === 'localhost' || hostname === '127.0.0.1' || hostname.endsWith('.test')
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* @param {Element} element
|
|
287
|
+
* @param {string} name
|
|
288
|
+
*/
|
|
289
|
+
function hasNonEmptyAttribute(element, name) {
|
|
290
|
+
return Boolean(element.getAttribute(name)?.trim());
|
|
291
|
+
}
|
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
/** Runs on: client */
|
|
2
|
+
import { css, html } from 'lit';
|
|
3
|
+
import { LitElement } from 'lit';
|
|
4
|
+
import { createRef, ref } from 'lit/directives/ref.js';
|
|
5
|
+
import '@awesome.me/webawesome/dist/components/icon/icon.js';
|
|
6
|
+
import '@awesome.me/webawesome/dist/components/button/button.js';
|
|
7
|
+
import { until } from 'lit/directives/until.js';
|
|
8
|
+
import { standaloneDemoPath, standaloneDemoUrl } from './standalone-demo-url.js';
|
|
9
|
+
|
|
10
|
+
export { standaloneDemoUrl };
|
|
11
|
+
|
|
12
|
+
/** @type {Record<string, string>} */
|
|
13
|
+
const copyButtonLabels = {
|
|
14
|
+
copy: 'Copy Standalone Demo URL',
|
|
15
|
+
success: 'Copied Standalone Demo URL',
|
|
16
|
+
error: 'Unable to copy Standalone Demo URL',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {string} parentUrl
|
|
21
|
+
* @param {string} demoName
|
|
22
|
+
*/
|
|
23
|
+
export function standaloneDemoPathFromUrl(parentUrl, demoName) {
|
|
24
|
+
return standaloneDemoPath(new URL(parentUrl).pathname, demoName);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class RocketJsDemo extends LitElement {
|
|
28
|
+
static properties = {
|
|
29
|
+
demo: { type: Function },
|
|
30
|
+
singleDemo: { type: Boolean, attribute: 'single-demo', reflect: true },
|
|
31
|
+
_copyState: { type: String, state: true },
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
constructor() {
|
|
35
|
+
super();
|
|
36
|
+
/** @type {(options: { wrapperRef?: import('lit/directives/ref.js').Ref }) => import('lit').TemplateResult } */
|
|
37
|
+
this.demo = () => html`<p>Loading...</p>`;
|
|
38
|
+
this.preview = createRef();
|
|
39
|
+
this.singleDemo = false;
|
|
40
|
+
this._copyState = 'copy';
|
|
41
|
+
this.copyStateResetDelay = 2000;
|
|
42
|
+
/** @type {ReturnType<typeof setTimeout> | undefined} */
|
|
43
|
+
this.copyStateResetTimeout = undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get demoName() {
|
|
47
|
+
return this.getAttribute('demo-name') || '';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
get standaloneDemoPath() {
|
|
51
|
+
if (!this.demoName) {
|
|
52
|
+
return '';
|
|
53
|
+
}
|
|
54
|
+
return standaloneDemoPathFromUrl(window.location.href, this.demoName);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
openStandaloneDemo() {
|
|
58
|
+
const url = this.standaloneDemoPath;
|
|
59
|
+
if (!url) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
window.open(url, '_blank', 'noopener,noreferrer');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async copyStandaloneDemoUrl() {
|
|
67
|
+
const url = this.standaloneDemoPath;
|
|
68
|
+
if (!url) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
this.clearCopyStateResetTimeout();
|
|
73
|
+
try {
|
|
74
|
+
await navigator.clipboard.writeText(url);
|
|
75
|
+
this._copyState = 'success';
|
|
76
|
+
} catch {
|
|
77
|
+
this._copyState = 'error';
|
|
78
|
+
}
|
|
79
|
+
this.scheduleCopyStateReset();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
disconnectedCallback() {
|
|
83
|
+
super.disconnectedCallback();
|
|
84
|
+
this.clearCopyStateResetTimeout();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
scheduleCopyStateReset() {
|
|
88
|
+
this.copyStateResetTimeout = setTimeout(() => {
|
|
89
|
+
this.copyStateResetTimeout = undefined;
|
|
90
|
+
this._copyState = 'copy';
|
|
91
|
+
}, this.copyStateResetDelay);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
clearCopyStateResetTimeout() {
|
|
95
|
+
if (this.copyStateResetTimeout !== undefined) {
|
|
96
|
+
clearTimeout(this.copyStateResetTimeout);
|
|
97
|
+
this.copyStateResetTimeout = undefined;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @param {PointerEvent} ev
|
|
103
|
+
*/
|
|
104
|
+
handleResizePointerDown(ev) {
|
|
105
|
+
const startX = ev.clientX;
|
|
106
|
+
const element = this.preview.value;
|
|
107
|
+
if (!element) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const startWidth = element.getBoundingClientRect().width;
|
|
111
|
+
const target = /** @type {HTMLElement} */ (ev.currentTarget);
|
|
112
|
+
|
|
113
|
+
ev.preventDefault();
|
|
114
|
+
target.setPointerCapture(ev.pointerId);
|
|
115
|
+
const pointerMoveHandler = (/** @type {PointerEvent} */ ev) => {
|
|
116
|
+
const diff = ev.clientX - startX;
|
|
117
|
+
this.setPreviewWidth(startWidth + diff);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const pointerUpHandler = (/** @type {PointerEvent} */ ev) => {
|
|
121
|
+
target.releasePointerCapture(ev.pointerId);
|
|
122
|
+
target.removeEventListener('pointermove', pointerMoveHandler);
|
|
123
|
+
target.removeEventListener('pointerup', pointerUpHandler);
|
|
124
|
+
target.removeEventListener('pointercancel', pointerUpHandler);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
target.addEventListener('pointermove', pointerMoveHandler);
|
|
128
|
+
target.addEventListener('pointerup', pointerUpHandler);
|
|
129
|
+
target.addEventListener('pointercancel', pointerUpHandler);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @param {KeyboardEvent} ev
|
|
134
|
+
*/
|
|
135
|
+
handleResizeKeyDown(ev) {
|
|
136
|
+
const step = ev.shiftKey ? 64 : 16;
|
|
137
|
+
if (ev.key === 'ArrowLeft') {
|
|
138
|
+
ev.preventDefault();
|
|
139
|
+
this.resizePreviewBy(-step);
|
|
140
|
+
} else if (ev.key === 'ArrowRight') {
|
|
141
|
+
ev.preventDefault();
|
|
142
|
+
this.resizePreviewBy(step);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @param {number} delta
|
|
148
|
+
*/
|
|
149
|
+
resizePreviewBy(delta) {
|
|
150
|
+
const element = this.preview.value;
|
|
151
|
+
if (!element) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this.setPreviewWidth(element.getBoundingClientRect().width + delta);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @param {number} width
|
|
159
|
+
*/
|
|
160
|
+
setPreviewWidth(width) {
|
|
161
|
+
const element = this.preview.value;
|
|
162
|
+
if (!(element instanceof HTMLElement)) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const maxWidth = element.parentElement?.getBoundingClientRect().width ?? width;
|
|
166
|
+
const clampedWidth = Math.min(Math.max(width, 160), maxWidth);
|
|
167
|
+
element.style.width = `${Math.round(clampedWidth)}px`;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
render() {
|
|
171
|
+
if (this.singleDemo) {
|
|
172
|
+
return html`
|
|
173
|
+
<div ${ref(this.preview)}>
|
|
174
|
+
${until(this.demo({ wrapperRef: this.preview }), 'loading...')}
|
|
175
|
+
</div>
|
|
176
|
+
`;
|
|
177
|
+
}
|
|
178
|
+
return html`
|
|
179
|
+
<div id="bg">
|
|
180
|
+
<div ${ref(this.preview)} id="wrapper">
|
|
181
|
+
${until(this.demo({ wrapperRef: this.preview }), 'loading...')}
|
|
182
|
+
<button
|
|
183
|
+
type="button"
|
|
184
|
+
id="resize"
|
|
185
|
+
aria-label="Resize JavaScript Demo width"
|
|
186
|
+
title="Resize JavaScript Demo width"
|
|
187
|
+
@pointerdown=${(/** @type {PointerEvent} */ ev) => this.handleResizePointerDown(ev)}
|
|
188
|
+
@keydown=${(/** @type {KeyboardEvent} */ ev) => this.handleResizeKeyDown(ev)}
|
|
189
|
+
>
|
|
190
|
+
<wa-icon name="grip-vertical" variant="solid"></wa-icon>
|
|
191
|
+
</button>
|
|
192
|
+
</div>
|
|
193
|
+
</div>
|
|
194
|
+
<div id="bottom">
|
|
195
|
+
<div id="source-row">
|
|
196
|
+
<details id="source">
|
|
197
|
+
<summary>Source</summary>
|
|
198
|
+
<slot></slot>
|
|
199
|
+
</details>
|
|
200
|
+
<div id="standalone-actions" aria-label="Standalone Demo URL actions">
|
|
201
|
+
<wa-button
|
|
202
|
+
id="open-standalone-demo"
|
|
203
|
+
appearance="plain"
|
|
204
|
+
title="Open Standalone Demo URL"
|
|
205
|
+
aria-label="Open Standalone Demo URL"
|
|
206
|
+
@click=${() => this.openStandaloneDemo()}
|
|
207
|
+
>
|
|
208
|
+
<wa-icon name="arrow-up-right-from-square" variant="solid"></wa-icon>
|
|
209
|
+
</wa-button>
|
|
210
|
+
<wa-button
|
|
211
|
+
id="copy-standalone-demo"
|
|
212
|
+
appearance="plain"
|
|
213
|
+
title=${copyButtonLabels[this._copyState] || copyButtonLabels.copy}
|
|
214
|
+
aria-label=${copyButtonLabels[this._copyState] || copyButtonLabels.copy}
|
|
215
|
+
@click=${() => this.copyStandaloneDemoUrl()}
|
|
216
|
+
>
|
|
217
|
+
<wa-icon
|
|
218
|
+
name=${this._copyState === 'success'
|
|
219
|
+
? 'check'
|
|
220
|
+
: this._copyState === 'error'
|
|
221
|
+
? 'xmark'
|
|
222
|
+
: 'copy'}
|
|
223
|
+
variant=${this._copyState === 'copy' ? 'regular' : 'solid'}
|
|
224
|
+
></wa-icon>
|
|
225
|
+
</wa-button>
|
|
226
|
+
</div>
|
|
227
|
+
</div>
|
|
228
|
+
</div>
|
|
229
|
+
`;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
static styles = [
|
|
233
|
+
css`
|
|
234
|
+
:host(:not([single-demo])) {
|
|
235
|
+
display: block;
|
|
236
|
+
--resize-width: 1.5rem;
|
|
237
|
+
--border-color: #dbe3ec;
|
|
238
|
+
--border: 1px solid var(--border-color);
|
|
239
|
+
--border-radius: 8px;
|
|
240
|
+
--frame-header: #f8fafc;
|
|
241
|
+
--frame-muted: #57606a;
|
|
242
|
+
--frame-text: #24292f;
|
|
243
|
+
border: var(--border);
|
|
244
|
+
border-radius: var(--border-radius);
|
|
245
|
+
margin-bottom: var(--wa-content-spacing);
|
|
246
|
+
overflow: hidden;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
#bg {
|
|
250
|
+
background-color: #eee;
|
|
251
|
+
width: 100%;
|
|
252
|
+
overflow: hidden;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
#resize {
|
|
256
|
+
position: absolute;
|
|
257
|
+
top: 0;
|
|
258
|
+
right: 0;
|
|
259
|
+
bottom: 0;
|
|
260
|
+
width: var(--resize-width);
|
|
261
|
+
border-left: var(--border);
|
|
262
|
+
border-top: 0;
|
|
263
|
+
border-right: 0;
|
|
264
|
+
border-bottom: 0;
|
|
265
|
+
cursor: ew-resize;
|
|
266
|
+
background: white;
|
|
267
|
+
color: var(--frame-muted);
|
|
268
|
+
display: flex;
|
|
269
|
+
justify-content: center;
|
|
270
|
+
align-items: center;
|
|
271
|
+
padding: 0;
|
|
272
|
+
touch-action: none;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
#wrapper {
|
|
276
|
+
position: relative;
|
|
277
|
+
padding: 1rem calc(1rem + var(--resize-width)) 1rem 1rem;
|
|
278
|
+
box-sizing: border-box;
|
|
279
|
+
max-width: 100%;
|
|
280
|
+
min-width: min-content;
|
|
281
|
+
background: white;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
#bottom {
|
|
285
|
+
position: relative;
|
|
286
|
+
--standalone-action-size: 2.75rem;
|
|
287
|
+
--standalone-actions-width: calc(var(--standalone-action-size) * 2);
|
|
288
|
+
border-top: var(--border);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
#source-row {
|
|
292
|
+
position: relative;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
#source {
|
|
296
|
+
display: block;
|
|
297
|
+
min-inline-size: 0;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
#source summary {
|
|
301
|
+
display: flex;
|
|
302
|
+
align-items: center;
|
|
303
|
+
justify-content: center;
|
|
304
|
+
gap: 0.4rem;
|
|
305
|
+
min-block-size: var(--standalone-action-size);
|
|
306
|
+
box-sizing: border-box;
|
|
307
|
+
cursor: pointer;
|
|
308
|
+
color: var(--frame-muted);
|
|
309
|
+
font-size: 0.875rem;
|
|
310
|
+
font-weight: 600;
|
|
311
|
+
line-height: 1.2;
|
|
312
|
+
list-style: none;
|
|
313
|
+
padding-block: 0;
|
|
314
|
+
padding-inline: var(--standalone-actions-width);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
#source summary::marker {
|
|
318
|
+
content: '';
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
#source summary::-webkit-details-marker {
|
|
322
|
+
display: none;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
#source summary::after {
|
|
326
|
+
content: '';
|
|
327
|
+
display: inline-block;
|
|
328
|
+
flex: 0 0 auto;
|
|
329
|
+
box-sizing: border-box;
|
|
330
|
+
inline-size: 0.52rem;
|
|
331
|
+
block-size: 0.52rem;
|
|
332
|
+
border: solid currentColor;
|
|
333
|
+
border-width: 0 2px 2px 0;
|
|
334
|
+
transform: rotate(-45deg);
|
|
335
|
+
transform-origin: center;
|
|
336
|
+
transition: transform 120ms ease-in-out;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
#source[open] summary {
|
|
340
|
+
border-bottom: var(--border);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
#source[open] summary::after {
|
|
344
|
+
transform: rotate(45deg);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
#standalone-actions {
|
|
348
|
+
position: absolute;
|
|
349
|
+
inset-block-start: 0;
|
|
350
|
+
inset-inline-end: 0;
|
|
351
|
+
display: flex;
|
|
352
|
+
align-items: stretch;
|
|
353
|
+
block-size: var(--standalone-action-size);
|
|
354
|
+
border-left: var(--border);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
#open-standalone-demo,
|
|
358
|
+
#copy-standalone-demo {
|
|
359
|
+
inline-size: var(--standalone-action-size);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
#open-standalone-demo::part(base),
|
|
363
|
+
#copy-standalone-demo::part(base) {
|
|
364
|
+
display: inline-grid;
|
|
365
|
+
place-items: center;
|
|
366
|
+
min-block-size: var(--standalone-action-size);
|
|
367
|
+
inline-size: 100%;
|
|
368
|
+
border: none;
|
|
369
|
+
border-radius: 0;
|
|
370
|
+
padding: 0;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
#copy-standalone-demo::part(base) {
|
|
374
|
+
border-left: var(--border);
|
|
375
|
+
border-radius: 0;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
::slotted(pre) {
|
|
379
|
+
font-size: 0.9rem;
|
|
380
|
+
border-radius: 0;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
::slotted(rocket-code-block) {
|
|
384
|
+
--rocket-code-border-radius: 0 0 calc(var(--border-radius) - 1px)
|
|
385
|
+
calc(var(--border-radius) - 1px);
|
|
386
|
+
--rocket-code-frame-border: none;
|
|
387
|
+
--rocket-code-margin: 0;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
@media (prefers-reduced-motion: reduce) {
|
|
391
|
+
#source summary::after {
|
|
392
|
+
transition: none;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
`,
|
|
396
|
+
];
|
|
397
|
+
}
|