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

Support time, frequency and resolution units #1167

Closed
xzyfer opened this issue May 6, 2015 · 2 comments
Closed

Support time, frequency and resolution units #1167

xzyfer opened this issue May 6, 2015 · 2 comments

Comments

@xzyfer
Copy link
Contributor

xzyfer commented May 6, 2015

We currently do not support the following units

  • s Seconds.
  • ms Milliseconds. There are 1000 milliseconds in a second.
  • Hz Hertz. It represents the number of occurrences per second.
  • kHz KiloHertz. A kiloHertz is 1000 Hertz.
  • dpi dots per inch
  • dpcm dots per centimeter
  • dppx dots per ‘px’ unit

Source http://www.w3.org/TR/css3-values/#other-units

a {
  b: 3s + 101ms; }

Ruby Sass

a {
  b: 3.101s; }

Libsass

Incompatible units: 'ms' and 's'. on line 2 at column 6
@xzyfer xzyfer self-assigned this May 6, 2015
@xzyfer xzyfer added this to the 3.2.3 milestone May 6, 2015
@davidkpiano
Copy link

Relevant: https://github.com/sass/sass/blob/d26e6fa17f55d64278c9f09b5ace5e256e363e3f/lib/sass/script/value/number.rb#L329 and https://github.com/sass/sass/blob/d26e6fa17f55d64278c9f09b5ace5e256e363e3f/lib/sass/script/value/number.rb#L450

    # This is the source data for all the unit logic. It's pre-processed to make
    # it efficient to figure out whether a set of units is mutually compatible
    # and what the conversion ratio is between two units.
    #
    # These come from http://www.w3.org/TR/2012/WD-css3-values-20120308/.
    relative_sizes = [
      {
        'in' => Rational(1),
        'cm' => Rational(1, 2.54),
        'pc' => Rational(1, 6),
        'mm' => Rational(1, 25.4),
        'pt' => Rational(1, 72),
        'px' => Rational(1, 96)
      },
      {
        'deg'  => Rational(1, 360),
        'grad' => Rational(1, 400),
        'rad'  => Rational(1, 2 * Math::PI),
        'turn' => Rational(1)
      },
      {
        's'  => Rational(1),
        'ms' => Rational(1, 1000)
      },
      {
        'Hz'  => Rational(1),
        'kHz' => Rational(1000)
      },
      {
        'dpi'  => Rational(1),
        'dpcm' => Rational(1, 2.54),
        'dppx' => Rational(1, 96)
      }
    ]

Mutually compatible units should be coerced to the unit in the first operand -- that's the behavior in Ruby Sass.

@mgreter mgreter assigned mgreter and unassigned xzyfer May 7, 2015
@mgreter
Copy link
Contributor

mgreter commented May 7, 2015

I have a half backed branch around for this. Thought to include it with the other number related refactoring! Let me see if I get something working in a few hours!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants