Skip to content

Instantly share code, notes, and snippets.

Evgeni Dmitriev thybzi

Block or report user

Report or block thybzi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View position.less
/**
* Apply position value, and 0 to 4 offset values
* Offsets (length or `auto`) are treated similar to `padding` value
* Any of offsets may be `null`, in that case it is counted but not used
* @example .position(absolute, 5px, 2px) // position: absolute, 5px for top and bottom, 2px for left and right
* @example .position(relative, 5px, 2px, 3px) // position: relative, top: 5px, bottom: 3px, 2px for left and right
* @example .position(fixed, 5px, 2px, null) // position: fixed, top: 5px, nothing for bottom, 2px for left and right
* @example .position(static) // applies just `position: static` (without any offsets)
*/
View position.styl
/**
* Set `position` property, as well as `top`, `right`, `bottom`, `left` properties
* After the first argument, accepts 1 to 4 additional args, ordered and working "as for padding"
* To skip any of values, set it to `null`
* @mixin
* @example position(absolute, 5px, 10px, 0, auto)
* @example position(absolute, 5px, null, 0, auto)
* @example position(fixed, 5px, 10px)
* @example position(fixed, 0)
*/
@thybzi
thybzi / less2styl.html
Last active Mar 7, 2016
less2styl (ivi style)
View less2styl.html
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<script>
function fade2rbga(match, color, percentage) {
return 'rgba(' + color + ', ' + (parseFloat(percentage) / 100) + ')';
}
function less2styl() {
@thybzi
thybzi / ostap.styl
Last active Feb 23, 2016
Ostap Bender: The Great Combinator (of Stylus): http://codepen.io/thybzi/pen/PZMPob
View ostap.styl
// Get both inverse and forward combinated subject and current selector
// Example: .parent > .curr + .subj, .parent > .subj + .curr
// If subj is omitted, get current selector combinated with itself
// Example: .parent > .curr + .curr
// Limitation: Fails if parent selector level contains more that one combinator
// Limitation: Nesting calls cause exception
combinate(comb, subj='^[-1..-1]')
parts = ('&' + pad-combinator(comb) + subj)
if subj != '^[-1..-1]'
push(parts, combinate-inv(comb, subj))
View combinate.styl
//**
//* Put CSS combinator between current selector and subj -- in direct and reversed order
//* Apply CSS rules block to resulting selector
//* Example output: .parent .curr + .subj, .parent .subj + .curr { color: red; }
//* Limitation: current selector must have a separent level in selector tree (e.g. & > .curr)
//* @param {string} subj Another selector to combinate with
//* @param {string='+'} comb CSS combinator (can be: '+', '~', '>' or ' ')
//*/
combinate(subj, comb='+')
scurr = selectors()[-1]
@thybzi
thybzi / types.styl
Last active Apr 28, 2016
Stylus detected types — for use with `typeof()` and `is a`: http://codepen.io/thybzi/pen/MKMGoK
View types.styl
/*! bool, null */
typeof() // -> "null"
typeof(null) // -> "null"
typeof(undefined) // -> "ident"
typeof(false) // -> "boolean"
typeof(no) // -> "ident"
/*! color */
typeof(#ff0000) // -> "rgba"
typeof(#f00) // -> "rgba"
You can’t perform that action at this time.