Skip to content

Commit 3e8a888

Browse files
committed
feat(css): add new display css classes and test
1 parent cd836a3 commit 3e8a888

File tree

2 files changed

+81
-2
lines changed

2 files changed

+81
-2
lines changed

core/src/css/display.scss

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
@import "../themes/ionic.mixins";
33

44
// Display
5-
// --------------------------------------------------
6-
// Modifies display of a particular element based on the given classes
5+
// ------------------------------------------------------------------
6+
// Provides utility classes to control the CSS display property
7+
// of elements. Includes responsive variants for toggling between
8+
// block, inline, flex, grid, and other display values at different
9+
// breakpoints.
710

11+
// TODO(FW-6697): remove ion-hide-* classes in favor of the new
12+
// ion-display-* classes
813
.ion-hide {
914
display: none !important;
1015
}
@@ -29,3 +34,29 @@
2934
}
3035
}
3136
}
37+
38+
$display-values: (
39+
none,
40+
inline,
41+
inline-block,
42+
block,
43+
flex,
44+
inline-flex,
45+
grid,
46+
inline-grid,
47+
table,
48+
table-cell,
49+
table-row
50+
);
51+
52+
@each $display in $display-values {
53+
@each $breakpoint in map-keys($screen-breakpoints) {
54+
$infix: breakpoint-infix($breakpoint, $screen-breakpoints);
55+
56+
@include media-breakpoint-up($breakpoint, $screen-breakpoints) {
57+
.ion-display#{$infix}-#{$display} {
58+
display: #{$display} !important;
59+
}
60+
}
61+
}
62+
}

core/src/css/test/display.e2e.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { test, expect } from '@playwright/test';
2+
import fs from 'fs';
3+
import path from 'path';
4+
5+
test.describe('display css utility classes', () => {
6+
let css: string;
7+
8+
test.beforeAll(() => {
9+
css = fs.readFileSync(path.resolve(__dirname, '../../../css/display.css'), 'utf8');
10+
});
11+
12+
const INFIXES = ['', '-sm', '-md', '-lg', '-xl'];
13+
14+
// TODO(FW-6697): remove `ion-hide classes` test
15+
test('ion-hide classes', () => {
16+
expect(css).toContain('.ion-hide');
17+
18+
const values = ['up', 'down'];
19+
20+
for (const value of values) {
21+
for (const infix of INFIXES) {
22+
expect(css).toContain(`.ion-hide${infix}-${value}`);
23+
}
24+
}
25+
});
26+
27+
test('ion-display classes', () => {
28+
const values = [
29+
'none',
30+
'inline',
31+
'inline-block',
32+
'block',
33+
'flex',
34+
'inline-flex',
35+
'grid',
36+
'inline-grid',
37+
'table',
38+
'table-cell',
39+
'table-row',
40+
];
41+
42+
for (const value of values) {
43+
for (const infix of INFIXES) {
44+
expect(css).toContain(`.ion-display${infix}-${value}`);
45+
}
46+
}
47+
});
48+
});

0 commit comments

Comments
 (0)