@ulu/frontend 0.1.0-beta.40 → 0.1.0-beta.42

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.
@@ -5190,7 +5190,7 @@
5190
5190
  <li><a href="#utils%2Fdom.resolveclasses(input)-%E2%87%92-array.%3Cstring%3E">utils/dom.resolveClasses(input) ⇒ Array.<string></string></a>
5191
5191
  </li>
5192
5192
 
5193
- <li><a href="#utils%2Fdom.addscrollbarproperty(%5Belement%5D%2C-%5Bcontainer%5D%2C-propname)">utils/dom.addScrollbarProperty([element], [container], propName)</a>
5193
+ <li><a href="#utils%2Fdom.addscrollbarproperty(options)">utils/dom.addScrollbarProperty(options)</a>
5194
5194
  </li>
5195
5195
 
5196
5196
  <li><a href="#utils%2Fdom.getscrollbarwidth(%5Belement%5D%2C-%5Bcontainer%5D)-%E2%87%92-number">utils/dom.getScrollbarWidth([element], [container]) ⇒ number</a>
@@ -5219,7 +5219,7 @@
5219
5219
  <li><a href="#module_utils/dom.getElement">.getElement(target, context)</a> ⇒ <code>HTMLElement</code></li>
5220
5220
  <li><a href="#module_utils/dom.getElements">.getElements(target, context)</a> ⇒ <code>Array</code></li>
5221
5221
  <li><a href="#module_utils/dom.resolveClasses">.resolveClasses(input)</a> ⇒ <code>Array.&lt;string&gt;</code></li>
5222
- <li><a href="#module_utils/dom.addScrollbarProperty">.addScrollbarProperty([element], [container], propName)</a></li>
5222
+ <li><a href="#module_utils/dom.addScrollbarProperty">.addScrollbarProperty(options)</a></li>
5223
5223
  <li><a href="#module_utils/dom.getScrollbarWidth">.getScrollbarWidth([element], [container])</a> ⇒ <code>number</code></li>
5224
5224
  </ul>
5225
5225
  </li>
@@ -5414,8 +5414,8 @@ or new instances are added to the screen</p>
5414
5414
  <span class="pjs-token pjs-function">resolveClassArray</span><span class="pjs-token pjs-punctuation">(</span><span class="pjs-token pjs-punctuation">[</span><span class="pjs-token pjs-string">"another-class"</span><span class="pjs-token pjs-punctuation">,</span> <span class="pjs-token pjs-string">"yet-another-class"</span><span class="pjs-token pjs-punctuation">]</span><span class="pjs-token pjs-punctuation">)</span><span class="pjs-token pjs-punctuation">;</span> <span class="pjs-token pjs-comment">// Returns ["another-class", "yet-another-class"]</span>
5415
5415
  <span class="pjs-token pjs-function">resolveClassArray</span><span class="pjs-token pjs-punctuation">(</span><span class="pjs-token pjs-string">"single-class"</span><span class="pjs-token pjs-punctuation">)</span><span class="pjs-token pjs-punctuation">;</span> <span class="pjs-token pjs-comment">// Returns ["single-class"]</span></code></pre>
5416
5416
  <p><a name="module_utils/dom.addScrollbarProperty"></a></p>
5417
- <h2 id="utils%2Fdom.addscrollbarproperty(%5Belement%5D%2C-%5Bcontainer%5D%2C-propname)" tabindex="-1">utils/dom.addScrollbarProperty([element], [container], propName)</h2>
5418
- <p>Sets a CSS custom property equal to the scrollbar width</p>
5417
+ <h2 id="utils%2Fdom.addscrollbarproperty(options)" tabindex="-1">utils/dom.addScrollbarProperty(options)</h2>
5418
+ <p>Sets a CSS custom property equal to the scrollbar width.</p>
5419
5419
  <p><strong>Kind</strong>: static method of <a href="#module_utils/dom"><code>utils/dom</code></a></p>
5420
5420
  <table>
5421
5421
  <thead>
@@ -5428,22 +5428,34 @@ or new instances are added to the screen</p>
5428
5428
  </thead>
5429
5429
  <tbody>
5430
5430
  <tr>
