Skip to content

Commit 32f66bd

Browse files
committed
Supporting new properties and removing old ones
1 parent 0e3e31d commit 32f66bd

7 files changed

Lines changed: 87 additions & 137 deletions

File tree

core/api.txt

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -622,18 +622,12 @@ ion-col,prop,offsetMd,string | undefined,undefined,false,false
622622
ion-col,prop,offsetSm,string | undefined,undefined,false,false
623623
ion-col,prop,offsetXl,string | undefined,undefined,false,false
624624
ion-col,prop,offsetXs,string | undefined,undefined,false,false
625-
ion-col,prop,pull,string | undefined,undefined,false,false
626-
ion-col,prop,pullLg,string | undefined,undefined,false,false
627-
ion-col,prop,pullMd,string | undefined,undefined,false,false
628-
ion-col,prop,pullSm,string | undefined,undefined,false,false
629-
ion-col,prop,pullXl,string | undefined,undefined,false,false
630-
ion-col,prop,pullXs,string | undefined,undefined,false,false
631-
ion-col,prop,push,string | undefined,undefined,false,false
632-
ion-col,prop,pushLg,string | undefined,undefined,false,false
633-
ion-col,prop,pushMd,string | undefined,undefined,false,false
634-
ion-col,prop,pushSm,string | undefined,undefined,false,false
635-
ion-col,prop,pushXl,string | undefined,undefined,false,false
636-
ion-col,prop,pushXs,string | undefined,undefined,false,false
625+
ion-col,prop,order,string | undefined,undefined,false,false
626+
ion-col,prop,orderLg,string | undefined,undefined,false,false
627+
ion-col,prop,orderMd,string | undefined,undefined,false,false
628+
ion-col,prop,orderSm,string | undefined,undefined,false,false
629+
ion-col,prop,orderXl,string | undefined,undefined,false,false
630+
ion-col,prop,orderXs,string | undefined,undefined,false,false
637631
ion-col,prop,size,string | undefined,undefined,false,false
638632
ion-col,prop,sizeLg,string | undefined,undefined,false,false
639633
ion-col,prop,sizeMd,string | undefined,undefined,false,false

core/src/components.d.ts

