@aw-webflow/pricing_page_js 1.0.0 → 1.1.0

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.
@@ -16,7 +16,11 @@
16
16
  "Bash(git commit -q -m ' *)",
17
17
  "Bash(git push *)",
18
18
  "Bash(git tag *)",
19
- "Bash(gh release create v1.0.0 --title v1.0.0 --notes ' *)"
19
+ "Bash(gh release create v1.0.0 --title v1.0.0 --notes ' *)",
20
+ "Bash(curl -sL \"https://atomicwork.webflow.io/pricing-new?cb=$\\(date +%s\\)\" -o live.html)",
21
+ "Bash(curl -sL \"https://cdn.prod.website-files.com/64f08da4e7effe6dcb06d456/css/atomicwork.6a195ea2d503d973ad3d9f0b.6d732586d.opt.min.css\" -o page.css)",
22
+ "Bash(gh release create v1.0.1 --title v1.0.1 --notes ' *)",
23
+ "Bash(gh release create v1.1.0 --title v1.1.0 --notes ' *)"
20
24
  ]
21
25
  }
22
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aw-webflow/pricing_page_js",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "start": "parcel script.js",
package/script.js CHANGED
@@ -37,8 +37,10 @@
37
37
  '.table-section-header{cursor:pointer;}' +
38
38
  ICON_SELECTOR + '{transition:transform .35s ease;}' +
39
39
  '.table-section-header.is-open ' + ICON_SELECTOR + '{transform:rotate(180deg);}' +
40
- // transition added after first paint to avoid a load flash
41
- '.' + SLIDE_CLASS + '{transition:height .35s ease;overflow:hidden;}';
40
+ // transition added after first paint to avoid a load flash.
41
+ // NOTE: only clip the vertical axis so the table can still scroll
42
+ // horizontally on mobile (overflow-x is left to Webflow's own CSS).
43
+ '.' + SLIDE_CLASS + '{transition:height .35s ease;overflow-y:hidden;}';
42
44
  var style = document.createElement('style');
43
45
  style.id = 'aw-accordion-styles';
44
46
  style.type = 'text/css';
@@ -118,8 +120,9 @@
118
120
  if (!header.getAttribute('role')) header.setAttribute('role', 'button');
119
121
  if (!header.hasAttribute('tabindex')) header.setAttribute('tabindex', '0');
120
122
 
121
- // initial state WITHOUT animation (slide class added after first paint)
122
- instance.style.overflow = 'hidden';
123
+ // initial state WITHOUT animation (slide class added after first paint).
124
+ // Only clip vertically so horizontal scroll (mobile) keeps working.
125
+ instance.style.overflowY = 'hidden';
123
126
  if (startOpen) {
124
127
  instance.setAttribute('data-aw-open', '1');
125
128
  header.setAttribute('aria-expanded', 'true');
@@ -216,3 +219,185 @@
216
219
  bootstrap();
217
220
  }
218
221
  })();
