@salla.sa/twilight 2.9.8 → 2.9.10

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/README.md CHANGED
@@ -33,10 +33,7 @@
33
33
  <li><a href="#sdks-main-apis">SDK's main APIs</a></li>
34
34
  <li><a href="#use-cases">Use cases</a></li>
35
35
  </ul>
36
- <li><a href="#installation">Installation</a></li>
37
- <ul>
38
- <li><a href="#initialization">Initialization</a></li>
39
- </ul>
36
+ <li><a href="#installation-and-initialization">Installation and initialization</a></li>
40
37
  <li><a href="#usage">Usage</a></li>
41
38
  <ul>
42
39
  <li><a href="#basic-configuration">Basic configuration </a></li>
@@ -80,8 +77,38 @@ Following are some of the possible uses of the Twilight JS SDK:
80
77
 
81
78
  <p align="right">(<a href="#top">back to top</a>)</p>
82
79
 
83
- ## Installation
84
- **Twilight JS SDK** can be installed from the `npm` using the following commands:
80
+ ## Installation and initialization
81
+ **Twilight JS SDK** can be used without the need to be downloaded or installed; instead it needs to be included as a short piece of regular JavaScript in the HTML that will asynchronously load the SDK into the Twilight theme. 
82
+
83
+ #### Twilight Themes
84
+ In case of using the **Twilight JS SDK** inside the Twilight themes, the developer doesn't need to include the **Twilight JS SDK** in the theme project's bundle or inside the html, **Twilight theme engine** will inject the latest version of the **Twilight JS SDK** in the page.
85
+
86
+ Basically, the developer does not need to call the method `salla.init()` for twilight themes, because it will be called automatically upon the installation of the Twilight theme engine. This is done thanks to the [body:end hook](https://salla.stoplight.io/studio/twilight-themes-documentation?#bodyend-hook) `{% hook 'body:end' %}`.
87
+
88
+ #### HTML and CDN
89
+ The most common approach for setting up the **Twilight JS SDK** is load it via `<script>` befor closing the `body` tag of the HTML document.
90
+
91
+ ```html title="Code Snippet"
92
+ <script src="https://cdn.jsdelivr.net/npm/@salla.sa/twilight@latest/dist/@salla.sa/twilight.min.js"></script>
93
+ ```
94
+
95
+ The following snippet of code will give the basic version of the SDK where the configurations are set to their minimum requirements, for example, store URL. The method `salla.init()` is used to setup and initialize the SDK. 
96
+
97
+ ```js
98
+ <script>
99
+ salla.init({
100
+ debug: true, // disbale it in prod
101
+ language_code: 'ar', // en
102
+ store: {
103
+ id: 1305146709, // The store id can found via store pages.
104
+ url: "https://the-best-store-ever.sa"
105
+ }
106
+ });
107
+ </script>
108
+ ```
109
+
110
+ #### Bundler/ES modules
111
+ Developer may also install the **Twilight JS SDK** using the following commands:
85
112
 
86
113
  ```npm title="NPM Installation Command"
87
114
  npm install @salla.sa/twilight --save
@@ -91,22 +118,27 @@ npm install @salla.sa/twilight --save
91
118
  yarn add @salla.sa/twilight
92
119
  ```
93
120
 
94
- ### Initialization
121
+ Initially, the developer must import the Salla JS Events library as follows:
95
122
 
96
- The following snippet of code will give the basic version of the SDK where the configurations are set to their minimum requirements, for example, store URL. The method `salla.init()` is used to setup and initialize the SDK.
123
+
124
+ ```js
125
+ import '@salla.sa/twilight';
126
+ ```
127
+
128
+ The following snippet of code will give the basic version of the SDK where the configurations are set to their minimum requirements, for example, store URL. The method `salla.init()` is used to setup and initialize the SDK. 
97
129
 
98
130
  ```js
99
131
  <script>
100
132
  salla.init({
101
- debug: true,
133
+ debug: true, // disbale it in prod
134
+ language_code: 'ar', // en
102
135
  store: {
103
- id: 693312468,
104
- url: "https://my_store.test/"
136
+ id: 1305146709, // The store id can found via store pages.
137
+ url: "https://the-best-store-ever.sa"
105
138
  }
106
- });
139
+ });
107
140
  </script>
108
141
  ```
109
- <p align="right">(<a href="#top">back to top</a>)</p>
110
142
 
111
143
  ## Usage
112
144