parse
Parses a condition from a string.
Length conditions are specified as <type>: <value>[<unit>], where:
- <type>can be- min-width,- max-width,- min-heightor- max-height
- <value>is a fractional number
- <unit>can be- px,- ptor- sp
If the unit is omitted, px is assumed.
See ctor@BreakpointCondition.new_length.
Examples:
- min-width: 500px
- min-height: 400pt
- max-width: 100sp
- max-height: 500
Ratio conditions are specified as <type>: <width>[/<height>], where:
- <type>can be- min-aspect-ratioor- max-aspect-ratio
- <width>and- <height>are integer numbers
See ctor@BreakpointCondition.new_ratio.
The ratio is represented as <width> divided by <height>.
If <height> is omitted, it's assumed to be 1.
Examples:
- min-aspect-ratio: 4/3
- max-aspect-ratio: 1
The logical operators and, or can be used to compose a complex condition as follows:
- <condition> and <condition>: the condition is true when both- <condition>s are true, same as when using ctor@BreakpointCondition.new_and
- <condition> or <condition>: the condition is true when either of the- <condition>s is true, same as when using ctor@BreakpointCondition.new_or
Examples:
- min-width: 400px and max-aspect-ratio: 4/3
- max-width: 360sp or max-width: 360px
Conditions can be further nested using parentheses, for example:
- min-width: 400px and (max-aspect-ratio: 4/3 or max-height: 400px)
If parentheses are omitted, the first operator takes priority.
Return
the parsed condition
Since
1.4
Parameters
the string specifying the condition