222
+
223
+ /* Tooltips
224
+ *
225
+ * Markup built in Webflow (positioning + styling are Webflow's job):
226
+ *
227
+ * .tooltip-wrap (position: relative)
228
+ * .tooltip-trigger (the hover/tap target)
229
+ * .tooltip-content (the bubble, hidden by default)
230
+ *
231
+ * This script only toggles classes:
232
+ * - .tooltip-content gets `is-visible`
233
+ * - .tooltip-wrap gets `is-open`
234
+ * Style the visible state in Webflow off either of those.
235
+ *
236
+ * Behaviour: hover on devices that support it; tap-to-toggle on touch
237
+ * devices (with outside-tap + Escape to close). Keyboard focus also opens.
238
+ * Auto-wires every .tooltip-wrap on the page, including ones injected later
239
+ * (e.g. Finsweet table rows).
240
+ *
241
+ * ES5 only (var / no arrow functions) for browser compatibility.
242
+ */
243
+ (function () {
244
+ 'use strict';
245
+
246
+ var WRAP_SELECTOR = '.tooltip-wrap';
247
+ var TRIGGER_SELECTOR = '.tooltip-trigger';
248
+ var CONTENT_SELECTOR = '.tooltip-content';
249
+ var VISIBLE_CLASS = 'is-visible';
250
+ var OPEN_CLASS = 'is-open';
251
+ var INIT_FLAG = 'awTooltipBound';
252
+
253
+ // Hover devices use mouseenter/leave; touch devices use tap-to-toggle.
254
+ var hoverCapable = !(
255
+ window.matchMedia && window.matchMedia('(hover: none)').matches
256
+ );
257
+
258
+ var uid = 0;
259
+
260
+ function matches(el, selector) {
261
+ if (!el || el.nodeType !== 1) return false;
262
+ var fn =
263
+ el.matches ||
264
+ el.webkitMatchesSelector ||
265
+ el.msMatchesSelector ||
266
+ el.mozMatchesSelector;
267
+ return fn ? fn.call(el, selector) : false;
268
+ }
269
+
270
+ function closest(el, selector) {
271
+ while (el && el.nodeType === 1) {
272
+ if (matches(el, selector)) return el;
273
+ el = el.parentNode;
274
+ }
275
+ return null;
276
+ }
277
+
278
+ function addClass(el, cls) {
279
+ if (el && el.className.indexOf(cls) === -1) el.className += ' ' + cls;
280
+ }
281
+
282
+ function removeClass(el, cls) {
283
+ if (el) {
284
+ el.className = el.className.replace(
285
+ new RegExp('\\s*\\b' + cls + '\\b', 'g'),
286
+ ''
287
+ );
288
+ }
289
+ }
290
+
291
+ function hide(wrap) {
292
+ if (!wrap) return;
293
+ removeClass(wrap.querySelector(CONTENT_SELECTOR), VISIBLE_CLASS);
294
+ removeClass(wrap, OPEN_CLASS);
295
+ var trigger = wrap.querySelector(TRIGGER_SELECTOR);
296
+ if (trigger) trigger.setAttribute('aria-expanded', 'false');
297
+ }
298
+
299
+ function hideAll(except) {
300
+ var open = document.querySelectorAll(WRAP_SELECTOR + '.' + OPEN_CLASS);
301
+ for (var i = 0; i < open.length; i++) {
302
+ if (open[i] !== except) hide(open[i]);
303
+ }
304
+ }
305
+
306
+ function show(wrap) {
307
+ hideAll(wrap); // one at a time
308
+ addClass(wrap.querySelector(CONTENT_SELECTOR), VISIBLE_CLASS);
309
+ addClass(wrap, OPEN_CLASS);
310
+ var trigger = wrap.querySelector(TRIGGER_SELECTOR);
311
+ if (trigger) trigger.setAttribute('aria-expanded', 'true');
312
+ }
313
+
314
+ function toggle(wrap) {
315
+ if (wrap.className.indexOf(OPEN_CLASS) === -1) show(wrap);
316
+ else hide(wrap);
317
+ }
318
+
319
+ function bind(wrap) {
320
+ if (wrap[INIT_FLAG]) return;
321
+ var trigger = wrap.querySelector(TRIGGER_SELECTOR);
322
+ var content = wrap.querySelector(CONTENT_SELECTOR);
323
+ if (!trigger || !content) return; // incomplete markup, skip for now
324
+
325
+ wrap[INIT_FLAG] = true;
326
+
327
+ // accessibility wiring
328
+ if (!content.id) content.id = 'aw-tip-' + ++uid;
329
+ content.setAttribute('role', 'tooltip');
330
+ trigger.setAttribute('aria-describedby', content.id);
331
+ trigger.setAttribute('aria-expanded', 'false');
332
+ var tag = trigger.tagName;
333
+ if (!trigger.hasAttribute('tabindex') && tag !== 'BUTTON' && tag !== 'A') {
334
+ trigger.setAttribute('tabindex', '0');
335
+ }
336
+
337
+ if (hoverCapable) {
338
+ wrap.addEventListener('mouseenter', function () {
339
+ show(wrap);
340
+ });
341
+ wrap.addEventListener('mouseleave', function () {
342
+ hide(wrap);
343
+ });
344
+ } else {
345
+ trigger.addEventListener('click', function (e) {
346
+ e.stopPropagation(); // don't trip the outside-tap handler below
347
+ toggle(wrap);
348
+ });
349
+ }
350
+
351
+ // keyboard focus opens; closing handled when focus leaves the wrap
352
+ wrap.addEventListener('focusin', function () {
353
+ show(wrap);
354
+ });
355
+ wrap.addEventListener('focusout', function (e) {
356
+ var to = e.relatedTarget;
357
+ if (!to || !wrap.contains(to)) hide(wrap);
358
+ });
359
+ }
360
+
361
+ function scan(root) {
362
+ var wraps = (root || document).querySelectorAll(WRAP_SELECTOR);
363
+ for (var i = 0; i < wraps.length; i++) bind(wraps[i]);
364
+ }
365
+
366
+ function init() {
367
+ scan(document);
368
+
369
+ // outside tap closes (tap mode only — hover mode closes on mouseleave)
370
+ document.addEventListener('click', function (e) {
371
+ if (hoverCapable) return;
372
+ if (!closest(e.target, WRAP_SELECTOR)) hideAll(null);
373
+ });
374
+
375
+ // Escape closes any open tooltip
376
+ document.addEventListener('keydown', function (e) {
377
+ var key = e.key || e.keyCode;
378
+ if (key === 'Escape' || key === 'Esc' || key === 27) hideAll(null);
379
+ });
380
+
381
+ // wire up tooltips injected after load (e.g. Finsweet table rows)
382
+ if (window.MutationObserver) {
383
+ var observer = new MutationObserver(function (mutations) {
384
+ for (var i = 0; i < mutations.length; i++) {
385
+ var added = mutations[i].addedNodes;
386
+ for (var j = 0; j < added.length; j++) {
387
+ var node = added[j];
388
+ if (!node || node.nodeType !== 1) continue;
389
+ if (matches(node, WRAP_SELECTOR)) bind(node);
390
+ if (node.querySelectorAll) scan(node);
391
+ }
392
+ }
393
+ });
394
+ observer.observe(document.body, { childList: true, subtree: true });
395
+ }
396
+ }
397
+
398
+ if (document.readyState === 'loading') {
399
+ document.addEventListener('DOMContentLoaded', init);
400
+ } else {
401
+ init();
402
+ }
403
+ })();