Skip to content

Commit 409525f

Browse files
author
carl@connectedbrains.com
committed
first draft for virtual
1 parent c092b08 commit 409525f

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

guides/_posts/2015-01-06-constraints.html

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
{% endhighlight %}
9292

9393
In the previous example, we're asking GSS to give the `#GSS` and `#cassowary` elements a width of 200px and we
94-
later ask cassowary to constraint the sum of these two element to be equal to 350px. In this case, one the the
94+
later declare a constraint for the sum of these two elements to be equal to 350px. In this case, one of these
9595
two constraints will not hold. As we'll see later in the documentation you can influence the constraints solving
9696
by given more intent to GSS about what you want. <a href="http://codepen.io/cbchouinard/pen/XJROdV" target="_blank">Live example.</a>
9797

@@ -119,12 +119,11 @@
119119
- `!strong`
120120
- `!require`
121121

122-
`!medium` is the default for all constraints when no strenght is explicitly
122+
`!medium` is the default for all constraints when no strenght is explicitly defined.
123123

124-
#### Strenghts example
125-
Using the [May or may not hold example](#mayofmaynothold) we saw previously, in this example will give
126-
more strenght to the `#GSS` and `#cassowary` elements to make sure they overcome the sum
127-
constraints. <a href="http://codepen.io/cbchouinard/pen/bNRbQg" target="_blank">Live example.</a>
124+
Using the [May or may not hold example](#mayofmaynothold) example we saw previously,
125+
we'll give in the following example more strenghts to the each individual `width` to
126+
make sure they overcome the sum constraints: <a href="http://codepen.io/cbchouinard/pen/bNRbQg" target="_blank">Live example.</a>
128127

129128

130129
#### !require strenght
@@ -154,7 +153,7 @@
154153

155154
### Constraints order
156155
Generally speaking, later constraint statements are more powerful than earlier ones. There could be exception
157-
to this behavior as well see in the following sections when using conditions.
156+
to this behavior as well see in the following sections.
158157

159158
Taking the [May or may not hold example](#mayofmaynothold) we saw previously, by changing the order you'll get a
160159
different result. <a href="http://codepen.io/cbchouinard/pen/rawBRr" target="_blank">Live example.</a>
@@ -173,13 +172,16 @@
173172

174173
{% endhighlight %}
175174

176-
Will the `#box` move or stretch to satisfy the last constraint? Again, the later constraint statements are more powerful than later ones, so the box's width would stretch. You can control this by either changing the order in which the constraints are declared or by using a `stay` like so:
175+
Will the `#box` move or stretch to satisfy the last constraint? Again, the later constraint statements are more
176+
powerful than later ones, so the box's width would stretch. You can control this by either changing the order in
177+
which the constraints are declared or by using a `stay` like so:
177178

178179
{% highlight css %}
179-
#box[left] >= 100;
180+
181+
#box[right] == ::window[right];
180182
#box[width] >= 100;
183+
#box[left] >= 100;
181184
@stay(#box[width]);
182-
#box[right] == ::window[right];
183185

184186
/* the #box's position will move */
185187
{% endhighlight %}
@@ -205,10 +207,9 @@
205207
I wish we could go non-linear, but we can't because math.
206208

207209
## Units of measurement
208-
Default unit in GSS are pixels. When omiting the unit, pixels will be use. GSS also supports the following units:
210+
Default unit in GSS are pixels. GSS also supports the following units:
209211

210212
{% highlight css %}
211-
#pixel[width] == 100px;
212213
#em[width] == 10em;
213214
#pourcentage[width] == 10%;
214215
{% endhighlight %}
@@ -647,11 +648,13 @@
647648
## Intrinsic values
648649

649650
When you want to constraint the position of an element GSS needs to know the dimension of the element. For example how could
650-
GSS position an element using the bottom-right property without knowing the height and width of the element.
651+
GSS position an element using the bottom-right property without knowing the height and width of that element.
651652

652-
One way to solve this, would be to constraint the dimension of the element. But what if it had text in it and what if that text was dynamic?
653+
One way to solve this, would be to constraint the dimension of the element. But what if it had text in it? You'll then need to know the
654+
exact width and height require to display the text. What if that text is dynamic?
653655

654-
GSS provides the `intrinsic-` properties to get the dimension of the element defined by the text occupying the element and/or the CSS styling the element.
656+
GSS provides the `intrinsic-` properties to get the dimension of the element defined by the text occupying the element and/or the
657+
CSS styling the element.
655658

656659
{% highlight css %}
657660

@@ -668,11 +671,11 @@
668671

669672
Once an intrinsic value is constrained on a property, GSS will not evaluate other constraints you define on the same property.
670673

671-
For example if we add a `width` constraint on `.SelectorA` this constraint will be ignored by GSS since `intrinsic-` have total
674+
For example if we add a `width` constraint on `.SelectorA` this constraint will be ignored by GSS since `intrinsic-*` have total
672675
precendence over all other constraints.
673676

674677
## Virtuals
675-
Virtuals are a very cool concept that allows you to constraints elements on virtual element that don't actually exists in the DOM.
678+
Virtuals are a very interesting concept that allows you to constraints elements against `virtual` element that don't actually exists in the DOM.
676679

677680

678681
{% highlight css %}
@@ -687,6 +690,6 @@
687690

688691
{% endhighlight %}
689692

690-
In this example we are constraining `#elmA` and `#elmB` against the virtual element. TODO - Live example
693+
In this example we are constraining `#elmA` and `#elmB` against the virtual element.
691694

692695
Virtuals are very handy with [VFL](/guides/vfl-guide).

0 commit comments

Comments
 (0)