Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Commit

Permalink
Refactored HTML5 text input addon
Browse files Browse the repository at this point in the history
Avoids upcoming SASS varialbe rescoping issues.
  • Loading branch information
hmps committed Nov 30, 2013
1 parent 185bfe6 commit 56f1375
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions app/assets/stylesheets/addons/_html5-input-types.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,31 @@ $inputs-list: 'input[type="email"]',
'input[type="time"]',
'input[type="week"]';

$unquoted-inputs-list: ();
@each $input-type in $inputs-list {
$unquoted-inputs-list: append($unquoted-inputs-list, unquote($input-type), comma) !global;
}
@function assign-text-inputs($inputs, $pseudo: null) {
$list : ();

$all-text-inputs: $unquoted-inputs-list;
@each $input in $inputs {
$input: unquote($input);
$input: if($pseudo, $input + ":" + $pseudo, $input);
$list: append($list, $input, comma);
}

@return $list;
}

// Bare inputs
//************************************************************************//
$all-text-inputs: assign-text-inputs($inputs-list);

// Hover Pseudo-class
//************************************************************************//
$all-text-inputs-hover: ();
@each $input-type in $unquoted-inputs-list {
$input-type-hover: $input-type + ":hover";
$all-text-inputs-hover: append($all-text-inputs-hover, $input-type-hover, comma) !global;
}
$all-text-inputs-hover: assign-text-inputs($inputs-list, hover);

// Focus Pseudo-class
//************************************************************************//
$all-text-inputs-focus: ();
@each $input-type in $unquoted-inputs-list {
$input-type-focus: $input-type + ":focus";
$all-text-inputs-focus: append($all-text-inputs-focus, $input-type-focus, comma) !global;
}
$all-text-inputs-focus: assign-text-inputs($inputs-list, focus);



// You must use interpolation on the variable:
// #{$all-text-inputs}
Expand Down

0 comments on commit 56f1375

Please sign in to comment.