vitalets / react-native-extended-stylesheet

Extended StyleSheets for React Native
MIT License
2.93k stars 132 forks source link

Nested global variables #41

Closed lucasff closed 7 years ago

lucasff commented 7 years ago
EStyleSheet.build({
    dashboard: {
         $valueFontSize: 26 * fontScale,
    }
});

Currently, this is not possible because the check is against the first letter (charAt(0)). Say I want to use:

EStyleSheet.create({
    text: {
         fontSize: '16 * dashboard.$valueFontSize',
    }
});

Could we have this support?

vitalets commented 7 years ago

hi @lucasff ! Could you show the full example what do you expect? Thanks!

lucasff commented 7 years ago

@vitalets I updated my comment. Thanks!

vitalets commented 7 years ago

Hi @lucasff

$ should be used only in top level variable name, nested sub-variables can be without it.

Working example:

EStyleSheet.build({
    $dashboard: {
         valueFontSize: 26
    }
});

Usage in the component:

const styles = EStyleSheet.create({
    text: {
         fontSize: '16 * $dashboard.valueFontSize'
    }
});

Hope that helps. Sorry for late response.