Skip to content

Commit a57ca8d

Browse files
chore(theming): remove Sass default flag & update guidelines (#29458)
Remove a missed `!default` flag in the themes directory and update the Sass variable guidelines docs to eliminate the `!default` flag from the code examples, except for in the historic usage section which includes examples from previous versions where the `!default` flag was used. --------- Co-authored-by: Brandy Carney <[email protected]>
1 parent dfb72d7 commit a57ca8d

File tree

2 files changed

+43
-43
lines changed

2 files changed

+43
-43
lines changed

core/src/themes/ionic.theme.default.ios.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ $overlay-ios-background-color: var(--ion-overlay-background-color,
1313
// --------------------------------------------------
1414
$tabbar-ios-background: var(--ion-tab-bar-background, var(--ion-color-step-50, var(--ion-background-color-step-50, #f7f7f7)));
1515
$tabbar-ios-background-focused: var(--ion-tab-bar-background-focused, get-color-shade(#fff));
16-
$tabbar-ios-border-color: var(--ion-tab-bar-border-color, var(--ion-border-color, var(--ion-color-step-150, var(--ion-background-color-step-150, rgba(0, 0, 0, .2)))) )!default;
16+
$tabbar-ios-border-color: var(--ion-tab-bar-border-color, var(--ion-border-color, var(--ion-color-step-150, var(--ion-background-color-step-150, rgba(0, 0, 0, .2)))));
1717
$tabbar-ios-color: var(--ion-tab-bar-color, $text-color-step-400);
1818
$tabbar-ios-color-selected: var(--ion-tab-bar-color-selected, ion-color(primary, base));
1919

docs/sass-guidelines.md

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,16 @@ $alert-ios-radio-label-text-color-checked: $alert-ios-button-text-color !de
7171

7272
The abundance of Sass variables currently in Ionic Framework is a result of their historical usage, being used to rebuild the CSS and customize Ionic Framework components.
7373

74-
The comments for Sass variables are also still visible today in [v7.7.0](https://github.com/ionic-team/ionic-framework/blob/v7.7.0/core/src/components/alert/alert.ios.vars.scss), even though they are no longer used by any documentation generators:
74+
The comments for Sass variables are also still visible today in [v8.1.0](https://github.com/ionic-team/ionic-framework/blob/v8.1.0/core/src/components/alert/alert.ios.vars.scss), even though they are no longer used by any documentation generators:
7575

7676
```scss
7777
// alert.ios.vars.scss
7878

7979
/// @prop - Max width of the alert
80-
$alert-ios-max-width: dynamic-font-clamp(1, 270px, 1.2) !default;
80+
$alert-ios-max-width: dynamic-font-clamp(1, 270px, 1.2);
8181

8282
/// @prop - Border radius of the alert
83-
$alert-ios-border-radius: 13px !default;
83+
$alert-ios-border-radius: 13px;
8484
```
8585

8686
These comments aren't necessary when the naming describes its use thoroughly. The comments for the variables above do not need to be there, as it is fairly obvious what they are used for.
@@ -91,7 +91,7 @@ However, the comment for the following variable might be helpful in explaining w
9191
// action-sheet.ios.vars.scss
9292

9393
/// @prop - Font weight of the action sheet title when it has a sub title
94-
$action-sheet-ios-title-with-sub-title-font-weight: 600 !default;
94+
$action-sheet-ios-title-with-sub-title-font-weight: 600;
9595
```
9696

9797
It could be argued though that the comment doesn't really help, as seeing the variable in use will explain its purpose the best. Additionally, this is an example of a variable that isn't necessary, given it is only used in one place, which is why it is so specific in the first place.
@@ -110,15 +110,15 @@ We should update the comments for Sass variables in one of the following ways:
110110

111111
-/// @prop - Border radius of the alert
112112
+// Border radius of the alert
113-
$alert-ios-border-radius: 13px !default;
113+
$alert-ios-border-radius: 13px;
114114
```
115115

116116
2. If we don't find the comments to be helpful, and want to stick with keeping the variable names specific, we should remove the comments entirely:
117117
```diff
118118
// alert.ios.vars.scss
119119

120120
-/// @prop - Border radius of the alert
121-
$alert-ios-border-radius: 13px !default;
121+
$alert-ios-border-radius: 13px;
122122
```
123123

124124
3. If we find the comments to be helpful for certain variables or situations, like when there are math calculations involved, we should keep only the comments that are necessary to explain what is going on:
@@ -133,7 +133,7 @@ We should update the comments for Sass variables in one of the following ways:
133133
* a hairline (<1px) width, this will cause subpixel rendering
134134
* differences across browsers.
135135
*/
136-
$alert-ios-button-height: dynamic-font-min(1, 44px) !default;
136+
$alert-ios-button-height: dynamic-font-min(1, 44px);
137137
```
138138

139139
### Variables
@@ -161,11 +161,11 @@ Example of global variables:
161161
```scss
162162
// ionic.globals.scss
163163

164-
$font-family-base: var(--ion-font-family, inherit) !default;
164+
$font-family-base: var(--ion-font-family, inherit);
165165

166-
$hairlines-width: .55px !default;
166+
$hairlines-width: .55px;
167167

168-
$placeholder-opacity: 0.6 !default;
168+
$placeholder-opacity: 0.6;
169169
```
170170

171171
#### ✅ Theming
@@ -177,23 +177,23 @@ Example of theme variables:
177177
```scss
178178
// ionic.theme.default.scss
179179

180-
$background-color-value: #fff !default;
181-
$background-color-rgb-value: 255, 255, 255 !default;
180+
$background-color-value: #fff;
181+
$background-color-rgb-value: 255, 255, 255;
182182

183-
$text-color-value: #000 !default;
184-
$text-color-rgb-value: 0, 0, 0 !default;
183+
$text-color-value: #000;
184+
$text-color-rgb-value: 0, 0, 0;
185185

186-
$background-color: var(--ion-background-color, $background-color-value) !default;
187-
$background-color-rgb: var(--ion-background-color-rgb, $background-color-rgb-value) !default;
188-
$text-color: var(--ion-text-color, $text-color-value) !default;
189-
$text-color-rgb: var(--ion-text-color-rgb, $text-color-rgb-value) !default;
186+
$background-color: var(--ion-background-color, $background-color-value);
187+
$background-color-rgb: var(--ion-background-color-rgb, $background-color-rgb-value);
188+
$text-color: var(--ion-text-color, $text-color-value);
189+
$text-color-rgb: var(--ion-text-color-rgb, $text-color-rgb-value);
190190
```
191191

192192
```scss
193193
// ionic.theme.default.ios.scss
194194

195-
$backdrop-ios-color: var(--ion-backdrop-color, #000) !default;
196-
$overlay-ios-background-color: var(--ion-overlay-background-color, var(--ion-color-step-100, #f9f9f9)) !default;
195+
$backdrop-ios-color: var(--ion-backdrop-color, #000);
196+
$overlay-ios-background-color: var(--ion-overlay-background-color, var(--ion-color-step-100, #f9f9f9));
197197
```
198198

199199
#### ✅ Reusable values
@@ -216,10 +216,10 @@ Example of reusable values:
216216
// alert.ios.vars.scss
217217

218218
/// @prop - Padding end of the alert head
219-
$alert-ios-head-padding-end: 16px !default;
219+
$alert-ios-head-padding-end: 16px;
220220

221221
/// @prop - Padding start of the alert head
222-
$alert-ios-head-padding-start: $alert-ios-head-padding-end !default;
222+
$alert-ios-head-padding-start: $alert-ios-head-padding-end;
223223
```
224224

225225
```scss
@@ -248,10 +248,10 @@ $alert-ios-head-padding-start: $alert-ios-head-padding-end !default;
248248
// alert.ios.vars.scss
249249

250250
/// @prop - Padding top of the alert head
251-
$alert-ios-head-padding-top: 12px !default;
251+
$alert-ios-head-padding-top: 12px;
252252

253253
/// @prop - Padding bottom of the alert head
254-
$alert-ios-head-padding-bottom: 7px !default;
254+
$alert-ios-head-padding-bottom: 7px;
255255
```
256256

257257
```scss
@@ -292,10 +292,10 @@ $global-md-item-padding-start: $global-md-item-padding-end;
292292
@import "../../themes/ionic.globals.md";
293293

294294
/// @prop - Padding end for the item content
295-
$item-md-padding-end: $global-md-item-padding-end !default;
295+
$item-md-padding-end: $global-md-item-padding-end;
296296

297297
/// @prop - Padding start for the item content
298-
$item-md-padding-start: $global-md-item-padding-start !default;
298+
$item-md-padding-start: $global-md-item-padding-start;
299299
```
300300

301301
```scss
@@ -304,10 +304,10 @@ $item-md-padding-start: $global-md-item-padding-start !default;
304304
@import "../../themes/ionic.globals.md";
305305

306306
/// @prop - Padding start for the divider
307-
$item-divider-md-padding-start: $global-md-item-padding-start !default;
307+
$item-divider-md-padding-start: $global-md-item-padding-start;
308308

309309
/// @prop - Padding end for the divider
310-
$item-divider-md-padding-end: $global-md-item-padding-end !default;
310+
$item-divider-md-padding-end: $global-md-item-padding-end;
311311
```
312312

313313
</td>
@@ -327,10 +327,10 @@ $item-divider-md-padding-end: $global-md-item-padding-end !default;
327327
@import "../../themes/ionic.globals.md";
328328

329329
/// @prop - Padding end for the item content
330-
$item-md-padding-end: 16px !default;
330+
$item-md-padding-end: 16px;
331331

332332
/// @prop - Padding start for the item content
333-
$item-md-padding-start: 16px !default;
333+
$item-md-padding-start: 16px;
334334
```
335335

336336
```scss
@@ -340,10 +340,10 @@ $item-md-padding-start: 16px !default;
340340
@import "../item/item.md.vars";
341341

342342
/// @prop - Padding start for the divider
343-
$item-divider-md-padding-start: $item-md-padding-start !default;
343+
$item-divider-md-padding-start: $item-md-padding-start;
344344

345345
/// @prop - Padding end for the divider
346-
$item-divider-md-padding-end: $item-md-padding-end !default;
346+
$item-divider-md-padding-end: $item-md-padding-end;
347347
```
348348

349349
</td>
@@ -370,7 +370,7 @@ $screen-breakpoints: (
370370
md: 768px,
371371
lg: 992px,
372372
xl: 1200px
373-
) !default;
373+
);
374374
```
375375

376376
#### ✅ Dynamic calculations
@@ -418,7 +418,7 @@ $chip-avatar-size: math.div(24em, $chip-base-font-size);
418418
// alert.vars.scss
419419

420420
/// @prop - Font size of the alert button
421-
$alert-button-font-size: dynamic-font(14px) !default;
421+
$alert-button-font-size: dynamic-font(14px);
422422
```
423423

424424
</td>
@@ -445,7 +445,7 @@ For example, the color of the label changes when focused in `md` mode. However,
445445
// label.md.vars.scss
446446

447447
/// @prop - Text color of the stacked/floating label when it is focused
448-
$label-md-text-color-focused: ion-color(primary, base) !default;
448+
$label-md-text-color-focused: ion-color(primary, base);
449449
```
450450

451451
```scss
@@ -474,7 +474,7 @@ $label-md-text-color-focused: ion-color(primary, base) !default;
474474
// label.ios.vars.scss
475475

476476
/// @prop - Text color of the stacked/floating label when it is focused
477-
$label-ios-text-color-focused: null !default;
477+
$label-ios-text-color-focused: null;
478478
```
479479

480480
```scss
@@ -526,7 +526,7 @@ A text alignment property should not be stored in a Sass variable, even if it is
526526
// action-sheet.ios.vars.scss
527527

528528
/// @prop - Text align of the action sheet
529-
$action-sheet-ios-text-align: center !default;
529+
$action-sheet-ios-text-align: center;
530530
```
531531

532532
```scss
@@ -588,10 +588,10 @@ Variables should not be used when they are structural changes of an element. Thi
588588
// alert.ios.vars.scss
589589

590590
/// @prop - Flex wrap of the alert button group
591-
$alert-ios-button-group-flex-wrap: wrap !default;
591+
$alert-ios-button-group-flex-wrap: wrap;
592592

593593
/// @prop - Flex of the alert button
594-
$alert-ios-button-flex: 1 1 auto !default;
594+
$alert-ios-button-flex: 1 1 auto;
595595
```
596596

597597
```scss
@@ -653,13 +653,13 @@ We shouldn't use variables for changing things such as `font-size` or `font-weig
653653
// action-sheet.ios.vars.scss
654654

655655
/// @prop - Font size of the action sheet title
656-
$action-sheet-ios-title-font-size: dynamic-font-min(1, 13px) !default;
656+
$action-sheet-ios-title-font-size: dynamic-font-min(1, 13px);
657657

658658
/// @prop - Font weight of the action sheet title
659-
$action-sheet-ios-title-font-weight: 400 !default;
659+
$action-sheet-ios-title-font-weight: 400;
660660

661661
/// @prop - Font size of the action sheet sub title
662-
$action-sheet-ios-sub-title-font-size: dynamic-font-min(1, 13px) !default;
662+
$action-sheet-ios-sub-title-font-size: dynamic-font-min(1, 13px);
663663
```
664664

665665
```scss

0 commit comments

Comments
 (0)