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

supported more css units #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

supported more css units #5

wants to merge 1 commit into from

Conversation

Jinjiang
Copy link
Contributor

Support more CSS units without native update.

Three updates together:

  1. css-units branch in weexteam/weex-styler
  2. weex-next branch in weexteam/weex-vue-loader
  3. jsfm-feature-css-units in jinjiang/weex

How it works: CSS value 100rem in <style> will be transformed into "100rem" by weex-styler and then 100 * CSS_UNIT.REM by weex-vue-loader. At the same time define global variable CSS_UNIT in JS Framework. So it works.

@Jinjiang
Copy link
Contributor Author

alibaba/weex#1894 related

Copy link
Contributor

@songsiqi songsiqi left a comment

Choose a reason for hiding this comment

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

OK. Please make sure that all css units in the list are supported by weex-vue-loader and jsfm.

Copy link
Contributor

@Hanks10100 Hanks10100 left a comment

Choose a reason for hiding this comment

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

Retain the style units in transformer is fine.

But only change the weex-loader may not support the CSS units very well. The real value of the style needs to be calculated in real time.

Consider this:

<div style="width: {{width}}; height: {{height}}"><div>
this.width = '32rem'
this.height = this.getHeight() / 25 + 'vh'

@Jinjiang
Copy link
Contributor Author

Just

this.width = 32 * CSS_UNIT.REM
this.height = this.getHeight() / 25 * CSS_UNIT.VH

is OK. The variable CSS_UNIT could be exposed to frontend developers

@Jinjiang
Copy link
Contributor Author

Another thing is at least we can make it happen before native render support these units. And maybe that's enough already.

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