Skip to content

Commit 7afba1a

Browse files
committed
feat(content): add recipe and tokens
1 parent 3e68056 commit 7afba1a

14 files changed

Lines changed: 154 additions & 48 deletions

File tree

core/api.txt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -758,15 +758,16 @@ ion-content,method,scrollToTop,scrollToTop(duration?: number) => Promise<void>
758758
ion-content,event,ionScroll,ScrollDetail,true
759759
ion-content,event,ionScrollEnd,ScrollBaseDetail,true
760760
ion-content,event,ionScrollStart,ScrollBaseDetail,true
761-
ion-content,css-prop,--background
762-
ion-content,css-prop,--color
763-
ion-content,css-prop,--keyboard-offset
764-
ion-content,css-prop,--offset-bottom
765-
ion-content,css-prop,--offset-top
766-
ion-content,css-prop,--padding-bottom
767-
ion-content,css-prop,--padding-end
768-
ion-content,css-prop,--padding-start
769-
ion-content,css-prop,--padding-top
761+
ion-content,css-prop,--ion-content-background
762+
ion-content,css-prop,--ion-content-color
763+
ion-content,css-prop,--ion-content-overflow
764+
ion-content,css-prop,--ion-content-padding-bottom
765+
ion-content,css-prop,--ion-content-padding-end
766+
ion-content,css-prop,--ion-content-padding-start
767+
ion-content,css-prop,--ion-content-padding-top
768+
ion-content,css-prop,--ion-content-transition-cover-background
769+
ion-content,css-prop,--ion-content-transition-cover-opacity
770+
ion-content,css-prop,--ion-content-transition-shadow
770771
ion-content,part,background
771772
ion-content,part,scroll
772773

core/src/components.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { RouteID, RouterDirection, RouterEventDetail, RouteWrite } from "./compo
1515
import { BreadcrumbCollapsedClickEventDetail } from "./components/breadcrumb/breadcrumb-interface";
1616
import { CheckboxChangeEventDetail } from "./components/checkbox/checkbox-interface";
1717
import { IonChipFill, IonChipHue, IonChipShape, IonChipSize } from "./components/chip/chip.interfaces";
18-
import { ScrollBaseDetail, ScrollDetail } from "./components/content/content-interface";
18+
import { ScrollBaseDetail, ScrollDetail } from "./components/content/content.interfaces";
1919
import { DatetimeChangeEventDetail, DatetimeHighlight, DatetimeHighlightCallback, DatetimeHourCycle, DatetimePresentation, FormatOptions, TitleSelectedDatesFormatter } from "./components/datetime/datetime-interface";
2020
import { SpinnerTypes } from "./components/spinner/spinner-configs";
2121
import { InputChangeEventDetail, InputInputEventDetail } from "./components/input/input-interface";
@@ -55,7 +55,7 @@ export { RouteID, RouterDirection, RouterEventDetail, RouteWrite } from "./compo
5555
export { BreadcrumbCollapsedClickEventDetail } from "./components/breadcrumb/breadcrumb-interface";
5656
export { CheckboxChangeEventDetail } from "./components/checkbox/checkbox-interface";
5757
export { IonChipFill, IonChipHue, IonChipShape, IonChipSize } from "./components/chip/chip.interfaces";
58-
export { ScrollBaseDetail, ScrollDetail } from "./components/content/content-interface";
58+
export { ScrollBaseDetail, ScrollDetail } from "./components/content/content.interfaces";
5959
export { DatetimeChangeEventDetail, DatetimeHighlight, DatetimeHighlightCallback, DatetimeHourCycle, DatetimePresentation, FormatOptions, TitleSelectedDatesFormatter } from "./components/datetime/datetime-interface";
6060
export { SpinnerTypes } from "./components/spinner/spinner-configs";
6161
export { InputChangeEventDetail, InputInputEventDetail } from "./components/input/input-interface";

core/src/components/content/content-interface.ts renamed to core/src/components/content/content.interfaces.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
11
import type { GestureDetail } from '../../interface';
2+
import type { IonPadding } from '../../themes/themes.interfaces';
3+
4+
export interface IonContentRecipe {
5+
background?: string;
6+
color?: string;
7+
overflow?: string;
8+
9+
padding?: IonPadding;
10+
11+
transition?: {
12+
cover?: {
13+
background?: string;
14+
opacity?: string;
15+
};
16+
17+
shadow?: string;
18+
};
19+
}
20+
21+
export interface IonContentConfig {
22+
transitionShadow?: boolean;
23+
}
224

325
export interface ScrollBaseDetail {
426
isScrolling: boolean;

core/src/components/content/content.scss

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,25 @@
55

66
:host {
77
/**
8-
* @prop --background: Background of the content
8+
* @prop --ion-content-background: Background of the content
99
*
10-
* @prop --color: Color of the content
10+
* @prop --ion-content-color: Color of the content
1111
*
12-
* @prop --padding-top: Top padding of the content
13-
* @prop --padding-end: Right padding if direction is left-to-right, and left padding if direction is right-to-left of the content
14-
* @prop --padding-bottom: Bottom padding of the content
15-
* @prop --padding-start: Left padding if direction is left-to-right, and right padding if direction is right-to-left of the content
12+
* @prop --ion-content-overflow: Overflow behavior of the scrollable area
1613
*
17-
* @prop --keyboard-offset: Keyboard offset of the content
14+
* @prop --ion-content-padding-top: Top padding of the content
15+
* @prop --ion-content-padding-end: Right padding if direction is left-to-right, and left padding if direction is right-to-left of the content
16+
* @prop --ion-content-padding-bottom: Bottom padding of the content
17+
* @prop --ion-content-padding-start: Left padding if direction is left-to-right, and right padding if direction is right-to-left of the content
1818
*
19-
* @prop --offset-top: Offset top of the content
20-
* @prop --offset-bottom: Offset bottom of the content
19+
* @prop --ion-content-transition-cover-background: Background color of the navigation transition cover overlay
20+
* @prop --ion-content-transition-cover-opacity: Opacity of the navigation transition cover overlay
21+
*
22+
* @prop --ion-content-transition-shadow: Box shadow of the navigation transition shadow
2123
*/
22-
--background: #{$background-color};
23-
--color: #{$text-color};
24-
--padding-top: 0px;
25-
--padding-bottom: 0px;
26-
--padding-start: 0px;
27-
--padding-end: 0px;
2824
--keyboard-offset: 0px;
2925
--offset-top: 0px;
3026
--offset-bottom: 0px;
31-
--overflow: auto;
3227

3328
display: block;
3429
position: relative;
@@ -59,21 +54,21 @@
5954

6055
position: absolute;
6156

62-
background: var(--background);
57+
background: var(--ion-content-background);
6358
}
6459

6560
.inner-scroll {
6661
@include position(calc(var(--offset-top) * -1), 0px, calc(var(--offset-bottom) * -1), 0px);
6762
@include padding(
68-
calc(var(--padding-top) + var(--offset-top)),
69-
var(--padding-end),
70-
calc(var(--padding-bottom) + var(--keyboard-offset) + var(--offset-bottom)),
71-
var(--padding-start)
63+
calc(var(--ion-content-padding-top) + var(--offset-top)),
64+
var(--ion-content-padding-end),
65+
calc(var(--ion-content-padding-bottom) + var(--keyboard-offset) + var(--offset-bottom)),
66+
var(--ion-content-padding-start)
7267
);
7368

7469
position: absolute;
7570

76-
color: var(--color);
71+
color: var(--ion-content-color);
7772

7873
box-sizing: border-box;
7974

@@ -115,12 +110,12 @@
115110
}
116111

117112
.scroll-y {
118-
overflow-y: var(--overflow);
113+
overflow-y: var(--ion-content-overflow);
119114
overscroll-behavior-y: contain;
120115
}
121116

122117
.scroll-x {
123-
overflow-x: var(--overflow);
118+
overflow-x: var(--ion-content-overflow);
124119
overscroll-behavior-x: contain;
125120
}
126121

@@ -210,9 +205,9 @@
210205
width: 100%;
211206
height: 100%;
212207

213-
background: black;
208+
background: var(--ion-content-transition-cover-background);
214209

215-
opacity: 0.1;
210+
opacity: var(--ion-content-transition-cover-opacity);
216211
}
217212

