Skip to content

Commit fdbea0e

Browse files
authored
Merge pull request #4 from jekuer/dev
npm optimization
2 parents 7c68ac1 + a871ab4 commit fdbea0e

File tree

11 files changed

+524
-29
lines changed

11 files changed

+524
-29
lines changed

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# PLUS what else should not be on npm
1414

1515
.github/
16+
assets/js/
1617
*.png
1718
*.ico
19+
*.gif
1820
index.html

README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,36 +44,38 @@ See [jekuer.github.io/add-to-calendar-button](https://jekuer.github.io/add-to-ca
4444
* Translatable labels and dynamic.
4545
* Well documented code, to easily understand the processes.
4646

47-
![Screenshot](https://github.com/jekuer/add-to-calendar-button/blob/main/screenshot.png?raw=true)
47+
![Demo Screenshot](https://github.com/jekuer/add-to-calendar-button/blob/main/demo.gif?raw=true)
4848

4949

5050
## Setup
5151

5252
### Option 1: Simple
5353

5454
1. Simply **download** the code from GitHub **or clone** the git repository.
55-
2. Copy the css (atcb.min.css) and js (atcb.min.js) files from the assets folders into your project (the **.min.** files are required, but it is recommended to also copy the raw and map files).
56-
3. Include those files in your project. As usual, the css goes into the <head> (`<link rel="stylesheet" href="./assets/css/atcb.min.css">`), the js into the <body> footer (`<script type="module" src="./assets/js/atcb.min.js"></script>`). You can also combine them with other files, if you want to.
57-
4. Mind that when using this in a Vanilla JS style, you need to either include `type="module"` within the script tag **or** remove the last line from the js file (*module.exports*), since this is only relevant for Option 2 and throws a console error otherwise.
58-
5. Create your button as can be seen in the "Configuration" section below.
59-
6. That is it. The script takes care of all the rest. :)
55+
2. Copy the css (atcb.min.css) and js (atcb.min.js) files from the assets (not the "npm_dist"!) folders into your project (the **.min.** files are required, but it is recommended to also copy the raw and map files).
56+
3. Include those files in your project. As usual, the css goes into the <head> (`<link rel="stylesheet" href="./assets/css/atcb.min.css">`), the js into the <body> footer (`<script src="./assets/js/atcb.min.js" defer></script>`). You can also combine them with other files, if you want to.
57+
4. Create your button as can be seen in the "Configuration" section below.
58+
5. That is it. The script takes care of all the rest. :)
6059

6160
### Option 2: NodeJS
6261

6362
1. Requires NodeJS and a project, which builds on it (e.g. React or Angular).
6463
2. Rund **`npm install add-to-calendar-button`**.
6564
3. Import the module into your project/component. For example with Angular/React: `import { atcb_init } from 'add-to-calendar-button';`.
66-
4. Init the js with `atcb_init();`.
65+
4. Init the js after the DOM has been loaded. To determine the right moment and execute, ...
66+
1. with Angular, you would use `ngAfterViewInit()` with `atcb_init();`;
67+
2. with React, you might want to include an event listener like `document.addEventListener('DOMContentLoaded', atcb_init, false);`.
6768
5. Include the css. For example with Angular or React, add the following to the global style.css: `@import 'add-to-calendar-button/assets/css/atcb.min'`;
6869
6. Create your button as can be seen in the "Configuration" section below.
6970
7. That is it. The script takes care of all the rest. :)
7071

7172

7273
## Configuration
7374

74-
A button can be easily created by placing a respective placeholder, wherever you want the button to appear.
75+
A button can be easily created by placing a respective placeholder, wherever you want the button to appear.
76+
(The `style="display:none;"` theoretically is not necessary, but should be used for better compatibility.)
7577
```html
76-
<div class="atcb">
78+
<div class="atcb" style="display:none;">
7779
(...)
7880
</div>
7981
```
@@ -83,7 +85,7 @@ Mind that with Angular, you might need to escape the { with `{{ '{' }}` and } wi
8385
### Minimal structure (required)
8486

