vitalets / react-native-extended-stylesheet

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

Variables don't support division #37

Closed joemckie closed 7 years ago

joemckie commented 7 years ago

Is there currently any way to implement division with a variable? Take the following example which creates a label with rounded sides:

const styles = EStyleSheet.create({
  label: {
    $height: 30,
    borderRadius: '$height / 2',
    height: '$height',
  }
});

This is throwing an error that says $height / 2 is an unresolved variable. The docs also suggest that division isn't implemented.

Is there a reason for that or is it just unimplemented? I could take a look into it if there's nothing blocking it.

vitalets commented 7 years ago

hi @joemckie

It seems redundant because we can replace division with multiply:

const styles = EStyleSheet.create({
  label: {
    $height: 30,
    borderRadius: '$height * 0.5',
    height: '$height',
  }
});
joemckie commented 7 years ago

Hmm... true. It is a little confusing that it initially appears to be broken though. If it won't be implemented perhaps it needs to be made clearer in the docs? On Wed, 12 Apr 2017 at 09:40, Vitaliy Potapov notifications@github.com wrote:

hi @joemckie https://github.com/joemckie

It seems redundant because we can replace division with multiply:

const styles = EStyleSheet.create({ label: { $height: 30, borderRadius: '$height * 0.5', height: '$height', } });

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/vitalets/react-native-extended-stylesheet/issues/37#issuecomment-293499160, or mute the thread https://github.com/notifications/unsubscribe-auth/AEv_ighQHZRvwNIoaaVUN_dxjSmb45ioks5rvH_8gaJpZM4M7DjC .

vitalets commented 7 years ago

Agree. Now will add to docs. Also just looked on code, it seems rather cheap to support division. I think it's better as nobody read docs :)

joemckie commented 7 years ago

Yeah I agree, it seems weird to not implement it, even if it does just coerce / 2 to * 0.5 behind the scenes. :) On Wed, 12 Apr 2017 at 10:36, Vitaliy Potapov notifications@github.com wrote:

Agree. Now will add to docs. Also just looked on code, it seems rather cheap to support division. I think it's better as nobody read docs :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/vitalets/react-native-extended-stylesheet/issues/37#issuecomment-293511280, or mute the thread https://github.com/notifications/unsubscribe-auth/AEv_iqbt90_TbwMucP8pvcpWl5_JUJ2fks5rvI0hgaJpZM4M7DjC .