Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): Media query support #10530

Draft
wants to merge 61 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
5552d65
feat(core): New parser for CSS selectors
CatchABus Apr 13, 2024
0f90fb9
fix: Invalid :not() nested selector parsing
CatchABus Apr 13, 2024
ef4a144
chore: Removed unneeded nullish coalescing operator
CatchABus Apr 13, 2024
2210ae6
fix: Pseudo-class :not() is not dynamic
CatchABus Apr 13, 2024
ed28c8e
feat: Added case-insensitivity support for attribute selectors
CatchABus Apr 13, 2024
2a9487e
fix: Added missing :not() selector change tracking and corrected dyna…
CatchABus Apr 13, 2024
d54e174
feat: Added support for ':is()' pseudo-class
CatchABus Apr 14, 2024
fdbad98
chore: Minor trace improvement
CatchABus Apr 14, 2024
2fca2f6
feat: Added support for pseudo-class selector list types
CatchABus Apr 14, 2024
0748746
feat: Proper functional pseudo-class specificity
CatchABus Apr 14, 2024
39e72da
fix: Added null-check for pseudo-class lookupSort calls
CatchABus Apr 14, 2024
12103ce
fix: Removed pseudo-class lookupSort override as it caused problems
CatchABus Apr 14, 2024
39acfca
feat: Proper dynamic state for functional pseudo-classes
CatchABus Apr 14, 2024
158751c
chore: Removed old css selector parser unused code
CatchABus Apr 14, 2024
3ba567c
chore: Base functional pseudo-class should be abstract
CatchABus Apr 14, 2024
a34b7de
chore: Removed unused method
CatchABus Apr 14, 2024
35b72cb
chore: Re-added the previously removed method
CatchABus Apr 14, 2024
55d2815
perf: Do not generate selector sequences for a single selectors
CatchABus Apr 15, 2024
aeb4fd3
feat: Added combinator support for pseudo-class selector list
CatchABus Apr 15, 2024
e36ce66
feat: Added support for CSS general sibling combination (~)
CatchABus Apr 16, 2024
4a7aa62
chore: Better CSS selector combinator readability
CatchABus Apr 16, 2024
dce0159
chore: Renaming selector arrays
CatchABus Apr 16, 2024
59b4c97
perf: Reduce the number of instances and arrays for complex selectors
CatchABus Apr 20, 2024
f965bfb
test: Added UI sample for general sibling selector
CatchABus Apr 20, 2024
15f4df6
test: Added unit tests for new pseudo-classes
CatchABus Apr 20, 2024
38f0367
chore: Minor comment correction
CatchABus Apr 20, 2024
a3f20cf
fix: Dependency css-what was missing from core
CatchABus Apr 20, 2024
21413fa
perf: Faster lookup for :is() and :where() that contain a single sele…
CatchABus Apr 30, 2024
d5b8fb1
Merge branch 'main' into css-selector-parser-rework
NathanWalker May 2, 2024
97d3bc7
chore: Added missing dependency to root
CatchABus May 2, 2024
82df947
chore: Moving new dependency to root dev deps
CatchABus May 2, 2024
872a0da
test: Added automated tests for new functional pseudo-classes
CatchABus May 5, 2024
ab928bf
feat: Experimental media query support
CatchABus Apr 23, 2024
6a89eae
feat: Media queries revalidation during layout change and support for…
CatchABus Apr 23, 2024
00800e2
fix: Media query rules incorrect position
CatchABus Apr 24, 2024
44c4109
fix: Android screen metrics were not updated in time during orientation
CatchABus Apr 24, 2024
05b4b6f
fix: Ensure css update orientation/appearance trigger for the case of…
CatchABus Apr 24, 2024
af7e7ec
chore: Better naming for applyCss parameter flag
CatchABus Apr 24, 2024
c0e29ed
ref: Solving the confusion of _keyframes value
CatchABus Apr 24, 2024
e662156
feat: Added support for nesting keyframes inside media queries
CatchABus Apr 24, 2024
be21262
fix: Keyframes memory leak
CatchABus Apr 26, 2024
ad50e0b
feat: MediaQueryList event listeners
CatchABus Apr 26, 2024
3ed1632
chore: Better naming for SelectorsMap class
CatchABus Apr 26, 2024
6230342
feat: Added scope support for css keyframes
CatchABus Apr 26, 2024
fe68dd9
feat: Added a new media query parser
CatchABus Apr 27, 2024
e80831a
ref: Split platform module to avoid circular deps
CatchABus Apr 27, 2024
90692eb
ref: Re-apply keyframes only to matching selectors
CatchABus Apr 27, 2024
a87ecf7
fix: Added missing CSS import handling
CatchABus Apr 27, 2024
1dd1852
fix: Live-sync should cleanup selectors and key frames if the last on…
CatchABus Apr 27, 2024
d1b185a
ref: Revert ScreenMetrics back to being an interface
CatchABus Apr 28, 2024
769ab86
fix: Prevent identical media queries from removing each other
CatchABus Apr 28, 2024
807d31b
perf: Avoid multiple validations for identical media queries
CatchABus Apr 28, 2024
80a64bc
chore: Renamed media-query module
CatchABus Apr 29, 2024
f982505
perf: Removed unneeded arrays created for media query scopes
CatchABus Apr 30, 2024
da978b2
fix: Some media query selectors skipped lookup
CatchABus Apr 30, 2024
80a73d8
ref: Better media query list error handling
CatchABus May 4, 2024
14e575c
ref: Improved media query feature handling
CatchABus May 4, 2024
c776605
test: Added unit tests for css-mediaquery
CatchABus May 4, 2024
0a5b10b
test: Added unit tests for media-query-list module
CatchABus May 5, 2024
db34187
ref: Renamed validateMediaQuery function
CatchABus May 5, 2024
5c21bda
test: Added unit tests for css media query-scoped selectors
CatchABus May 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
77 changes: 38 additions & 39 deletions apps/automated/src/ui/animation/css-animation-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ function createAnimationFromCSS(css: string, name: string): keyframeAnimation.Ke
const selector = findSelectorInScope(scope, name);
if (selector) {
const animation = scope.getAnimations(selector.ruleset)[0];

return animation;
}
}
Expand All @@ -40,7 +39,7 @@ export function test_ReadAnimationProperties() {
animation-direction: reverse;
animation-fill-mode: forwards;
}`,
'test'
'test',
);
TKUnit.assertEqual(animation.name, 'first');
TKUnit.assertEqual(animation.duration, 4000);
Expand All @@ -56,7 +55,7 @@ export function test_ReadTheAnimationProperty() {
`.test {
animation: second 0.2s ease-out 1s 2;
}`,
'test'
'test',
);
TKUnit.assertEqual(animation.name, 'second');
TKUnit.assertEqual(animation.duration, 200);
Expand All @@ -70,42 +69,42 @@ export function test_ReadAnimationCurve() {
`.test {
animation-timing-function: ease-in;
}`,
'test'
'test',
);
TKUnit.assertEqual(animation.curve, CoreTypes.AnimationCurve.easeIn);
animation = createAnimationFromCSS(
`.test {
animation-timing-function: ease-out;
}`,
'test'
'test',
);
TKUnit.assertEqual(animation.curve, CoreTypes.AnimationCurve.easeOut);
animation = createAnimationFromCSS(
`.test {
animation-timing-function: linear;
}`,
'test'
'test',
);
TKUnit.assertEqual(animation.curve, CoreTypes.AnimationCurve.linear);
animation = createAnimationFromCSS(
`.test {
animation-timing-function: ease-in-out;
}`,
'test'
'test',
);
TKUnit.assertEqual(animation.curve, CoreTypes.AnimationCurve.easeInOut);
animation = createAnimationFromCSS(
`.test {
animation-timing-function: spring;
}`,
'test'
'test',
);
TKUnit.assertEqual(animation.curve, CoreTypes.AnimationCurve.spring);
animation = createAnimationFromCSS(
`.test {
animation-timing-function: cubic-bezier(0.1, 1.0, 0.5, 0.5);
}`,
'test'
'test',
);
let curve = animation.curve;
TKUnit.assert(curve.x1 === 0.1 && curve.y1 === 1.0 && curve.x2 === 0.5 && curve.y2 === 0.5);
Expand All @@ -116,14 +115,14 @@ export function test_ReadIterations() {
`.test {
animation-iteration-count: 5;
}`,
'test'
'test',
);
TKUnit.assertEqual(animation.iterations, 5);
animation = createAnimationFromCSS(
`.test {
animation-iteration-count: infinite;
}`,
'test'
'test',
);
TKUnit.assertEqual(animation.iterations, Number.POSITIVE_INFINITY);
}
Expand All @@ -133,21 +132,21 @@ export function test_ReadFillMode() {
`.test {
animation-iteration-count: 5;
}`,
'test'
'test',
);
TKUnit.assertFalse(animation.isForwards);
animation = createAnimationFromCSS(
`.test {
animation-fill-mode: forwards;
}`,
'test'
'test',
);
TKUnit.assertTrue(animation.isForwards);
animation = createAnimationFromCSS(
`.test {
animation-fill-mode: backwards;
}`,
'test'
'test',
);
TKUnit.assertFalse(animation.isForwards);
}
Expand All @@ -157,21 +156,21 @@ export function test_ReadDirection() {
`.test {
animation-iteration-count: 5;
}`,
'test'
'test',
);
TKUnit.assertFalse(animation.isReverse);
animation = createAnimationFromCSS(
`.test {
animation-direction: reverse;
}`,
'test'
'test',
);
TKUnit.assertTrue(animation.isReverse);
animation = createAnimationFromCSS(
`.test {
animation-direction: normal;
}`,
'test'
'test',
);
TKUnit.assertFalse(animation.isReverse);
}
Expand All @@ -183,7 +182,7 @@ export function test_ReadKeyframe() {
from { background-color: red; }
to { background-color: blue; }
}`,
'test'
'test',
);
TKUnit.assert(animation !== undefined, 'CSS selector was not created!');
TKUnit.assertEqual(animation.name, 'test', 'Wrong animation name!');
Expand All @@ -200,7 +199,7 @@ export function test_ReadTransformAllSet() {
@keyframes test {
to { transform: rotate(10) scaleX(5) translate(100, 200); }
}`,
'test'
'test',
);
const { rotate, scale, translate } = getTransformsValues(animation.keyframes[0].declarations);

Expand All @@ -219,7 +218,7 @@ export function test_ReadTransformNone() {
@keyframes test {
to { transform: none; }
}`,
'test'
'test',
);
const { rotate, scale, translate } = getTransformsValues(animation.keyframes[0].declarations);

