Skip to content

Commit bde1d09

Browse files
authored
feat(modal): add default ionic theme styles (#29876)
Issue number: resolves internal --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> No default modal styles for the Ionic theme ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Splits common and native styles into separate stylesheets - Adds default styles to modals for Ionic theme ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change: 1. Describe the impact and migration path for existing applications below. 2. Update the BREAKING.md file with the breaking change. 3. Add "BREAKING CHANGE: [...]" to the commit description when merging. See https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer for more information. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> I only applied some of the global styles to the sheet modal vairation since it is unclear whether the card variation will be used in the widgets
1 parent 05cf900 commit bde1d09

File tree

36 files changed

+217
-64
lines changed

36 files changed

+217
-64
lines changed

core/src/components/modal/modal.scss renamed to core/src/components/modal/modal.common.scss

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
@import "./modal.vars";
1+
@import "../../themes/mixins.scss";
22

3-
// Modals
3+
// Modals: Common Styles
44
// --------------------------------------------------
55

66
:host {
@@ -29,13 +29,10 @@
2929
--min-height: auto;
3030
--max-height: auto;
3131
--overflow: hidden;
32-
--border-radius: 0;
3332
--border-width: 0;
3433
--border-style: none;
3534
--border-color: transparent;
36-
--background: #{$background-color};
3735
--box-shadow: none;
38-
--backdrop-opacity: 0;
3936

4037
@include position(0, 0, 0, 0);
4138

@@ -47,8 +44,6 @@
4744

4845
outline: none;
4946

50-
color: $modal-text-color;
51-
5247
contain: strict;
5348
}
5449

@@ -90,37 +85,14 @@ ion-backdrop {
9085
background: transparent;
9186
}
9287

93-
@media only screen and (min-width: $modal-inset-min-width) and (min-height: $modal-inset-min-height-small) {
94-
:host {
95-
--width: #{$modal-inset-width};
96-
--height: #{$modal-inset-height-small};
97-
--ion-safe-area-top: 0px;
98-
--ion-safe-area-bottom: 0px;
99-
--ion-safe-area-right: 0px;
100-
--ion-safe-area-left: 0px;
101-
}
102-
}
103-
104-
@media only screen and (min-width: $modal-inset-min-width) and (min-height: $modal-inset-min-height-large) {
105-
:host {
106-
--width: #{$modal-inset-width};
107-
--height: #{$modal-inset-height-large};
108-
}
109-
}
110-
11188
// Sheet Modal
11289
// --------------------------------------------------
11390

11491
.modal-handle {
115-
@include position(5px, 0px, null, 0px);
116-
@include border-radius(8px, 8px, 8px, 8px);
11792
@include margin(null, auto, null, auto);
11893

11994
position: absolute;
12095

121-
width: 36px;
122-
height: 5px;
123-
12496
/**
12597
* This allows the handle to appear
12698
* on top of user content in WebKit.
@@ -129,8 +101,6 @@ ion-backdrop {
129101

130102
border: 0;
131103

132-
background: var(--ion-color-step-350, var(--ion-background-color-step-350, #c0c0be));
133-
134104
cursor: pointer;
135105

136106
z-index: 11;
@@ -144,9 +114,6 @@ ion-backdrop {
144114

145115
position: absolute;
146116

147-
width: 36px;
148-
height: 5px;
149-
150117
transform: translate(-50%, -50%);
151118

152119
content: "";

core/src/components/modal/modal.ionic.scss

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
@use "../../themes/ionic/ionic.globals.scss" as globals;
2-
@import "./modal";
2+
@use "./modal.common";
33

44
// Ionic Modal
55
// --------------------------------------------------
66

77
:host {
8+
--background: #{globals.$ionic-color-base-white};
9+
--box-shadow: #{globals.$ionic-elevation-300};
810
--backdrop-opacity: 1;
11+
12+
color: globals.$ionic-color-neutral-1200;
913
}
1014

1115
// Shape
@@ -21,3 +25,20 @@
2125
:host(.modal-rectangular) {
2226
--border-radius: #{globals.$ionic-border-radius-0};
2327
}
28+
29+
// Sheet Modal
30+
// --------------------------------------------------
31+
32+
.modal-handle {
33+
@include globals.position(globals.$ionic-space-300, 0px, null, 0px);
34+
@include globals.border-radius(globals.$ionic-border-radius-100);
35+
36+
width: globals.$ionic-scale-1100;
37+
height: globals.$ionic-scale-100;
38+
39+
background-color: globals.$ionic-color-neutral-300;
40+
}
41+
42+
:host(.modal-sheet) .modal-wrapper {
43+
@include globals.border-radius(var(--border-radius), var(--border-radius), 0, 0);
44+
}

core/src/components/modal/modal.ios.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import "./modal";
1+
@import "./modal.native";
22
@import "./modal.ios.vars";
33

44
// iOS Modals

core/src/components/modal/modal.md.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import "./modal";
1+
@import "./modal.native";
22
@import "./modal.md.vars";
33

44
// Material Design Modals
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
@use "./modal.common";
2+
@use "./modal.vars" as vars;
3+
@forward "./modal.vars.scss";
4+
5+
// Modals: Native Styles
6+
// --------------------------------------------------
7+
8+
:host {
9+
--background: #{vars.$background-color};
10+
--border-radius: 0;
11+
--backdrop-opacity: 0;
12+
13+
color: vars.$modal-text-color;
14+
}
15+
16+
@media only screen and (min-width: vars.$modal-inset-min-width) and (min-height: vars.$modal-inset-min-height-small) {
17+
:host {
18+
--width: #{vars.$modal-inset-width};
19+
--height: #{vars.$modal-inset-height-small};
20+
--ion-safe-area-top: 0px;
21+
--ion-safe-area-bottom: 0px;
22+
--ion-safe-area-right: 0px;
23+
--ion-safe-area-left: 0px;
24+
}
25+
}
26+
27+
@media only screen and (min-width: vars.$modal-inset-min-width) and (min-height: vars.$modal-inset-min-height-large) {
28+
:host {
29+
--width: #{vars.$modal-inset-width};
30+
--height: #{vars.$modal-inset-height-large};
31+
}
32+
}
33+
34+
// Sheet Modal
35+
// --------------------------------------------------
36+
37+
.modal-handle {
38+
@include vars.position(5px, 0px, null, 0px);
39+
@include vars.border-radius(8px, 8px, 8px, 8px);
40+
41+
width: 36px;
42+
height: 5px;
43+
44+
background: var(--ion-color-step-350, var(--ion-background-color-step-350, #c0c0be));
45+
46+
&::before {
47+
width: 36px;
48+
height: 5px;
49+
}
50+
}

core/src/components/modal/test/shape/index.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>
1515

1616
<style>
17-
ion-modal {
18-
--box-shadow: 0px 0px 30px 10px rgba(0, 0, 0, 0.1);
19-
}
20-
2117
.container {
2218
margin-bottom: 20px;
2319
}
-299 Bytes
Loading
-329 Bytes
Loading
-205 Bytes
Loading
-371 Bytes
Loading

0 commit comments

Comments
 (0)