8587
```html
86-
<div class="atcb">
88+
<div class="atcb" style="display:none;">
8789
{
8890
"title":"Add the title of your event",
8991
"dateStart":"02-21-2022",
@@ -98,7 +100,7 @@ Mind that with Angular, you might need to escape the { with `{{ '{' }}` and } wi
98100
### Full structure
99101

100102
```html
101-
<div class="atcb">
103+
<div class="atcb" style="display:none;">
102104
{
103105
"label":"Add to Calendar",
104106
"title":"Add the title of your event",

assets/css/atcb.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Add-to-Calendar Button
44
* ++++++++++++++++++++++
55
*
6-
* Version: 1.1.4
6+
* Version: 1.1.5
77
* Creator: Jens Kuerschner (https://jenskuerschner.de)
88
* Project: https://github.com/jekuer/add-to-calendar-button
99
* License: GNU General Public License v3.0 (gpl-3.0)

assets/js/atcb.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Add-to-Calendar Button
44
* ++++++++++++++++++++++
55
*/
6-
const atcbVersion = '1.1.4';
6+
const atcbVersion = '1.1.5';
77
/* Creator: Jens Kuerschner (https://jenskuerschner.de)
88
* Project: https://github.com/jekuer/add-to-calendar-button
99
* License: GNU General Public License v3.0 (gpl-3.0)
@@ -494,8 +494,3 @@ function atcb_generate_time(data, style = 'delimiters', targetCal = 'general') {
494494

495495
// START THE MAGIC AS SOON AS THE DOM HAS BEEN LOADED
496496
document.addEventListener('DOMContentLoaded', atcb_init, false);
497-
498-
499-
500-
// EXPORT FOR USE IN NODEJS
501-
export { atcb_init };

assets/js/atcb.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/atcb.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo.gif

760 KB
Loading

index.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ <h3>Example 1: The usual One</h3>
140140
<div class="example_left">
141141

142142
<!-- start of button code -->
143-
<div class="atcb">
143+
<div class="atcb" style="display:none;">
144144
{
145145
"title":"Reminder to check the add-to-calendar-button repo",
146146
"description":"Check out the maybe easiest way to include add-to-calendar-buttons to your website at: https://github.com/jekuer/add-to-calendar-button",
@@ -197,7 +197,7 @@ <h3>Example 2: Going All-Day</h3>
197197
<div class="example_left">
198198

199199
<!-- start of button code -->
200-
<div class="atcb">
200+
<div class="atcb" style="display:none;">
201201
{
202202
"title":"Reminder to check the add-to-calendar-button repo",
203203
"description":"Check out the maybe easiest way to include add-to-calendar-buttons to your website at: https://github.com/jekuer/add-to-calendar-button",
@@ -251,7 +251,7 @@ <h3>Example 3: Customizing Labels</h3>
251251
<div class="example_left">
252252

253253
<!-- start of button code -->
254-
<div class="atcb">
254+
<div class="atcb" style="display:none;">
255255
{
256256
"label":"Click me to remember!",
257257
"title":"Reminder to check the add-to-calendar-button repo",
@@ -299,7 +299,7 @@ <h3>Example 4: Dynamic Dates</h3>
299299
<div class="example_left">
300300

301301
<!-- start of button code -->
302-
<div class="atcb">
302+
<div class="atcb" style="display:none;">
303303
{
304304
"title":"Reminder to check the add-to-calendar-button repo",
305305
"description":"Check out the maybe easiest way to include add-to-calendar-buttons to your website at: https://github.com/jekuer/add-to-calendar-button",
@@ -345,7 +345,7 @@ <h3>Example 5: Click Trigger</h3>
345345
<div class="example_left">
346346

347347
<!-- start of button code -->
348-
<div class="atcb">
348+
<div class="atcb" style="display:none;">
349349
{
350350
"title":"Reminder to check the add-to-calendar-button repo",
351351
"description":"Check out the maybe easiest way to include add-to-calendar-buttons to your website at: https://github.com/jekuer/add-to-calendar-button",
@@ -394,7 +394,7 @@ <h3>Example 6: Timezone Offset</h3>
394394
<div class="example_left">
395395

396396
<!-- start of button code -->
397-
<div class="atcb">
397+
<div class="atcb" style="display:none;">
398398
{
399399
"title":"Reminder to check the add-to-calendar-button repo",
400400
"description":"Check out the maybe easiest way to include add-to-calendar-buttons to your website at: https://github.com/jekuer/add-to-calendar-button",
@@ -444,7 +444,7 @@ <h3>Example 6: Timezone Offset</h3>
444444

445445

446446
<!-- load the button js -->
447-
<script type="module" src="./assets/js/atcb.min.js"></script>
447+
<script src="./assets/js/atcb.min.js" defer></script>
448448

449449

450450
</body>

0 commit comments

Comments
 (0)