Skip to content

Commit

Permalink
feat(TestRun): add success page animation
Browse files Browse the repository at this point in the history
  • Loading branch information
harunbleech committed Oct 21, 2024
1 parent 6151910 commit dbbcbca
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 33 deletions.
1 change: 1 addition & 0 deletions assets/animations/success-check.json

Large diffs are not rendered by default.

23 changes: 0 additions & 23 deletions components/test-run-empty/_style.scss

This file was deleted.

7 changes: 0 additions & 7 deletions components/test-run-empty/index.php

This file was deleted.

2 changes: 1 addition & 1 deletion components/test-run-page/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<?php vrts()->icon( 'arrow-down' ); ?>
</div>
<?php else : ?>
<?php vrts()->component( 'test-run-empty' ); ?>
<?php vrts()->component( 'test-run-success' ); ?>
<?php endif; ?>
</div>
</vrts-test-run-page>
37 changes: 37 additions & 0 deletions components/test-run-success/_style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.vrts-test-run-success {
display: block;
padding: 50px 20px;
border-top: 0;

&__inner {
margin-bottom: 1.5rem;
max-width: 600px;
margin-inline: auto;
}

&__lottie-player {
position: relative;
pointer-events: none;
display: flex;
align-items: center;
justify-content: center;
aspect-ratio: 10 / 8;
margin-top: calc(100% / (10 / 8) * 0.3 * -1);

svg {
position: absolute;
inset: 0;
}
}

&__content {
text-align: center;
margin-top: calc(100% / (10 / 8) * 0.3 * -1);

p {
font-size: 16px;
font-weight: 600;
margin: 0;
}
}
}
9 changes: 9 additions & 0 deletions components/test-run-success/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vrts-test-run-success class="vrts-test-run-success postbox">
<div class="vrts-test-run-success__inner">
<div class="vrts-test-run-success__lottie-player" vrts-lottie-player></div>
<div class="vrts-test-run-success__content">
<p><?php esc_html_e( 'Smooth sailing – no changes found!', 'visual-regression-tests' ); ?></p>
<p><?php esc_html_e( "You're good to go.", 'visual-regression-tests' ); ?></p>
</div>
</div>
</vrts-test-run-success>
32 changes: 32 additions & 0 deletions components/test-run-success/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import lottie from 'lottie-web/build/player/lottie_light';

class VrtsTestRunSuccess extends window.HTMLElement {
constructor() {
super();
this.resolveElements();
}

resolveElements() {
this.$lottiePlayer = this.querySelector( '[vrts-lottie-player]' );
}

connectedCallback() {
this.lottieAnimation = lottie.loadAnimation( {
path: `${ window.vrts_admin_vars.pluginUrl }/assets/animations/success-check.json`,
container: this.$lottiePlayer,
renderer: 'svg',
loop: false,
autoplay: true,
} );
}

disconnectedCallback() {
this.lottieAnimation.destroy();
}

loaAnimation() {
this.$lottiePlayer.play();
}
}

window.customElements.define( 'vrts-test-run-success', VrtsTestRunSuccess );
1 change: 1 addition & 0 deletions includes/features/class-enqueue-scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function enqueue_scripts() {
[
'rest_url' => esc_url_raw( rest_url( 'vrts/v1' ) ),
'rest_nonce' => wp_create_nonce( 'wp_rest' ),
'pluginUrl' => vrts()->get_plugin_url(),
'currentUserId' => get_current_user_id(),
'onboarding' => apply_filters( 'vrts_onboarding', null ),
]
Expand Down
9 changes: 8 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"a11y-dialog": "^8.1.1",
"dompurify": "^3.1.7",
"driver.js": "^1.3.1",
"iframe-resizer": "4.3"
"iframe-resizer": "4.3",
"lottie-web": "^5.12.2"
},
"devDependencies": {
"@wordpress/scripts": "^30.2.0",
Expand Down

0 comments on commit dbbcbca

Please sign in to comment.