Skip to content

Commit b717f37

Browse files
simeonoffdesig9steindidimmovaDilyana DimovaSisIvanova
authored
refactor(themes): use logical CSS properties (#11377)
* refactor(themes): use logical CSS props and values Co-authored-by: Marin Popov <[email protected]> Co-authored-by: Dilyana Yarabanova <[email protected]> Co-authored-by: Dilyana Dimova <[email protected]> Co-authored-by: Silvia Ivanova <[email protected]>
1 parent c1f63f8 commit b717f37

File tree

67 files changed

+823
-1045
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+823
-1045
lines changed

projects/igniteui-angular/migrations/migration-collection.json

+5
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@
115115
"version": "13.1.0",
116116
"description": "Updates Ignite UI for Angular from v13.0.x to v13.1.0",
117117
"factory": "./update-13_1_0"
118+
},
119+
"migration-24": {
120+
"version": "13.2.0",
121+
"description": "Updates Ignite UI for Angular from v13.1.x to v13.2.0",
122+
"factory": "./update-13_2_0"
118123
}
119124
}
120125
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "../../common/schema/theme-changes.schema.json",
3+
"changes": [
4+
{
5+
"name": "$direction",
6+
"remove": true,
7+
"owner": "core",
8+
"type": "property"
9+
}
10+
]
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import * as path from 'path';
2+
3+
import { EmptyTree } from '@angular-devkit/schematics';
4+
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
5+
6+
const version = '13.2.0';
7+
8+
describe(`Update to ${version}`, () => {
9+
let appTree: UnitTestTree;
10+
const schematicRunner = new SchematicTestRunner('ig-migrate', path.join(__dirname, '../migration-collection.json'));
11+
const configJson = {
12+
defaultProject: 'testProj',
13+
projects: {
14+
testProj: {
15+
sourceRoot: '/testSrc'
16+
}
17+
},
18+
schematics: {
19+
'@schematics/angular:component': {
20+
prefix: 'appPrefix'
21+
}
22+
}
23+
};
24+
25+
beforeEach(() => {
26+
appTree = new UnitTestTree(new EmptyTree());
27+
appTree.create('/angular.json', JSON.stringify(configJson));
28+
});
29+
30+
const migrationName = 'migration-24';
31+
32+
it('should remove the $direction prop from the core mixin', async () => {
33+
appTree.create(
34+
`/testSrc/appPrefix/component/test.component.scss`,
35+
`@include igniteui.core($direction: 'rtl');`
36+
);
37+
38+
const tree = await schematicRunner
39+
.runSchematicAsync(migrationName, {}, appTree)
40+
.toPromise();
41+
42+
expect(
43+
tree.readContent('/testSrc/appPrefix/component/test.component.scss')
44+
).toEqual(
45+
`@include igniteui.core();`
46+
);
47+
});
48+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {
2+
Rule,
3+
SchematicContext,
4+
Tree
5+
} from '@angular-devkit/schematics';
6+
import { UpdateChanges } from '../common/UpdateChanges';
7+
8+
const version = '13.2.0';
9+
10+
export default (): Rule => async (host: Tree, context: SchematicContext) => {
11+
context.logger.info(`Applying migration for Ignite UI for Angular to version ${version}`);
12+
const update = new UpdateChanges(__dirname, host, context);
13+
update.applyChanges();
14+
};

projects/igniteui-angular/src/lib/core/styles/base/_variables.scss

-3
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,6 @@ $theme-palette: (
126126
)
127127
) !default;
128128

129-
/// Determines the content direction.
130-
$direction: ltr !default;
131-
132129
/// Determines whether color-blind palettes are enabled.
133130
$enhanced-accessibility: false !default;
134131

projects/igniteui-angular/src/lib/core/styles/base/utilities/_functions.scss

-28
Original file line numberDiff line numberDiff line change
@@ -881,34 +881,6 @@ $p-test: palette(#fff, #000);
881881
@return $color;
882882
}
883883

884-
/// Returns $if param when global variable $directory
885-
/// is set to ltr otherwise returns $else.
886-
/// @param {*} $if - The value to be returned when $direction is set to ltr;
887-
/// @param {*} $else - The value to be returned when $direction is set to rtl;
888-
/// @example scss Set variable values based on $direction
889-
/// $left: if-ltr(left, right);
890-
/// $right: if-ltr(right, left);
891-
@function if-ltr($if, $else: null) {
892-
$dir: if(meta.global-variable-exists('direction'), $direction, 'ltr');
893-
894-
@if $dir != rtl {
895-
@return $if;
896-
} @else {
897-
@return $else;
898-
}
899-
}
900-
901-
/// Returns $if param when global variable $directory
902-
/// is set to rtl otherwise returns $else.
903-
/// @param {*} $if - The value to be returned when $direction is set to rtl;
904-
/// @param {*} $else - The value to be returned when $direction is set to ltr;
905-
/// @example scss Set variable values based on $direction
906-
/// $left: if-rtl(left, right);
907-
/// $right: if-rtl(right, left);
908-
@function if-rtl($if, $else: null) {
909-
@return if-ltr($else, $if);
910-
}
911-
912884
@function expand-shorthand($list) {
913885
$len: list.length($list);
914886

projects/igniteui-angular/src/lib/core/styles/base/utilities/_mixins.scss

-39
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@
1212
/// @author <a href="https://github.com/simeonoff" target="_blank">Simeon Simeonoff</a>
1313
////
1414

15-
/// @access private
16-
@mixin icon-w-margin($margin, $left) {
17-
> * {
18-
margin-#{$left}: $margin;
19-
20-
&:first-child {
21-
margin-#{$left}: 0;
22-
}
23-
}
24-
}
25-
2615
/// Hides the element from the DOM.
2716
/// @access public
2817
/// @example scss - Sample usage
@@ -425,34 +414,6 @@
425414
}
426415
}
427416

428-
/// Compiles the passed content to CSS only if
429-
/// the global $direction variable is set to 'ltr'.
430-
/// @example scss Include content only if $direction is set to ltr (default)
431-
/// @include if-ltr {
432-
/// margin-right: 8px;
433-
/// }
434-
@mixin if-ltr {
435-
$dir: if(meta.global-variable-exists('direction'), $direction, 'ltr');
436-
437-
@if $dir != 'rtl' {
438-
@content;
439-
}
440-
}
441-
442-
/// Compiles the passed content to CSS only if
443-
/// the global $direction variable is set to 'rtl'.
444-
/// @example scss Include content only if $direction is set to rtl
445-
/// @include if-rtl {
446-
/// margin-left: 8px;
447-
/// }
448-
@mixin if-rtl {
449-
$dir: if(meta.global-variable-exists('direction'), $direction, 'ltr');
450-
451-
@if $dir == 'rtl' {
452-
@content;
453-
}
454-
}
455-
456417
/// Truncates text at a specific number of lines
457418
/// @param {number|string} $lines - The number of lines to show
458419
/// @param {Boolean} $inline - Sets whether an element displays inline-box or box

projects/igniteui-angular/src/lib/core/styles/components/_common/_igx-vhelper.scss

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
/// @group themes
44
/// @access private
5-
$_right: if-ltr(right, left);
6-
75
%vhelper-display {
86
display: block;
97
overflow: auto;
@@ -13,7 +11,7 @@ $_right: if-ltr(right, left);
1311
%vhelper--vertical {
1412
position: absolute;
1513
top: 0;
16-
#{$_right}: 0;
14+
inset-inline-end: 0;
1715
}
1816

1917
%vhelper--horizontal {

projects/igniteui-angular/src/lib/core/styles/components/action-strip/_action-strip-theme.scss

+7-10
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@
7878

7979
$variant: map.get($theme, variant);
8080

81-
$left: if-ltr(left, right);
82-
$right: if-ltr(right, left);
83-
8481
%igx-action-strip-display {
8582
display: flex;
8683
align-items: center;
@@ -90,7 +87,7 @@
9087
height: 100%;
9188
pointer-events: none;
9289
top: 0;
93-
#{$left}: 0;
90+
inset-inline-start: 0;
9491
background: var-get($theme, 'background');
9592
color: inherit;
9693
padding: map.get($padding, 'comfortable');
@@ -139,18 +136,18 @@
139136
}
140137

141138
igx-icon + [igxLabel] {
142-
margin-#{$left}: rem(12px);
139+
margin-inline-start: rem(12px);
143140
}
144141

145142
&%igx-drop-down__item--cosy {
146143
igx-icon + [igxLabel] {
147-
margin-#{$left}: rem(10px);
144+
margin-inline-start: rem(10px);
148145
}
149146
}
150147

151148
&%igx-drop-down__item--compact {
152149
igx-icon + [igxLabel] {
153-
margin-#{$left}: rem(8px);
150+
margin-inline-start: rem(8px);
154151
}
155152
}
156153
}
@@ -180,7 +177,7 @@
180177
max-height: 36px;
181178

182179
&:last-child {
183-
margin-#{$right}: 0;
180+
margin-inline-end: 0;
184181
}
185182

186183
igx-icon {
@@ -200,10 +197,10 @@
200197

201198
%igx-action-strip__editing-actions {
202199
> [igxButton] {
203-
margin-#{$left}: rem(4px);
200+
margin-inline-start: rem(4px);
204201

205202
&:first-of-type {
206-
margin-#{$left}: 0;
203+
margin-inline-start: 0;
207204
}
208205
}
209206
}

projects/igniteui-angular/src/lib/core/styles/components/banner/_banner-theme.scss

+14-18
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,6 @@
7070
/// @requires var-get
7171
@mixin banner($theme) {
7272
@include css-vars($theme);
73-
74-
$left: if-ltr(left, right);
75-
$right: if-ltr(right, left);
76-
7773
$banner-padding: (
7874
comfortable: rem(8),
7975
cosy: rem(8),
@@ -88,10 +84,10 @@
8884
}
8985

9086
%igx-banner {
91-
padding-#{$right}: map.get($banner-padding, 'comfortable');
92-
padding-#{$left}: 0;
93-
padding-top: map.get($banner-padding, 'comfortable');
94-
padding-bottom: map.get($banner-padding, 'comfortable');
87+
padding-inline-start: 0;
88+
padding-inline-end: map.get($banner-padding, 'comfortable');
89+
padding-block-start: map.get($banner-padding, 'comfortable');
90+
padding-block-end: map.get($banner-padding, 'comfortable');
9591
background: var-get($theme, 'banner-background');
9692
align-items: center;
9793
position: relative;
@@ -104,27 +100,27 @@
104100
width: rem(40);
105101
min-width: rem(40);
106102
height: rem(40);
107-
margin-#{$left}: rem(16);
103+
margin-inline-start: rem(16);
108104
color: var-get($theme, 'banner-illustration-color');
109105
}
110106

111107
%igx-banner__border-top {
112-
border-top: 1px solid var-get($theme, 'banner-border-color');
113-
top: -1px
108+
border-block-start: 1px solid var-get($theme, 'banner-border-color');
109+
inset-block-start: -1px
114110
}
115111

116112
%igx-banner__border-bottom {
117-
border-bottom: 1px solid var-get($theme, 'banner-border-color');
118-
top: 0;
113+
border-block-end: 1px solid var-get($theme, 'banner-border-color');
114+
inset-block-start: 0;
119115
}
120116

121117
%igx-banner__text {
122118
color: var-get($theme, 'banner-message-color');
123119
flex: 1 0 0%;
124-
margin-#{$left}: rem(24);
120+
margin-inline-start: rem(24);
125121

126122
> * {
127-
margin-top: 0 !important;
123+
margin-block-start: 0 !important;
128124
}
129125
}
130126

@@ -139,7 +135,7 @@
139135
%igx-banner__message {
140136
min-width: rem(220);
141137
flex: 1 0 0%;
142-
margin-#{$right}: rem(90);
138+
margin-inline-end: rem(90);
143139
}
144140

145141
%igx-banner__row {
@@ -168,8 +164,8 @@
168164

169165
%igx-banner__text {
170166
@include type-style($type-scale, $message) {
171-
margin-top: 0;
172-
margin-bottom: 0;
167+
margin-block-start: 0;
168+
margin-block-end: 0;
173169
}
174170
}
175171
}

projects/igniteui-angular/src/lib/core/styles/components/bottom-nav/_bottom-nav-theme.scss

+7-7
Original file line numberDiff line numberDiff line change
@@ -109,23 +109,23 @@
109109
position: fixed;
110110
justify-content: center;
111111
align-items: center;
112-
left: 0;
113-
right: 0;
112+
inset-inline-start: 0;
113+
inset-inline-end: 0;
114114
height: $menu-height;
115115
background: var-get($theme, 'background');
116116
overflow: hidden;
117117
z-index: 8;
118118
}
119119

120120
%igx-bottom-nav-menu--top {
121-
top: 0;
122-
bottom: inherit;
121+
inset-block-start: 0;
122+
inset-block-end: inherit;
123123
box-shadow: var-get($theme, 'shadow');
124124
}
125125

126126
%igx-bottom-nav-menu--bottom {
127-
top: inherit;
128-
bottom: 0;
127+
inset-block-start: inherit;
128+
inset-block-end: 0;
129129
box-shadow: var-get($theme, 'shadow');
130130
}
131131

@@ -161,7 +161,7 @@
161161

162162
%igx-tab-label {
163163
@include ellipsis();
164-
padding-top: 4px;
164+
padding-block-start: rem(4px);
165165
max-width: 100%;
166166
text-align: center;
167167
transform: translateZ(0);

0 commit comments

Comments
 (0)