218213
.transition-shadow {
@@ -222,7 +217,7 @@
222217
width: 100%;
223218
height: 100%;
224219

225-
box-shadow: inset -9px 0 9px 0 rgba(0, 0, 100, 0.03);
220+
box-shadow: var(--ion-content-transition-shadow);
226221
}
227222

228223
:host(.content-ltr) .transition-shadow {

core/src/components/content/content.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { config } from '../../global/config';
1010
import { getIonMode, getIonTheme } from '../../global/ionic-global';
1111
import type { Color, Mode } from '../../interface';
1212

13-
import type { ScrollBaseDetail, ScrollDetail } from './content-interface';
13+
import type { ScrollBaseDetail, ScrollDetail } from './content.interfaces';
1414

1515
/**
1616
* @virtualProp {"ios" | "md"} mode - The mode determines the platform behaviors of the component.
@@ -457,7 +457,7 @@ export class Content implements ComponentInterface {
457457
const theme = getIonTheme(this);
458458
const mode = getIonMode(this);
459459
const forceOverscroll = this.shouldForceOverscroll(mode);
460-
const transitionShadow = theme === 'ios';
460+
const transitionShadow = config.getObjectValue('IonContent.transitionShadow', false) as boolean;
461461

462462
this.resize();
463463

core/src/components/content/test/fullscreen/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@
6565
}
6666

6767
ion-content {
68-
--background: linear-gradient(90deg, blue, red);
69-
--color: white;
68+
--ion-content-background: linear-gradient(90deg, blue, red);
69+
--ion-content-color: white;
7070
}
7171

7272
p:first-child {

core/src/components/content/test/standalone/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ <h6>Heading</h6>
5959
}
6060

6161
.custom-color {
62-
--background: blue;
63-
--color: white;
62+
--ion-content-background: blue;
63+
--ion-content-color: white;
6464
--hr-background: purple;
6565
}
6666
</style>

core/src/css/core.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ ion-card-header.ion-color .ion-inherit-color {
247247
* The code below accounts for both ion-content and then custom
248248
* scroll containers within ion-content (such as virtual scroll)
249249
*/
250-
.menu-content-open ion-content {
251-
--overflow: hidden;
250+
.menu-content-open ion-content::part(scroll) {
251+
overflow: hidden;
252252
}
253253

254254
.menu-content-open .ion-content-scroll-host {

core/src/css/ionic/core.ionic.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ ion-card-header.ion-color .ion-inherit-color {
254254
* The code below accounts for both ion-content and then custom
255255
* scroll containers within ion-content (such as virtual scroll)
256256
*/
257+
/**
258+
* NOTE: This rule will not be updated as part of individual component migrations.
259+
* core.ionic.scss is slated for deletion and will be fully replaced by core.scss.
260+
* All remaining styles here will be consolidated into core.scss at that time.
261+
*/
257262
.menu-content-open ion-content {
258263
--overflow: hidden;
259264
}

core/src/global/config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import type { IonicConfig } from '../themes/themes.interfaces';
22

33
// TODO(FW-2832): types
44

5+
type ObjectConfigValue = string | boolean;
6+
57
export class Config {
68
private m = new Map<keyof IonicConfig, any>();
79

@@ -21,7 +23,7 @@ export class Config {
2123
* @param fallback Default value if the key is not found
2224
* @returns The value found at the nested key or the fallback
2325
*/
24-
getObjectValue(key: string, fallback?: string): string | undefined {
26+
getObjectValue(key: string, fallback?: ObjectConfigValue): ObjectConfigValue | undefined {
2527
const [firstKey, ...remainingKeys] = key.split('.');
2628

2729
let root: any;

0 commit comments

Comments
 (0)