-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(share-button): small perf and size refactor for v1 release
- Loading branch information
Showing
7 changed files
with
71 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@parsonic/share-button': major | ||
--- | ||
|
||
Tidy up and release as v1 |
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,2 +1,3 @@ | ||
node_modules | ||
dist | ||
packages/share-button/min.js |
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 |
---|---|---|
|
@@ -21,8 +21,7 @@ Add the script tag and use the button in your page. | |
```html | ||
<script | ||
defer | ||
type="module" | ||
src="https://cdn.jsdelivr.net/npm/@parsonic/share-button@latest/dist/index.js" | ||
src="https://cdn.jsdelivr.net/npm/@parsonic/share-button@latest/min.js" | ||
></script> | ||
<share-button data-button-label="Share this page"></share-button> | ||
``` | ||
|
@@ -68,7 +67,7 @@ supports it. If the share feature is not available the component will not be | |
defined and will either show the fallback content or no button at all. | ||
|
||
For control over the share data you can provide the share button with data | ||
attribute. Below is an example using Nunjucks template syntax. | ||
attributes. Below is an example using Nunjucks template syntax. | ||
|
||
```html | ||
<share-button | ||
|
@@ -103,7 +102,7 @@ Provide a label for the button with the `data-button-label` attribute. | |
<share-button data-button-label="Share this page"></share-button> | ||
``` | ||
|
||
Style the button use the `button` part selector. | ||
Style the button using the `button` part selector. | ||
|
||
```css | ||
share-button::part(button) { | ||
|
@@ -121,9 +120,9 @@ Provide your own button in the `button` slot. | |
|
||
## Share event | ||
|
||
When the share button is clicked a custom event with the name `share` is | ||
dispatched. This event has the share data as the payload, bubbles and is | ||
cancelable. | ||
When the share button is clicked a [custom event][custom-event] with the | ||
name `share` is dispatched. This event has the share data as the payload, | ||
bubbles and is cancelable. | ||
|
||
```js | ||
// Example metric capture | ||
|
@@ -143,9 +142,10 @@ document.addEventListener('share', (ev) => { | |
|
||
## Fallback content | ||
|
||
Fallback content can be provided if for some reason the native share | ||
function isn't available or the scripts aren't loaded. Please see this | ||
[blog post][blog-post] for thorough explanation of using fallback content. | ||
Fallback content can be provided for situations where the native share | ||
function isn't available or the component script isn't loaded. Please see | ||
this [blog post][blog-post] for thorough explanation of using fallback | ||
content. | ||
|
||
```html | ||
<share-button> | ||
|
@@ -164,5 +164,6 @@ function isn't available or the scripts aren't loaded. Please see this | |
|
||
[share]: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share | ||
[open-graph]: https://ogp.me/ | ||
[custom-event]: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent | ||
[dist]: https://cdn.jsdelivr.net/npm/@parsonic/[email protected]/dist/ | ||
[blog-post]: https://philparsons.co.uk/blog/dont-fouc-up-your-web-components/ |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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