Skip to content

Commit

Permalink
Merge pull request #71 from kneath/pseudo-selectors
Browse files Browse the repository at this point in the history
Add pseudo selectors to kss.js/coffee
  • Loading branch information
Kyle Neath committed Jun 19, 2013
2 parents d3abc7e + 5c0e5b0 commit 96d2ef0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
5 changes: 4 additions & 1 deletion example/public/javascripts/kss.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions example/views/layout.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>Styleguide Example</title>
<link rel="stylesheet" href="/stylesheets/layout.css" type="text/css" />
<link rel="stylesheet" href="/stylesheets/buttons.css" type="text/css" />
<meta charset="utf-8">
<link rel="stylesheet" href="/stylesheets/layout.css">
<link rel="stylesheet" href="/stylesheets/buttons.css">
<link rel="stylesheet" href="/stylesheets/table.css">
</head>
<body>

Expand Down
17 changes: 16 additions & 1 deletion lib/kss.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,23 @@
# a:hover{ color:blue; }
# => a.pseudo-class-hover{ color:blue; }
class KssStateGenerator
psuedo_selectors = [
'hover',
'enabled',
'disabled',
'active',
'visited',
'focus',
'target',
'checked',
'empty',
'first-of-type',
'last-of-type',
'first-child',
'last-child']

constructor: ->
pseudos = /(\:hover|\:disabled|\:active|\:visited|\:focus|\:target)/g
pseudos = new RegExp "(\\:#{psuedo_selectors.join('|\\:')})", "g"

try
for stylesheet in document.styleSheets
Expand Down

0 comments on commit 96d2ef0

Please sign in to comment.