Expand All @@ -238,7 +237,7 @@ export function test_ReadScale() {
@keyframes test {
to { transform: scale(-5, 12.3pt); }
}`,
'test'
'test',
);
const { scale } = getTransforms(animation.keyframes[0].declarations);

Expand All @@ -253,7 +252,7 @@ export function test_ReadScaleSingle() {
@keyframes test {
to { transform: scale(2); }
}`,
'test'
'test',
);
const { scale } = getTransforms(animation.keyframes[0].declarations);

Expand All @@ -268,7 +267,7 @@ export function test_ReadScaleXY() {
@keyframes test {
to { transform: scaleX(5) scaleY(10); }
}`,
'test'
'test',
);
const { scale } = getTransforms(animation.keyframes[0].declarations);

Expand All @@ -283,7 +282,7 @@ export function test_ReadScaleX() {
@keyframes test {
to { transform: scaleX(12.5); }
}`,
'test'
'test',
);
const { scale } = getTransforms(animation.keyframes[0].declarations);

Expand All @@ -299,7 +298,7 @@ export function test_ReadScaleY() {
@keyframes test {
to { transform: scaleY(10); }
}`,
'test'
'test',
);
const { scale } = getTransforms(animation.keyframes[0].declarations);

Expand All @@ -315,7 +314,7 @@ export function test_ReadScale3d() {
@keyframes test {
to { transform: scale3d(10, 20, 30); }
}`,
'test'
'test',
);
const { scale } = getTransforms(animation.keyframes[0].declarations);