5431
- <td>[element]</td>
5431
+ <td>options</td>
5432
+ <td><code>object</code></td>
5433
+ <td></td>
5434
+ <td>Configuration options.</td>
5435
+ </tr>
5436
+ <tr>
5437
+ <td>[options.scrollableChild]</td>
5432
5438
  <td><code>HTMLElement</code></td>
5433
5439
  <td><code>document.body</code></td>
5434
- <td>The element that is the child of a scrollable container</td>
5440
+ <td>An element that is a child of a scrollable container (used for width calculation).</td>
5435
5441
  </tr>
5436
5442
  <tr>
5437
- <td>[container]</td>
5443
+ <td>[options.container]</td>
5438
5444
  <td><code>Window</code> | <code>HTMLElement</code></td>
5439
5445
  <td><code>window</code></td>
5440
- <td>The container that can be scrolled</td>
5446
+ <td>The container that can be scrolled (used for width calculation).</td>
5441
5447
  </tr>
5442
5448
  <tr>
5443
- <td>propName</td>
5444
- <td><code>Stirng</code></td>
5445
- <td></td>
5446
- <td>Custom property to set</td>
5449
+ <td>[options.propertyElement]</td>
5450
+ <td><code>HTMLElement</code></td>
5451
+ <td><code>document.documentElement</code></td>
5452
+ <td>The element to which the custom property will be added. Defaults to document.documentElement for :root access.</td>
5453
+ </tr>
5454
+ <tr>
5455
+ <td>[options.propName]</td>
5456
+ <td><code>string</code></td>
5457
+ <td><code>&quot;&amp;quot;--ulu-scrollbar-width&amp;quot;&quot;</code></td>
5458
+ <td>The name of the custom property to set.</td>
5447
5459
  </tr>
5448
5460
  </tbody>
5449
5461
  </table>
package/js/utils/dom.js CHANGED
@@ -165,14 +165,26 @@ export function resolveClasses(classes) {
165
165
  }
166
166
 
167
167
  /**
168
- * Sets a CSS custom property equal to the scrollbar width
169
- * @param {HTMLElement} [element=document.body] -The element that is the child of a scrollable container
170
- * @param {Window|HTMLElement} [container=window] - The container that can be scrolled
171
- * @param {Stirng} propName Custom property to set
168
+ * Sets a CSS custom property equal to the scrollbar width.
169
+ * @param {object} options - Configuration options.
170
+ * @param {HTMLElement} [options.scrollableChild=document.body] - An element that is a child of a scrollable container (used for width calculation).
171
+ * @param {Window|HTMLElement} [options.container=window] - The container that can be scrolled (used for width calculation).
172
+ * @param {HTMLElement} [options.propertyElement=document.documentElement] - The element to which the custom property will be added. Defaults to document.documentElement for :root access.
173
+ * @param {string} [options.propName="--ulu-scrollbar-width"] - The name of the custom property to set.
172
174
  */
