stylus / nib

Stylus mixins, utilities, components, and gradient image generation
http://stylus.github.io/nib
MIT License
1.9k stars 250 forks source link

-pos proposal #53

Open pgherveou opened 12 years ago

pgherveou commented 12 years ago

Hello TJ what do you think about adding this line of code to the position helper, most of the time when I use fixed or absolute I fix the top/bottom and stretch the element setting both right and left.


-pos(type, args)
  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 length(args) > i + 1
    {args[i += 1]}: args[i + 1] is a 'unit' ? args[i += 1] : 0

body
  fixed: top 0 right 5px left 5px
guybrush commented 12 years ago

+1

thats how my -pos looks like :D

-pos(type, args)
  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
  {args[i += 1]}: args[i + 1] is a 'unit' ? args[i += 1] : 0
  {args[i += 1]}: args[i + 1] is a 'unit' ? args[i += 1] : 0
pgherveou commented 12 years ago

I am new to stylus, so not sure about that but doesn't your solution add a null: 0 to the css if you don't specify the fourth argument ?

guybrush commented 12 years ago

you are right, my -pos is really just a quick hack without thinking about it - its only ok for me because i am defining all 4 positions everytime.

still +1 for this :D

maybe like that?

-pos(type, args)
  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 length(args) > i + 1
    {args[i += 1]}: args[i + 1] is a 'unit' ? args[i += 1] : 0
  if length(args) > i + 1
    {args[i += 1]}: args[i + 1] is a 'unit' ? args[i += 1] : 0