Lines changed: 24 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -928,53 +928,29 @@ export namespace Components {
928928
*/
929929
"offsetXs"?: string;
930930
/**
931-
* The amount to pull the column, in terms of how many columns it should shift to the start of the total available.
931+
* The order of the column, in terms of where the column should position itself in the columns renderer. If no value is passed, the column order implicit value will be the order in the html structure.
932932
*/
933-
"pull"?: string;
933+
"order"?: string;
934934
/**
935-
* The amount to pull the column for lg screens, in terms of how many columns it should shift to the start of the total available.
935+
* The order of the column for lg screens, in terms of where the column should position itself in the columns renderer. If no value is passed, the column order implicit value will be the order in the html structure.
936936
*/
937-
"pullLg"?: string;
937+
"orderLg"?: string;
938938
/**
939-
* The amount to pull the column for md screens, in terms of how many columns it should shift to the start of the total available.
939+
* The order of the column for md screens, in terms of where the column should position itself in the columns renderer. If no value is passed, the column order implicit value will be the order in the html structure.
940940
*/
941-
"pullMd"?: string;
941+
"orderMd"?: string;
942942
/**
943-
* The amount to pull the column for sm screens, in terms of how many columns it should shift to the start of the total available.
943+
* The order of the column for sm screens, in terms of where the column should position itself in the columns renderer. If no value is passed, the column order implicit value will be the order in the html structure.
944944
*/
945-
"pullSm"?: string;
945+
"orderSm"?: string;
946946
/**
947-
* The amount to pull the column for xl screens, in terms of how many columns it should shift to the start of the total available.
947+
* The order of the column for xl screens, in terms of where the column should position itself in the columns renderer. If no value is passed, the column order implicit value will be the order in the html structure.
948948
*/
949-
"pullXl"?: string;
949+
"orderXl"?: string;
950950
/**
951-
* The amount to pull the column for xs screens, in terms of how many columns it should shift to the start of the total available.
951+
* The order of the column for xs screens, in terms of where the column should position itself in the columns renderer. If no value is passed, the column order implicit value will be the order in the html structure.
952952
*/
953-
"pullXs"?: string;
954-
/**
955-
* The amount to push the column, in terms of how many columns it should shift to the end of the total available.
956-
*/
957-
"push"?: string;
958-
/**
959-
* The amount to push the column for lg screens, in terms of how many columns it should shift to the end of the total available.
960-
*/
961-
"pushLg"?: string;
962-
/**
963-
* The amount to push the column for md screens, in terms of how many columns it should shift to the end of the total available.
964-
*/
965-
"pushMd"?: string;
966-
/**
967-
* The amount to push the column for sm screens, in terms of how many columns it should shift to the end of the total available.
968-
*/
969-
"pushSm"?: string;
970-
/**
971-
* The amount to push the column for xl screens, in terms of how many columns it should shift to the end of the total available.
972-
*/
973-
"pushXl"?: string;
974-
/**
975-
* The amount to push the column for xs screens, in terms of how many columns it should shift to the end of the total available.
976-
*/
977-
"pushXs"?: string;
953+
"orderXs"?: string;
978954
/**
979955
* The size of the column, in terms of how many columns it should take up out of the total available. If `"auto"` is passed, the column will be the size of its content.
980956
*/
@@ -6862,53 +6838,29 @@ declare namespace LocalJSX {
68626838
*/
68636839
"offsetXs"?: string;
68646840
/**
6865-
* The amount to pull the column, in terms of how many columns it should shift to the start of the total available.
6866-
*/
6867-
"pull"?: string;
6868-
/**
6869-
* The amount to pull the column for lg screens, in terms of how many columns it should shift to the start of the total available.
6870-
*/
6871-
"pullLg"?: string;
6872-
/**
6873-
* The amount to pull the column for md screens, in terms of how many columns it should shift to the start of the total available.
6874-
*/
6875-
"pullMd"?: string;
6876-
/**
6877-
* The amount to pull the column for sm screens, in terms of how many columns it should shift to the start of the total available.
6878-
*/
6879-
"pullSm"?: string;
6880-
/**
6881-
* The amount to pull the column for xl screens, in terms of how many columns it should shift to the start of the total available.
6882-
*/
6883-
"pullXl"?: string;
6884-
/**
6885-
* The amount to pull the column for xs screens, in terms of how many columns it should shift to the start of the total available.
6886-
*/
6887-
"pullXs"?: string;
6888-
/**
6889-
* The amount to push the column, in terms of how many columns it should shift to the end of the total available.
6841+
* The order of the column, in terms of where the column should position itself in the columns renderer. If no value is passed, the column order implicit value will be the order in the html structure.
68906842
*/
6891-
"push"?: string;
6843+
"order"?: string;
68926844
/**
6893-
* The amount to push the column for lg screens, in terms of how many columns it should shift to the end of the total available.
6845+
* The order of the column for lg screens, in terms of where the column should position itself in the columns renderer. If no value is passed, the column order implicit value will be the order in the html structure.
68946846
*/
6895-
"pushLg"?: string;
6847+
"orderLg"?: string;
68966848
/**
6897-
* The amount to push the column for md screens, in terms of how many columns it should shift to the end of the total available.
6849+
* The order of the column for md screens, in terms of where the column should position itself in the columns renderer. If no value is passed, the column order implicit value will be the order in the html structure.
68986850
*/
6899-
"pushMd"?: string;
6851+
"orderMd"?: string;
69006852
/**
6901-
* The amount to push the column for sm screens, in terms of how many columns it should shift to the end of the total available.
6853+
* The order of the column for sm screens, in terms of where the column should position itself in the columns renderer. If no value is passed, the column order implicit value will be the order in the html structure.
69026854
*/
6903-
"pushSm"?: string;
6855+
"orderSm"?: string;
69046856
/**
6905-
* The amount to push the column for xl screens, in terms of how many columns it should shift to the end of the total available.
6857+
* The order of the column for xl screens, in terms of where the column should position itself in the columns renderer. If no value is passed, the column order implicit value will be the order in the html structure.
69066858
*/
6907-
"pushXl"?: string;
6859+
"orderXl"?: string;
69086860
/**
6909-
* The amount to push the column for xs screens, in terms of how many columns it should shift to the end of the total available.
6861+
* The order of the column for xs screens, in terms of where the column should position itself in the columns renderer. If no value is passed, the column order implicit value will be the order in the html structure.
69106862
*/
6911-
"pushXs"?: string;
6863+
"orderXs"?: string;
69126864
/**
69136865
* The size of the column, in terms of how many columns it should take up out of the total available. If `"auto"` is passed, the column will be the size of its content.
69146866
*/

core/src/components/col/col.scss

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,36 @@
2727
max-width: 100%;
2828
min-height: 1px; // Prevent columns from collapsing when empty
2929
}
30+
31+
:host(.ion-grid-col-auto){
32+
flex: 0 0 auto;
33+
}
34+
35+
:host(
36+
[class^="ion-grid-col-"],
37+
[class*=" ion-grid-col-"]) {
38+
flex: 0 0
39+
calc(var(--ion-grid-col-span) * var(--col-unit-size) +
40+
(var(--ion-grid-col-span) - 1) * var(--ion-grid-gap));
41+
}
42+
43+
:host(
44+
[class^="ion-grid-offset-col-"],
45+
[class*=" ion-grid-offset-col-"]) {
46+
--margin-calc: calc(var(--col-unit-size) * var(--ion-grid-col-margin) + (var(--ion-grid-gap) * var(--ion-grid-col-margin)));
47+
margin-left: var(--margin-calc);
48+
}
49+
50+
.rtl :host(
51+
[class^="ion-grid-offset-col-"],
52+
[class*=" ion-grid-offset-col-"]) {
53+
margin-left: 0;
54+
margin-right: var(--margin-calc);
55+
}
56+
57+
$max: 12;
58+
@for $i from 1 through $max {
59+
.ion-grid-col-#{$i} { --ion-grid-col-span: #{$i}; }
60+
.ion-grid-order-col-#{$i} { order: #{$i}; }
61+
.ion-grid-offset-col-#{$i} { --ion-grid-col-margin: #{$i};}
62+
}

core/src/components/col/col.tsx

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import { matchBreakpoint } from '@utils/media';
44

55
import { getIonTheme } from '../../global/ionic-global';
66

7-
const win = typeof (window as any) !== 'undefined' ? (window as any) : undefined;
87
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
9-
const SUPPORTS_VARS = win && !!(win.CSS && win.CSS.supports && win.CSS.supports('--a: 0'));
108
const BREAKPOINTS = ['', 'xs', 'sm', 'md', 'lg', 'xl'];
119

1210
/**
@@ -154,61 +152,40 @@ export class Col implements ComponentInterface {
154152
return matched;
155153
}
156154

157-
private getSizeClass(): string | undefined {
158-
const colSize = this.getColumns('size');
155+
private getStyleClass(property: string, className: string, acceptsAuto = false): string | undefined {
156+
const colPropertyValue = this.getColumns(property);
159157

160158
// If size wasn't set for any breakpoint
161159
// or if the user set the size without a value
162160
// it means we need to stick with the default and return
163161
// e.g. <ion-col size-md>
164-
if (!colSize || colSize === '') {
162+
if (!colPropertyValue || colPropertyValue === '') {
165163
return;
166164
}
167165

168-
if (colSize === 'auto') {
169-
return 'ion-grid-auto';
166+
if (acceptsAuto && colPropertyValue === 'auto') {
167+
return 'ion-grid-col-auto';
170168
}
171169

172-
const colNum = parseInt(colSize);
170+
const valueNumber = parseInt(colPropertyValue);
173171

174-
if(isNaN(colNum)) {
172+
if (isNaN(valueNumber)) {
175173
return;
176174
}
177175

178-
return `ion-grid-col-${colSize}`;
176+
return `${className}-col-${valueNumber}`;
179177
}
180178

181-
private getOrderClass(): string | undefined {
182-
const colOrder = this.getColumns('order');
183-
184-
if (!colOrder || colOrder === '') {
185-
return;
186-
}
187-
188-
const colNum = parseInt(colOrder);
189-
190-
if (isNaN(colNum)) {
191-
return;
192-
}
193-
194-
return `ion-grid-order-${colOrder}`;
179+
private getSizeClass(): string | undefined {
180+
return this.getStyleClass('size', 'ion-grid', true);
195181
}
196182

183+
private getOrderClass(): string | undefined {
184+
return this.getStyleClass('order', 'ion-grid-order');
185+
}
197186

198187
private getOffsetClass(): string | undefined {
199-
const colOffset = this.getColumns('offset');
200-
201-
if (!colOffset || colOffset === '') {
202-
return;
203-
}
204-
205-
const colNum = parseInt(colOffset);
206-
207-
if (isNaN(colNum)) {
208-
return;
209-
}
210-
211-
return `ion-grid-offset-col-${colOffset}`;
188+
return this.getStyleClass('offset', 'ion-grid-offset');
212189
}
213190

214191
render() {

packages/angular/src/directives/proxies.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,14 +572,14 @@ export declare interface IonChip extends Components.IonChip {}
572572

573573

574574
@ProxyCmp({
575-
inputs: ['mode', 'offset', 'offsetLg', 'offsetMd', 'offsetSm', 'offsetXl', 'offsetXs', 'pull', 'pullLg', 'pullMd', 'pullSm', 'pullXl', 'pullXs', 'push', 'pushLg', 'pushMd', 'pushSm', 'pushXl', 'pushXs', 'size', 'sizeLg', 'sizeMd', 'sizeSm', 'sizeXl', 'sizeXs', 'theme']
575+
inputs: ['mode', 'offset', 'offsetLg', 'offsetMd', 'offsetSm', 'offsetXl', 'offsetXs', 'order', 'orderLg', 'orderMd', 'orderSm', 'orderXl', 'orderXs', 'size', 'sizeLg', 'sizeMd', 'sizeSm', 'sizeXl', 'sizeXs', 'theme']
576576
})
577577
@Component({
578578
selector: 'ion-col',
579579
changeDetection: ChangeDetectionStrategy.OnPush,
580580
template: '<ng-content></ng-content>',
581581
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
582-
inputs: ['mode', 'offset', 'offsetLg', 'offsetMd', 'offsetSm', 'offsetXl', 'offsetXs', 'pull', 'pullLg', 'pullMd', 'pullSm', 'pullXl', 'pullXs', 'push', 'pushLg', 'pushMd', 'pushSm', 'pushXl', 'pushXs', 'size', 'sizeLg', 'sizeMd', 'sizeSm', 'sizeXl', 'sizeXs', 'theme'],
582+
inputs: ['mode', 'offset', 'offsetLg', 'offsetMd', 'offsetSm', 'offsetXl', 'offsetXs', 'order', 'orderLg', 'orderMd', 'orderSm', 'orderXl', 'orderXs', 'size', 'sizeLg', 'sizeMd', 'sizeSm', 'sizeXl', 'sizeXs', 'theme'],
583583
})
584584
export class IonCol {
585585
protected el: HTMLIonColElement;

packages/angular/standalone/src/directives/proxies.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,14 +642,14 @@ export declare interface IonChip extends Components.IonChip {}
642642

643643
@ProxyCmp({
644644
defineCustomElementFn: defineIonCol,
645-
inputs: ['mode', 'offset', 'offsetLg', 'offsetMd', 'offsetSm', 'offsetXl', 'offsetXs', 'pull', 'pullLg', 'pullMd', 'pullSm', 'pullXl', 'pullXs', 'push', 'pushLg', 'pushMd', 'pushSm', 'pushXl', 'pushXs', 'size', 'sizeLg', 'sizeMd', 'sizeSm', 'sizeXl', 'sizeXs', 'theme']
645+
inputs: ['mode', 'offset', 'offsetLg', 'offsetMd', 'offsetSm', 'offsetXl', 'offsetXs', 'order', 'orderLg', 'orderMd', 'orderSm', 'orderXl', 'orderXs', 'size', 'sizeLg', 'sizeMd', 'sizeSm', 'sizeXl', 'sizeXs', 'theme']
646646
})
647647
@Component({
648648
selector: 'ion-col',
649649
changeDetection: ChangeDetectionStrategy.OnPush,
650650
template: '<ng-content></ng-content>',
651651
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
652-
inputs: ['mode', 'offset', 'offsetLg', 'offsetMd', 'offsetSm', 'offsetXl', 'offsetXs', 'pull', 'pullLg', 'pullMd', 'pullSm', 'pullXl', 'pullXs', 'push', 'pushLg', 'pushMd', 'pushSm', 'pushXl', 'pushXs', 'size', 'sizeLg', 'sizeMd', 'sizeSm', 'sizeXl', 'sizeXs', 'theme'],
652+
inputs: ['mode', 'offset', 'offsetLg', 'offsetMd', 'offsetSm', 'offsetXl', 'offsetXs', 'order', 'orderLg', 'orderMd', 'orderSm', 'orderXl', 'orderXs', 'size', 'sizeLg', 'sizeMd', 'sizeSm', 'sizeXl', 'sizeXs', 'theme'],
653653
standalone: true
654654
})
655655
export class IonCol {

packages/vue/src/proxies.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -280,18 +280,12 @@ export const IonCol: StencilVueComponent<JSX.IonCol> = /*@__PURE__*/ defineConta
280280
'offsetMd',
281281
'offsetLg',
282282
'offsetXl',
283-
'pull',
284-
'pullXs',
285-
'pullSm',
286-
'pullMd',
287-
'pullLg',
288-
'pullXl',
289-
'push',
290-
'pushXs',
291-
'pushSm',
292-
'pushMd',
293-
'pushLg',
294-
'pushXl',
283+
'order',
284+
'orderXs',
285+
'orderSm',
286+
'orderMd',
287+
'orderLg',
288+
'orderXl',
295289
'size',
296290
'sizeXs',
297291
'sizeSm',

0 commit comments

Comments
 (0)