@pumpkin-tech/pumpkin-tech-ng 0.2.10 → 0.2.11

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.
@@ -131,16 +131,22 @@ class PtechGridDirective {
131
131
  this.columns = `repeat(${cols}, minmax(0, 1fr))`;
132
132
  }
133
133
  resolveColsForBp() {
134
- const map = {
135
- xs: this.asNum(this.ptechColsXs),
136
- sm: this.asNum(this.ptechColsSm),
137
- md: this.asNum(this.ptechColsMd),
138
- lg: this.asNum(this.ptechColsLg),
139
- xl: this.asNum(this.ptechColsXl),
140
- };
134
+ const xs = this.asNum(this.ptechColsXs);
135
+ const sm = this.asNum(this.ptechColsSm);
136
+ const md = this.asNum(this.ptechColsMd);
137
+ const lg = this.asNum(this.ptechColsLg);
138
+ const xl = this.asNum(this.ptechColsXl);
141
139
  const bp = this.activeBp;
142
- const span = bp ? map[bp] : undefined;
143
- return span ?? this._cols ?? 12;
140
+ if (!bp)
141
+ return this._cols ?? 12;
142
+ switch (bp) {
143
+ case 'xl': return xl ?? lg ?? md ?? sm ?? xs ?? this._cols ?? 12;
144
+ case 'lg': return lg ?? md ?? sm ?? xs ?? this._cols ?? 12;
145
+ case 'md': return md ?? sm ?? xs ?? this._cols ?? 12;
146
+ case 'sm': return sm ?? xs ?? this._cols ?? 12;
147
+ case 'xs': return xs ?? this._cols ?? 12;
148
+ default: return this._cols ?? 12;
149
+ }
144
150
  }
145
151
  asNum(v, fallback) {
146
152
  if (v === null || v === undefined || v === '')
@@ -320,16 +326,28 @@ class PtechColDirective {
320
326
  this.gridColumn = `auto / span ${span}`;
321
327
  }
322
328
  resolveColForBp() {
323
- const map = {
324
- xs: this.asNum(this.ptechColXs),
325
- sm: this.asNum(this.ptechColSm),
326
- md: this.asNum(this.ptechColMd),
327
- lg: this.asNum(this.ptechColLg),
328
- xl: this.asNum(this.ptechColXl),
329
- };
329
+ const xs = this.asNum(this.ptechColXs);
330
+ const sm = this.asNum(this.ptechColSm);
331
+ const md = this.asNum(this.ptechColMd);
332
+ const lg = this.asNum(this.ptechColLg);
333
+ const xl = this.asNum(this.ptechColXl);
330
334
  const bp = this.activeBp;
331
- const span = bp ? map[bp] : undefined;
332
- return span ?? this._col ?? 12;
335
+ if (!bp)
336
+ return this._col ?? 12;
337
+ // Cascata mobile-first:
338
+ // xl -> lg -> md -> sm -> xs -> base
339
+ // lg -> md -> sm -> xs -> base
340
+ // md -> sm -> xs -> base
341
+ // sm -> xs -> base
342
+ // xs -> base
343
+ switch (bp) {
344
+ case 'xl': return xl ?? lg ?? md ?? sm ?? xs ?? this._col ?? 12;
345
+ case 'lg': return lg ?? md ?? sm ?? xs ?? this._col ?? 12;
346
+ case 'md': return md ?? sm ?? xs ?? this._col ?? 12;
347
+ case 'sm': return sm ?? xs ?? this._col ?? 12;
348
+ case 'xs': return xs ?? this._col ?? 12;
349
+ default: return this._col ?? 12;
350
+ }
333
351
  }
334
352
  asNum(v, fallback) {
335
353
  if (v === null || v === undefined || v === '')