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

Positions single property support (like "relative: top -100px") #191

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions lib/nib/positions.styl
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@
i = 0
position: unquote(type)
{args[i]}: args[i + 1] is a 'unit' ? args[i += 1] : 0
{args[i += 1]}: args[i + 1] is a 'unit' ? args[i += 1] : 0
if args[i+1]
{args[i += 1]}: args[i + 1] is a 'unit' ? args[i += 1] : 0

/*
* Position utility.
*
* Synopsis:
*
* fixed: <pos> [n] <pos> [n]
* fixed: <pos> [n] [<pos> [n]]
*
* Examples:
*
* fixed: top
* fixed: top 5px
* fixed: top left
* fixed: top 5px left
* fixed: top left 5px
Expand All @@ -30,10 +33,12 @@ fixed()
*
* Synopsis:
*
* absolute: <pos> [n] <pos> [n]
* absolute: <pos> [n] [<pos> [n]]
*
* Examples:
*
* absolute: top
* absolute: top 5px
* absolute: top left
* absolute: top 5px left
* absolute: top left 5px
Expand All @@ -49,10 +54,12 @@ absolute()
*
* Synopsis:
*
* relative: <pos> [n] <pos> [n]
* relative: <pos> [n] [<pos> [n]]
*
* Examples:
*
* relative: top
* relative: top 5px
* relative: top left
* relative: top 5px left
* relative: top left 5px
Expand Down
24 changes: 21 additions & 3 deletions test/cases/absolute.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
#login {
position: absolute;
bottom: 0;
right: 0;
top: 0;
}
#login {
position: absolute;
top: 5px;
}
#login {
position: absolute;
top: 0;
left: 0;
}
#login {
position: absolute;
top: 5px;
left: 10px;
}
#login {
position: absolute;
top: 0;
left: 10px;
}
}
#login {
position: absolute;
top: 5px;
left: 0;
}
16 changes: 14 additions & 2 deletions test/cases/absolute.styl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@
@import 'nib/positions'

#login
absolute bottom right
absolute: top

#login
absolute top 5px left 10px
absolute: top 5px

#login
absolute: top left

#login
absolute: top 5px left 10px

#login
absolute: top left 10px

#login
absolute: top 5px left
20 changes: 14 additions & 6 deletions test/cases/fixed.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#login {
position: fixed;
bottom: 0;
right: 0;
top: 0;
}
#login {
position: fixed;
top: 5px;
}
#login {
position: fixed;
top: 0;
left: 0;
}
#login {
position: fixed;
Expand All @@ -10,11 +18,11 @@
}
#login {
position: fixed;
bottom: 0;
top: 0;
left: 10px;
}
#login {
position: fixed;
bottom: 10px;
right: 0;
}
top: 5px;
left: 0;
}
12 changes: 9 additions & 3 deletions test/cases/fixed.styl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@
@import 'nib/positions'

#login
fixed: bottom right
fixed: top

#login
fixed: top 5px

#login
fixed: top left

#login
fixed: top 5px left 10px

#login
fixed: bottom left 10px
fixed: top left 10px

#login
fixed: bottom 10px right
fixed: top 5px left
27 changes: 25 additions & 2 deletions test/cases/relative.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@

#login {
position: relative;
top: 0;
}
#login {
position: relative;
top: 5px;
}
#login {
position: relative;
top: 0;
left: 0;
}
#login {
position: relative;
top: 5px;
left: 10px;
}
}
#login {
position: relative;
top: 0;
left: 10px;
}
#login {
position: relative;
top: 5px;
left: 0;
}
20 changes: 20 additions & 0 deletions test/cases/relative.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

@import 'nib/positions'

#login
relative: top

#login
relative: top 5px

#login
relative: top left

#login
relative: top 5px left 10px

#login
relative: top left 10px

#login
relative: top 5px left