SassCalculation
A Sass calculation value.
These correspond to Sass calc()
, min()
, max()
, or clamp()
expressions.
See the Sass docs.
The Sass compiler simplifies these before sending them to custom functions: this means that if you
receive a SassCalculation
argument then it cannot be further simplified at compile time,
for example calc(20px + 30%)
.
The API here allows you to construct SassCalculation
s representing calc()
-type expressions
including invalid ones such as calc(20px, 30px)
as though you were writing a stylesheet. The
validity is checked – and the overall expression simplified – by the compiler when it receives the value.
Topics
Types
enum Kind
enum Kind
enum Operator
enum Operator
Arithmetic operators valid within Value.operation(_:_:_:)
.
Declaration
public enum Operator: Character
enum Value
enum Value
A subexpression of a SassCalculation
.
Declaration
public indirect enum Value: Hashable, Equatable, CustomStringConvertible
Initializers
init(calc: Value)
init(calc: Value)
init(kind: Kind, arguments: [Value])
init(kind: Kind, arguments: [Value])
Properties
var kind: Kind
var kind: Kind
var arguments: [Value]
var arguments: [Value]
The SassCalculation
’s arguments. The Sass specification says how many
are actually valid for each Kind
but this API does not check this.
Declaration
public let arguments: [Value]
Misc
static func ==(lhs: SassCalculation, rhs: SassCalculation) -> Bool
static func ==(lhs: SassCalculation, rhs: SassCalculation) -> Bool
Two SassCalculation
s are equal if they have the same kind and arguments.
There’s no attempt at simplification here – so calc(10px)
and calc(5px + 5px)
compare as different.
Declaration
public static func == (lhs: SassCalculation, rhs: SassCalculation) -> Bool
func accept<V, R>(visitor: V) -> R
func accept<V, R>(visitor: V) -> R
Take part in the SassValueVisitor
protocol.
Declaration
public override func accept<V, R>(visitor: V) throws -> R
where V: SassValueVisitor, R == V.ReturnType
var description: String
var description: String
func hash(into: inout Hasher)
func hash(into: inout Hasher)