Skip to content

Standardize scss import practices#9183

Merged
brad-decker merged 4 commits intodevelopfrom
update-import-locations
Aug 19, 2020
Merged

Standardize scss import practices#9183
brad-decker merged 4 commits intodevelopfrom
update-import-locations

Conversation

@brad-decker
Copy link
Copy Markdown
Contributor

  1. Rename the base 'index' scss files to be more descriptive
  2. separates ui/app component imports into their own files
  3. moves imports to their proper new location
  4. Alphabetizes imports in root files.

@brad-decker brad-decker force-pushed the update-import-locations branch 2 times, most recently from 6f7c79c to 64199a4 Compare August 11, 2020 16:37
@brad-decker brad-decker marked this pull request as ready for review August 11, 2020 17:07
@brad-decker brad-decker requested a review from a team as a code owner August 11, 2020 17:07
@brad-decker brad-decker requested a review from tmashuang August 11, 2020 17:07
@brad-decker brad-decker force-pushed the update-import-locations branch from 64199a4 to 7cdf7f7 Compare August 11, 2020 17:10
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [7cdf7f7]
Page Load Metrics (586 ± 51 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint289538146
domContentLoaded33072258510751
load33172458610751
domInteractive32972258410751

@tmashuang
Copy link
Copy Markdown
Contributor

Seems that some of the ordering mattered in a couple of places. A couple of the ones I found

Account Details Button Width

.hide-token-confirmation__button, .button width and padding over .account-details-modal__button width padding

Tx List Item tx category color

.list-item color over .transaction-list-item--unconfirmed' color`

Tx Details Speed Up and Cancel font size

.hide-token-confirmation__button, .button font-size over .transaction-list-item-details__header-button font-size

Send Token button on asset list item

button.scss font-size over .asset-list-item__send-token-button font-size
.hide-token-confirmation__button, .button display and width over .asset-list-item__send-token-button display and width

I think these are from the old design and can be removed?

Buy button width

.hide-token-confirmation__button, .button width over .eth-overview__button, .token-overview__button width

Would we just tack an !important for the individual cases?

@brad-decker
Copy link
Copy Markdown
Contributor Author

@tmashuang thank you for finding those! I'll go through and review why the import order caused this to break as it likely means we are relying on styles from unrelated files which most likely is causing more heartaches than fixing things.

@brad-decker
Copy link
Copy Markdown
Contributor Author

@tmashuang - we can avoid !important; by making our css selectors more specific, in this case .button and .hide-token-confirmation__button are equally specific they are both just a single class name. It's important to note that the way we are using BEM is actually making it so that our "nested" scss isn't really creating nested selectors.

.some-class {
  .child {
     font-size: 16px;
  }
}

compiles to

.some-class .child {
  font-size: 16px;
}

whereas

.some-class {
  &__child {
    font-size: 16px;
  }
}

compiles to

.some-class__child {
  font-size: 16px;
}

In some cases here I am adding an additional ampersand to get the nested effect

.some-class {
 & &__child {
  font-size: 16px;
 }
}

compiles to

.some-class .some-class__child {
  font-size: 16px;
}

as we would hope.

@brad-decker
Copy link
Copy Markdown
Contributor Author

I added a commit that resolves those specific issues. I'm looking through the extension now to see if i can find anymore. I did end up pulling out the mixins created ad-hoc in the buttons scss file and converted everywhere they were being used to consume the button component instead. These will likely need to be reviewed carefully for breaking changes

Copy link
Copy Markdown
Contributor

@tmashuang tmashuang Aug 18, 2020

Choose a reason for hiding this comment

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

Seems this changed the Close to move to a new line and to overlay the Basic and Advanced Gas tabs, which Selenium has a failed on.

Customize Gas Close modal text
Details

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good find, I fixed this issue for the choose recipients view on the send page, but missed it here. I'll apply the same fix there and get a revision up for you.

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [c3cfd91]
Page Load Metrics (568 ± 50 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint307937105
domContentLoaded34069156610551
load34269256810550
domInteractive34069156610551

@brad-decker brad-decker force-pushed the update-import-locations branch 2 times, most recently from 1198e1f to 70812b1 Compare August 18, 2020 19:53
1. Rename the base 'index' scss files to be more descriptive
2. separates ui/app component imports into their own files
3. moves imports to their proper new location
4. Alphabetizes imports in root files.
@brad-decker brad-decker force-pushed the update-import-locations branch from 70812b1 to cb449bb Compare August 18, 2020 20:40
@brad-decker brad-decker force-pushed the update-import-locations branch from cb449bb to e864ce6 Compare August 18, 2020 21:26
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [e864ce6]
Page Load Metrics (355 ± 49 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint287734105
domContentLoaded26259535410249
load26659735510249
domInteractive26259535310249

@brad-decker brad-decker requested a review from tmashuang August 18, 2020 22:55
@brad-decker
Copy link
Copy Markdown
Contributor Author

Ready for another look @tmashuang. Thank you 🙏

@brad-decker
Copy link
Copy Markdown
Contributor Author

As it turns out, not nesting CSS seems to be the philosophy of BEM. I can achieve the same specificity by changing & &__element to &__element .sub-block. Either or is fine for this work, but I'll be researching BEM and how we might codify our usage of it.

@import 'send/send';
@import 'settings/index';
@import 'token/index';
@import 'create-account/index';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
@import 'create-account/index';
@import 'create-account/index';
@import 'unlock-page/index;'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

whoops, rebase error. Thanks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed, and put in the proper order.

</Button>
</div>
</div>
)
Copy link
Copy Markdown
Contributor

@tmashuang tmashuang Aug 19, 2020

Choose a reason for hiding this comment

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

Above changes have centered and padded the About page's Links section

Before About page's link section
After About page's link section

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

On it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [cc17b9a]
Page Load Metrics (439 ± 61 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint287436105
domContentLoaded30166543712861
load30266743912861
domInteractive30166543712861

Copy link
Copy Markdown
Contributor

@tmashuang tmashuang left a comment

Choose a reason for hiding this comment

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

LGTM

@brad-decker brad-decker merged commit c04cb63 into develop Aug 19, 2020
@brad-decker brad-decker deleted the update-import-locations branch August 19, 2020 16:41
Gudahtt added a commit that referenced this pull request Aug 19, 2020
* origin/develop: (137 commits)
  Use @metamask/eslint-config@3.1.0 (#9275)
  Standardize scss import practices (#9183)
  Update ESLint shared config to v3 (#9274)
  Add lock icon to default networks (#9269)
  Adds toPrecisionWithoutTrailingZeros utility (#9270)
  Hide gas estimate on non-main network (#9189)
  Move the mascot component to its own directory (#9272)
  Use @metamask/controllers@2.0.5 (#9266)
  Fix padding, alignment of actionable-message; add left aligned story
  Code cleanup and simplification for actionable-message component
  Adds actionable message component and stories
  Fix lint issues (#9265)
  Fix prefer-destructuring issues (#9263)
  colocate confirm-decrypt-message page styles (#9252)
  Tidy up Migrator tests (#9264)
  Adds pulse loader component (#9259)
  Fix import/order issues (#9239)
  Fix radix issues (#9247)
  New info tooltip component (#9180)
  Improve scss naming
  ...
tmashuang added a commit that referenced this pull request Sep 1, 2020
tmashuang added a commit that referenced this pull request Sep 1, 2020
* Fix alignment of restore vault screen

Fixes #9324

Possibly missed when #9183 was merged. The issue is that the same classname is overridding the intended flex-direction.

https://github.com/MetaMask/metamask-extension/blob/46ba1ef1008d5111924132229c281a449ea1a13a/ui/app/css/itcss/components/newui-sections.scss#L98-L101
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