Merge branch 'non-default-export'

https://codeberg.org/kytta/shareon/pulls/10
pull/45/head
Nikita Karamov 2022-02-10 23:06:56 +01:00
commit bdda39b8ef
No known key found for this signature in database
GPG Key ID: 3C8E688C96EEB9C9
4 changed files with 10 additions and 7 deletions

View File

@ -22,6 +22,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Changed ### Changed
- **BREAKING:** default version of the package doesn't auto-initialize buttons - **BREAKING:** default version of the package doesn't auto-initialize buttons
- **BREAKING:** instead of default export, named exports are now used. If IIFE
is used, the global object's name is now `Shareon`, and it has one `init()`
method
- remove mixins, defining the code/styles directly in the files - remove mixins, defining the code/styles directly in the files
- use [Vite](https://vitejs.dev/) for building, reducing the devDependencies - use [Vite](https://vitejs.dev/) for building, reducing the devDependencies
tree and build times drastically tree and build times drastically

View File

@ -109,8 +109,8 @@
</main> </main>
<script type="module"> <script type="module">
import initializeShareon from "./src/shareon.js"; import { init } from "./src/shareon.js";
initializeShareon(); init();
</script> </script>
</body> </body>
</html> </html>

View File

@ -1,9 +1,9 @@
import initializeShareon from "./shareon"; import { init } from "./shareon";
// TODO: update README // TODO: update README
const s = document.currentScript; const s = document.currentScript;
if (s && s.hasAttribute("init")) { if (s && s.hasAttribute("init")) {
initializeShareon(); init();
} }
export { default } from "./shareon"; export { init } from "./shareon";

View File

@ -34,7 +34,7 @@ const openUrl = (buttonUrl) => () => {
window.open(buttonUrl, "_blank", "noopener,noreferrer"); window.open(buttonUrl, "_blank", "noopener,noreferrer");
}; };
const initializeShareon = () => { const init = () => {
const shareonContainers = document.querySelectorAll(".shareon"); const shareonContainers = document.querySelectorAll(".shareon");
// iterate over <div class="shareon"> // iterate over <div class="shareon">
@ -90,4 +90,4 @@ const initializeShareon = () => {
} }
}; };
export default initializeShareon; export { init };