173
- export function addScrollbarProperty(element = document.body, container = window, propName = "--ulu-scrollbar-width") {
174
- const scrollbarWidth = getScrollbarWidth(element, container);
175
- element.style.setProperty(propName, `${ scrollbarWidth }px`);
175
+ export function addScrollbarProperty(options) {
176
+ const defaults = {
177
+ scrollableChild: document.body,
178
+ container: window,
179
+ propertyElement: document.documentElement,
180
+ propName: "--ulu-scrollbar-width",
181
+ };
182
+
183
+ const config = { ...defaults, ...options };
184
+ const { scrollableChild, container, propertyElement, propName } = config;
185
+
186
+ const scrollbarWidth = getScrollbarWidth(scrollableChild, container);
187
+ propertyElement.style.setProperty(propName, `${ scrollbarWidth }px`);
176
188
  }
177
189
 
178
190
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ulu/frontend",
3
- "version": "0.1.0-beta.40",
3
+ "version": "0.1.0-beta.42",
4
4
  "description": "Modular Sass Theming Library",
5
5
  "browser": "js/index.js",
6
6
  "main": "index.js",
@@ -125,8 +125,8 @@ $config: (
125
125
  // new below
126
126
  "toggle-aside-rule" : true,
127
127
  "aside-rule-width" : 6px,
128
- "aside-background-color" : rgb(197, 197, 197),
129
- "aside-rule-color": green,
128
+ "aside-background-color" : transparent,
129
+ "aside-rule-color": "rule",
130
130
 
131
131
  ) !default;
132
132
 
@@ -59,12 +59,19 @@ export function getElements(target: string | Node, context?: any): any[];
59
59
  */
60
60
  export function resolveClasses(classes: any): string[];
61
61
  /**
62
- * Sets a CSS custom property equal to the scrollbar width
63
- * @param {HTMLElement} [element=document.body] -The element that is the child of a scrollable container
64
- * @param {Window|HTMLElement} [container=window] - The container that can be scrolled
65
- * @param {Stirng} propName Custom property to set
62
+ * Sets a CSS custom property equal to the scrollbar width.
63
+ * @param {object} options - Configuration options.
64
+ * @param {HTMLElement} [options.scrollableChild=document.body] - An element that is a child of a scrollable container (used for width calculation).
65
+ * @param {Window|HTMLElement} [options.container=window] - The container that can be scrolled (used for width calculation).
66
+ * @param {HTMLElement} [options.propertyElement=document.documentElement] - The element to which the custom property will be added. Defaults to document.documentElement for :root access.
67
+ * @param {string} [options.propName="--ulu-scrollbar-width"] - The name of the custom property to set.
66
68
  */
67
- export function addScrollbarProperty(element?: HTMLElement, container?: Window | HTMLElement, propName?: Stirng): void;
69
+ export function addScrollbarProperty(options: {
70
+ scrollableChild?: HTMLElement;
71
+ container?: Window | HTMLElement;
72
+ propertyElement?: HTMLElement;
73
+ propName?: string;
74
+ }): void;
68
75
  /**
69
76
  * Calculates the width of the scrollbar.
70
77
  *
@@ -1 +1 @@
1
- {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../js/utils/dom.js"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,2DAFa,MAAM,CAOlB;AAED;;;;;GAKG;AACH,wCAJW,IAAI,oBAYd;AAED;;;;;;GAMG;AACH,gDAJW,IAAI,gBAEF,YAAa,CASzB;AAED;;GAEG;AACH,mEAMC;AAGD;;;;;;;;;GASG;AACH,2CAHa,IAAI,uBAoChB;AAED;;;;;GAKG;AACH,mCAJW,SAAO,IAAI,kBAEV,WAAW,CAWtB;AAED;;;;;GAKG;AACH,oCAJW,SAAO,IAAI,wBAerB;AAED;;;;;;;;GAQG;AACH,8CANa,MAAM,EAAE,CAiBpB;AAED;;;;;GAKG;AACH,+CAJW,WAAW,cACX,MAAM,GAAC,WAAW,2BAM5B;AAED;;;;;;GAMG;AACH,4CAJW,WAAW,cACX,MAAM,GAAC,WAAW,GAChB,MAAM,CAIlB;AA1LD;;GAEG;AAGH,qCAAqD"}
1
+ {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../js/utils/dom.js"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,2DAFa,MAAM,CAOlB;AAED;;;;;GAKG;AACH,wCAJW,IAAI,oBAYd;AAED;;;;;;GAMG;AACH,gDAJW,IAAI,gBAEF,YAAa,CASzB;AAED;;GAEG;AACH,mEAMC;AAGD;;;;;;;;;GASG;AACH,2CAHa,IAAI,uBAoChB;AAED;;;;;GAKG;AACH,mCAJW,SAAO,IAAI,kBAEV,WAAW,CAWtB;AAED;;;;;GAKG;AACH,oCAJW,SAAO,IAAI,wBAerB;AAED;;;;;;;;GAQG;AACH,8CANa,MAAM,EAAE,CAiBpB;AAED;;;;;;;GAOG;AACH;IALiC,eAAe,GAArC,WAAW;IACkB,SAAS,GAAtC,MAAM,GAAC,WAAW;IACI,eAAe,GAArC,WAAW;IACM,QAAQ,GAAzB,MAAM;SAehB;AAED;;;;;;GAMG;AACH,4CAJW,WAAW,cACX,MAAM,GAAC,WAAW,GAChB,MAAM,CAIlB;AAtMD;;GAEG;AAGH,qCAAqD"}