diff --git a/ui/src/javascript/web-components/webui-share.ts b/ui/src/javascript/web-components/webui-share.ts index eac7180..628bb9f 100644 --- a/ui/src/javascript/web-components/webui-share.ts +++ b/ui/src/javascript/web-components/webui-share.ts @@ -16,9 +16,9 @@ export default class WebUIShare extends HTMLElement { this.shareInput = this.querySelector('[data-input]'); this.canonical = document.querySelector('link[rel=canonical]'); - this.shareTitle = this.btnShare?.dataset.shareTitle || document.title; + this.shareTitle = this.btnShare?.dataset.title || document.title; this.shareUrl = - this.btnShare?.dataset.shareUrl || this.canonical + this.btnShare?.dataset.url || this.canonical ? this.canonical?.href : document.location.href; diff --git a/ui/stories/6. Web Components Or Custom Elements/WebUIShare/WebUIShare.js b/ui/stories/6. Web Components Or Custom Elements/WebUIShare/WebUIShare.js index 9be348b..d253a50 100644 --- a/ui/stories/6. Web Components Or Custom Elements/WebUIShare/WebUIShare.js +++ b/ui/stories/6. Web Components Or Custom Elements/WebUIShare/WebUIShare.js @@ -37,3 +37,45 @@ export const WebUIShareHtml = () => ` `; + +export const WebUIShareAnotherUrlHtml = () => ` + + + + +
+ + + +
+
+
+`; diff --git a/ui/stories/6. Web Components Or Custom Elements/WebUIShare/WebUIShare.mdx b/ui/stories/6. Web Components Or Custom Elements/WebUIShare/WebUIShare.mdx index 2fb3bcb..7ecbdb0 100644 --- a/ui/stories/6. Web Components Or Custom Elements/WebUIShare/WebUIShare.mdx +++ b/ui/stories/6. Web Components Or Custom Elements/WebUIShare/WebUIShare.mdx @@ -1,4 +1,4 @@ -import { Meta, Canvas, Controls } from '@storybook/blocks'; +import { Meta, Canvas } from '@storybook/blocks'; import * as WebUIShare from './WebUIShare.stories'; @@ -8,4 +8,6 @@ import * as WebUIShare from './WebUIShare.stories'; - It is a simple `wrapper` around the [webui-disclosure](/story/web-components-or-custom-elements-webui-disclosure--web-ui-disclosure) custom element. - + +## Share a different URL + diff --git a/ui/stories/6. Web Components Or Custom Elements/WebUIShare/WebUIShare.stories.js b/ui/stories/6. Web Components Or Custom Elements/WebUIShare/WebUIShare.stories.js index bd70514..85ae471 100644 --- a/ui/stories/6. Web Components Or Custom Elements/WebUIShare/WebUIShare.stories.js +++ b/ui/stories/6. Web Components Or Custom Elements/WebUIShare/WebUIShare.stories.js @@ -1,4 +1,4 @@ -import { WebUIShareHtml } from './WebUIShare'; +import { WebUIShareHtml, WebUIShareAnotherUrlHtml } from './WebUIShare'; export default { title: 'Web Components Or Custom Elements/', @@ -13,3 +13,8 @@ export const WebUIShare = { render: () => WebUIShareHtml(), }; WebUIShare.storyName = ''; + +export const WebUIShareAnotherUrl = { + render: () => WebUIShareAnotherUrlHtml(), +}; +WebUIShareAnotherUrl.storyName = ' Another URL';