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

Update "improve your measurement" section mobile design to match Figma #9832

Merged
merged 5 commits into from
Dec 10, 2024

Conversation

techanvil
Copy link
Collaborator

@techanvil techanvil commented Dec 6, 2024

Summary

Addresses issue:

Relevant technical choices

@benbowler updated 9 December 2024, reviewing and fixing tests and VRTs.

PR Author Checklist

  • My code is tested and passes existing unit tests.
  • My code has an appropriate set of unit tests which all pass.
  • My code is backward-compatible with WordPress 5.2 and PHP 7.4.
  • My code follows the WordPress coding standards.
  • My code has proper inline documentation.
  • I have added a QA Brief on the issue linked above.
  • I have signed the Contributor License Agreement (see https://cla.developers.google.com/).

Do not alter or remove anything below. The following sections will be managed by moderators only.

Code Reviewer Checklist

  • Run the code.
  • Ensure the acceptance criteria are satisfied.
  • Reassess the implementation with the IB.
  • Ensure no unrelated changes are included.
  • Ensure CI checks pass.
  • Check Storybook where applicable.
  • Ensure there is a QA Brief.
  • Ensure there are no unexpected significant changes to file sizes.

Merge Reviewer Checklist

  • Ensure the PR has the correct target branch.
  • Double-check that the PR is okay to be merged.
  • Ensure the corresponding issue has a ZenHub release assigned.
  • Add a changelog message to the issue.

@media (min-width: $bp-tablet) {
margin-left: 42px; // margin-left = 32px switch width + 10px margin-left of label.
}
margin: 6px 0 0 42px; // margin-left = 32px switch width + 10px margin-left of label.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use calc to do this instead of hard coding with a comment?

@benbowler benbowler marked this pull request as ready for review December 9, 2024 12:23
Copy link

github-actions bot commented Dec 9, 2024

Build files for 06417ac have been deleted.

Copy link
Collaborator Author

@techanvil techanvil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @benbowler, please see my comment about the use of calc() in this context.

@media (min-width: $bp-tablet) {
margin-left: 42px; // margin-left = 32px switch width + 10px margin-left of label.
}
margin: 6px 0 0 calc(32px + 10px);
Copy link
Collaborator Author

@techanvil techanvil Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is what @aaemnnosttv had in mind with his suggestion - using calc() to add two unnamed values isn't really an improvement on what we had before, it's less readable and introduces an unnecessary calc() to add two static values.

Unfortunately as things stand I don't see that we can use calc() to reference the values of the relevant element dimension/properties. We could do something like this to derive the value:

diff --git a/assets/sass/components/settings/_googlesitekit-settings-group.scss b/assets/sass/components/settings/_googlesitekit-settings-group.scss
index c1625f2fb2..1eade3778c 100644
--- a/assets/sass/components/settings/_googlesitekit-settings-group.scss
+++ b/assets/sass/components/settings/_googlesitekit-settings-group.scss
@@ -55,7 +55,7 @@
 			color: $c-surfaces-on-surface-variant;
 			flex-basis: 100%;
 			font-size: $fs-label-sm;
-			margin: 6px 0 0 calc(32px + 10px);
+			margin: 6px 0 0 $mdc-switch-track-width + $mdc-switch-label-margin-left;
 		}
 
 		.googlesitekit-analytics-enable-enhanced-measurement--loading {
diff --git a/assets/sass/config/_variables.scss b/assets/sass/config/_variables.scss
index e341c8792c..ef560d2231 100644
--- a/assets/sass/config/_variables.scss
+++ b/assets/sass/config/_variables.scss
@@ -308,6 +308,8 @@ $mdc-text-field-error: $c-utility-error;
 $mdc-text-field-placeholder-ink-color: $c-interactive-on-disable-container;
 $mdc-text-field-label: $c-interactive-on-disable-container;
 
+$mdc-switch-label-margin-left: 10px;
+
 // Custom max width for settings notice content
 $max-width-settings-notice-content: 1098px;
 
diff --git a/assets/sass/vendor/_mdc-switch.scss b/assets/sass/vendor/_mdc-switch.scss
index 0e0b0d0a7e..53b4a86ed7 100644
--- a/assets/sass/vendor/_mdc-switch.scss
+++ b/assets/sass/vendor/_mdc-switch.scss
@@ -40,7 +40,7 @@
 		font-size: $fs-body-md;
 		letter-spacing: $ls-s;
 		line-height: $lh-body-md;
-		margin-left: 10px;
+		margin-left: $mdc-switch-label-margin-left;
 	}
 
 	.mdc-switch__track {

$mdc-switch-track-width comes from the vendor's mixin and is defined here: https://github.com/material-components/material-components-web/blob/3a1767ea4da308dbee272763a377deff39cf0471/packages/mdc-switch/_variables.scss#L25

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @techanvil, I couldn't find those variables initially.

Copy link

Size Change: +128 B (+0.01%)

Total Size: 1.97 MB

Filename Size Change
./dist/assets/css/googlesitekit-admin-css-********************.min.css 61.7 kB +53 B (+0.09%)
./dist/assets/js/googlesitekit-modules-ads-********************.js 34.9 kB +30 B (+0.09%)
./dist/assets/js/googlesitekit-modules-analytics-4-********************.js 189 kB +45 B (+0.02%)
ℹ️ View Unchanged
Filename Size
./dist/assets/css/googlesitekit-adminbar-css-********************.min.css 11.8 kB
./dist/assets/css/googlesitekit-authorize-application-css-********************.min.css 846 B
./dist/assets/css/googlesitekit-wp-dashboard-css-********************.min.css 8.23 kB
./dist/assets/js/33-********************.js 2.76 kB
./dist/assets/js/34-********************.js 2.25 kB
./dist/assets/js/35-********************.js 3.64 kB
./dist/assets/js/36-********************.js 936 B
./dist/assets/js/37-********************.js 892 B
./dist/assets/js/38-********************.js 1.61 kB
./dist/assets/js/39-********************.js 1.57 kB
./dist/assets/js/40-********************.js 1.61 kB
./dist/assets/js/41-********************.js 1.59 kB
./dist/assets/js/42-********************.js 1.83 kB
./dist/assets/js/43-********************.js 3.12 kB
./dist/assets/js/analytics-advanced-tracking-********************.js 901 B
./dist/assets/js/googlesitekit-activation-********************.js 24 kB
./dist/assets/js/googlesitekit-ad-blocking-recovery-********************.js 54.4 kB
./dist/assets/js/googlesitekit-adminbar-********************.js 34.7 kB
./dist/assets/js/googlesitekit-api-********************.js 10.1 kB
./dist/assets/js/googlesitekit-components-gm2-********************.js 6.17 kB
./dist/assets/js/googlesitekit-components-gm3-********************.js 10.1 kB
./dist/assets/js/googlesitekit-consent-mode-********************.js 25.6 kB
./dist/assets/js/googlesitekit-data-********************.js 2.37 kB
./dist/assets/js/googlesitekit-datastore-forms-********************.js 8.97 kB
./dist/assets/js/googlesitekit-datastore-location-********************.js 2.08 kB
./dist/assets/js/googlesitekit-datastore-site-********************.js 20.1 kB
./dist/assets/js/googlesitekit-datastore-ui-********************.js 10 kB
./dist/assets/js/googlesitekit-datastore-user-********************.js 27.6 kB
./dist/assets/js/googlesitekit-entity-dashboard-********************.js 81.3 kB
./dist/assets/js/googlesitekit-events-provider-contact-form-7-********************.js 646 B
./dist/assets/js/googlesitekit-events-provider-easy-digital-downloads-********************.js 624 B
./dist/assets/js/googlesitekit-events-provider-mailchimp-********************.js 630 B
./dist/assets/js/googlesitekit-events-provider-ninja-forms-********************.js 712 B
./dist/assets/js/googlesitekit-events-provider-optin-monster-********************.js 675 B
./dist/assets/js/googlesitekit-events-provider-popup-maker-********************.js 634 B
./dist/assets/js/googlesitekit-events-provider-woocommerce-********************.js 657 B
./dist/assets/js/googlesitekit-events-provider-wpforms-********************.js 633 B
./dist/assets/js/googlesitekit-i18n-********************.js 3.93 kB
./dist/assets/js/googlesitekit-main-dashboard-********************.js 165 kB
./dist/assets/js/googlesitekit-metric-selection-********************.js 51.4 kB
./dist/assets/js/googlesitekit-modules-********************.js 22.1 kB
./dist/assets/js/googlesitekit-modules-adsense-********************.js 118 kB
./dist/assets/js/googlesitekit-modules-pagespeed-insights-********************.js 22.6 kB
./dist/assets/js/googlesitekit-modules-reader-revenue-manager-********************.js 43 kB
./dist/assets/js/googlesitekit-modules-search-console-********************.js 68.1 kB
./dist/assets/js/googlesitekit-modules-sign-in-with-google-********************.js 28.5 kB
./dist/assets/js/googlesitekit-modules-tagmanager-********************.js 32.1 kB
./dist/assets/js/googlesitekit-notifications-********************.js 35.7 kB
./dist/assets/js/googlesitekit-polyfills-********************.js 378 B
./dist/assets/js/googlesitekit-settings-********************.js 127 kB
./dist/assets/js/googlesitekit-splash-********************.js 68.9 kB
./dist/assets/js/googlesitekit-user-input-********************.js 44.1 kB
./dist/assets/js/googlesitekit-vendor-********************.js 322 kB
./dist/assets/js/googlesitekit-widgets-********************.js 101 kB
./dist/assets/js/googlesitekit-wp-dashboard-********************.js 63.1 kB
./dist/assets/js/runtime-********************.js 1.4 kB

compressed-size-action

Copy link
Collaborator Author

@techanvil techanvil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @benbowler, LGTM!

@techanvil techanvil merged commit bffad5d into develop Dec 10, 2024
21 of 22 checks passed
@techanvil techanvil deleted the enhancement/9830-measurement-section-mobile-poc branch December 10, 2024 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants