These are chat archives for LearnBoost/stylus

5th
Feb 2018
Mihal Malostanidis
@qm3ster
Feb 05 2018 19:06

@acidjazz I suspect you might be looking for

$gap = 3
.himstdve
  display flex 0 0 s('calc( 33% - unit(%s, px))',$gap)

which produces

.himstdve {
  display: flex 0 0 calc( 33% - unit(3, px));
}
kevin olson
@acidjazz
Feb 05 2018 19:06
thanks ill give it a shot
Mihal Malostanidis
@qm3ster
Feb 05 2018 19:06
WOW
were you sitting here all along
wtf
kevin olson
@acidjazz
Feb 05 2018 19:06
12 days
Mihal Malostanidis
@qm3ster
Feb 05 2018 19:07
Since the unit is static I actually recommend
$gap = 3
.himstdve
  display flex 0 0 s('calc( 33% - %spx)',$gap)
Reminds me of my younger days when I made this function:
interpolate(value_small, value_large, breakpoint_small, breakpoint_large)
  u = unit
  output_unit = u(value_small)
  unless output_unit == u(value_large) and output_unit == u(breakpoint_small) and output_unit == u(breakpoint_large)
    error('Different units')
  v_s = u(value_small, '')
  v_l = u(value_large, '')
  b_s = u(breakpoint_small, '')
  b_l = u(breakpoint_large, '')
  num_vw = 100 * (v_l - v_s) / (b_l - b_s)
  num_const = v_s + b_s * (v_s - v_l) / (b_l - b_s)
  return 'calc(%s + %s)' % (u(num_vw, vw) u(num_const, output_unit))
Mihal Malostanidis
@qm3ster
Feb 05 2018 19:21
@acidjazz peep the second version so your output files aren't doing unit for no reason.

You could use stylus' unit function, but there's no reason that I know of:

$gap = 0
.himstdve
  display flex 0 0 s('calc(33% - %s)', unit($gap, px))

For example, with a gap size of 0 i still outputs a filthy calc(33% - 0px) instead of calc(33% - 0).
Imagine automatically outputting calc(33%) or 33%!!!
Maybe with PostCSS