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

Style using CSS Modules #36

Merged
merged 14 commits into from
Apr 16, 2018
Merged

Style using CSS Modules #36

merged 14 commits into from
Apr 16, 2018

Conversation

hypest
Copy link
Contributor

@hypest hypest commented Apr 12, 2018

Start using SASS to define the styling of the views.

This solution is based on https://github.com/kristerkari/react-native-css-modules.
The idea here is to eventually be able to load the .scss files from the GB sourcetree, ideally with only some modifications/specializations.

  • The core/code block is styled with setting font-family to monospace. See here.
  • The Jest tests don't support the CSS module loading (yet, hopefully) so, mocking the CSS modules for now
  • On the Gutenberg code tree side, the styles are specialized by defining .native.scss versions of the SASS files

@hypest hypest requested a review from maxme April 12, 2018 20:30
@maxme maxme self-assigned this Apr 16, 2018
@maxme
Copy link
Contributor

maxme commented Apr 16, 2018

I just noticed font: monospace is not working on iOS. I get the following error:

Unrecognized font family 'monospace'

+[RCTFont updateFont:withFamily:size:weight:style:variant:scaleMultiplier:]
    RCTFont.mm:295
-[RCTFontAttributes updateFont]
-[RCTFontAttributes setFontFamily:]

Here is a list of the stock fonts by platform. I think it should be Courrier or Courrier New for iOS.

@maxme
Copy link
Contributor

maxme commented Apr 16, 2018

Should we export the style from block-management/toolbar.js to a .scss file?

@@ -0,0 +1,20 @@
.container {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should maybe start adding /** @format */ to style files. And check/format them with prettier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! Done with 686c0a3.

.babelrc Outdated
[
"react-native-platform-specific-extensions",
{
"extensions": ["native.scss", "css", "scss", "sass"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Are ios.scss and android.scss missing from this list?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, there is no need for the native.scss anyway so, removed with 74c88a6.

hypest added 2 commits April 16, 2018 13:01
Platform-specific file resolution is not yet supported by the
react-native-sass-transformer so, just use a common denominator.
`monospace` is not supported on iO so, for now just use `courier` which
is common between the platforms.
@hypest
Copy link
Contributor Author

hypest commented Apr 16, 2018

I think it should be Courrier or Courrier New for iOS.

I changed monospace to courier as the common denominator with 05b1dd8. We can't have platform-specific files yet so, just using what's common between the platforms for now.

Should we export the style from block-management/toolbar.js to a .scss file?

Done with 8d0821b for completeness.

Will work on the rest of the feedback.

hypest added 3 commits April 16, 2018 14:08
Notice the code duplication between the block-holder.android.scss and
block-holder.ios.scss files. This is needed because platform specific
scss @import statements are not supported yet.
Since Flow+Haste can't properly resolve the platform-specific CSS
Modules.
@hypest hypest force-pushed the feature/style-sass branch from df60449 to dd23ef4 Compare April 16, 2018 12:14
@hypest
Copy link
Contributor Author

hypest commented Apr 16, 2018

Differentiated the platform specific font-family for the Code block with 583335d. Using monospace on Android and courier on iOS. Note: the implementation is not optimal since there is code (well, CSS) duplication in the block-holder style files. That will get fixed when the SCSS @import statements start to properly resolve the platform specific file if any.

In the meantime, Flow can't properly resolve the platform specific style files as well so, need to mock the module resolution for Flow too (see dd23ef4).

@hypest
Copy link
Contributor Author

hypest commented Apr 16, 2018

I think I addressed all the feedback so far @maxme , ready for another pass, thanks!

@maxme
Copy link
Contributor

maxme commented Apr 16, 2018

Something weird happens on iOS:

https://bia.is/s/PQRr/style-sass-ios.mov

Note: everything looks good in the master branch.

@hypest
Copy link
Contributor Author

hypest commented Apr 16, 2018

Something weird happens on iOS:

Fixed with 590fea5 @maxme .

It seems that `flex: 1` is not interpreted correctly (flexGrow ends up
0 which causes the list to effectively collapse on iOS. For some
reason, it doesn't cause a problem on Android).
@hypest hypest force-pushed the feature/style-sass branch from ccd5038 to 590fea5 Compare April 16, 2018 13:45
@maxme
Copy link
Contributor

maxme commented Apr 16, 2018

:shipit: :shipit: :shipit:!

@maxme maxme merged commit 92c08a9 into master Apr 16, 2018
@maxme maxme deleted the feature/style-sass branch April 16, 2018 15:10
hypest pushed a commit that referenced this pull request Nov 2, 2018
…ncy-installer-script-2

Removes a command that no longer exists from 'yarn clean:install'.
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.

2 participants