Expand All @@ -330,7 +329,7 @@ export function test_ReadTranslate() {
@keyframes test {
to { transform: translate(100, 20); }
}`,
'test'
'test',
);
const { translate } = getTransforms(animation.keyframes[0].declarations);

Expand All @@ -345,7 +344,7 @@ export function test_ReadTranslateSingle() {
@keyframes test {
to { transform: translate(30); }
}`,
'test'
'test',
);
const { translate } = getTransforms(animation.keyframes[0].declarations);

Expand All @@ -360,7 +359,7 @@ export function test_ReadTranslateXY() {
@keyframes test {
to { transform: translateX(5) translateY(10); }
}`,
'test'
'test',
);
const { translate } = getTransforms(animation.keyframes[0].declarations);

Expand All @@ -375,7 +374,7 @@ export function test_ReadTranslateX() {
@keyframes test {
to { transform: translateX(12.5); }
}`,
'test'
'test',
);
const { translate } = getTransforms(animation.keyframes[0].declarations);

Expand All @@ -391,7 +390,7 @@ export function test_ReadTranslateY() {
@keyframes test {
to { transform: translateY(10); }
}`,
'test'
'test',
);
const { translate } = getTransforms(animation.keyframes[0].declarations);

Expand All @@ -407,7 +406,7 @@ export function test_ReadTranslate3d() {
@keyframes test {
to { transform: translate3d(10, 20, 30); }
}`,
'test'
'test',
);
const { translate } = getTransforms(animation.keyframes[0].declarations);

Expand All @@ -422,7 +421,7 @@ export function test_ReadRotate() {
@keyframes test {
to { transform: rotate(5); }
}`,
'test'
'test',
);
const { rotate } = getTransforms(animation.keyframes[0].declarations);

Expand All @@ -436,7 +435,7 @@ export function test_ReadRotateDeg() {
@keyframes test {
to { transform: rotate(45deg); }
}`,
'test'
'test',
);
const { rotate } = getTransforms(animation.keyframes[0].declarations);

Expand All @@ -450,7 +449,7 @@ export function test_ReadRotateRad() {
@keyframes test {
to { transform: rotate(0.7853981634rad); }
}`,
'test'
'test',
);
const { rotate } = getTransforms(animation.keyframes[0].declarations);

Expand All @@ -467,7 +466,7 @@ export function test_ReadAnimationWithUnsortedKeyframes() {
40%, 80% { opacity: 0.3; }
to { opacity: 1; }
}`,
'test'
'test',
);
TKUnit.assertEqual(animation.keyframes.length, 6);
TKUnit.assertEqual(animation.keyframes[0].declarations[0].value, 0);
Expand Down Expand Up @@ -502,7 +501,7 @@ export function test_LoadTwoAnimationsWithTheSameName() {
from { opacity: 0; }
to { opacity: 0.5; } /* this should override the previous one */
}`,
'a'
'a',
);
TKUnit.assertEqual(animation.keyframes.length, 2);
TKUnit.assertEqual(animation.keyframes[1].declarations[0].value, 0.5);
Expand All @@ -520,7 +519,7 @@ export function test_LoadTwoAnimationsWithTheSameName() {
from { opacity: 0; }
to { opacity: 1; }
}`,
'a'
'a',
);

TKUnit.assertEqual(animation2.keyframes.length, 2);
Expand Down Expand Up @@ -615,7 +614,7 @@ export function test_AnimationCurveInKeyframes() {
50% { background-color: green; }
to { background-color: black; }
}`,
'test'
'test',
);

TKUnit.assertEqual(animation.keyframes[0].curve, CoreTypes.AnimationCurve.linear);
Expand Down