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

Add more standard pseudo-classes #82

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
2 changes: 1 addition & 1 deletion src/CSS.purs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import CSS.Geometry (bottom, height, left, lineHeight, margin, marginBottom, mar
import CSS.Gradient (Extend, Radial, Ramp, circle, circular, closestCorner, closestSide, ellipse, elliptical, farthestCorner, farthestSide, hGradient, hRepeatingGradient, linearGradient, radialGradient, repeatingLinearGradient, repeatingRadialGradient, vGradient, vRepeatingGradient) as X
import CSS.Property (class Val, Key(..), Literal(..), Prefixed(..), Value(..), cast, noCommas, plain, quote, value, (!)) as X
import CSS.Render (Inline(..), Rendered, Sheet(..), collect, collect', face, feature, frame, getInline, getSheet, imp, kframe, mediaQuery, mediaType, merger, nel, predicate, properties, putInline, putStyleSheet, query', render, renderedInline, renderedSheet, rule', rules, selector, selector', selector'', sepWith) as X
import CSS.Pseudo (hover) as X
import CSS.Pseudo (active, any, anyLink, checked, default, defined, disabled, empty, enabled, first, firstChild, firstOfType, fullscreen, focus, focusVisible, hover, indeterminate, inRange, invalid, lastChild, lastOfType, link, onlyChild, onlyOfType, optional, outOfRange, readOnly, readWrite, required, root, scope, target, valid, visited) as X
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not re-exporting left and right here because there are two CSS properties with the same names that are already exported from the CSS.Geometry module and I believe they are used more often

import CSS.Selector (Path(..), Predicate(..), Refinement(..), Selector(..), child, deep, element, star, with, (##), (**), (|>)) as X
import CSS.Size (Abs, Angle(..), Deg, Rad, Rel, Size(..), deg, em, ex, nil, pct, pt, px, rad, rem, sym, vh, vmax, vmin, vw) as X
import CSS.String (class IsString, fromString) as X
Expand Down
114 changes: 114 additions & 0 deletions src/CSS/Pseudo.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,119 @@ module CSS.Pseudo where
import CSS.Selector (Refinement)
import CSS.String (fromString)

active :: Refinement
active = fromString ":active"

any :: Refinement
any = fromString ":any"

anyLink :: Refinement
anyLink = fromString ":any-link"

checked :: Refinement
checked = fromString ":checked"

default :: Refinement
default = fromString ":default"

defined :: Refinement
defined = fromString ":defined"

-- TODO: dir

disabled :: Refinement
disabled = fromString ":disabled"

empty :: Refinement
empty = fromString ":empty"

enabled :: Refinement
enabled = fromString ":enabled"

first :: Refinement
first = fromString ":first"

firstChild :: Refinement
firstChild = fromString ":first-child"

firstOfType :: Refinement
firstOfType = fromString ":first-of-type"

fullscreen :: Refinement
fullscreen = fromString ":fullscreen"

focus :: Refinement
focus = fromString ":focus"

focusVisible :: Refinement
focusVisible = fromString ":focus-visible"

-- TODO: host, host-context

hover :: Refinement
hover = fromString ":hover"

indeterminate :: Refinement
indeterminate = fromString ":indeterminate"

inRange :: Refinement
inRange = fromString ":in-range"

invalid :: Refinement
invalid = fromString ":invalid"

-- TODO: lang

lastChild :: Refinement
lastChild = fromString ":last-child"

lastOfType :: Refinement
lastOfType = fromString ":last-of-type"

left :: Refinement
left = fromString ":left"

link :: Refinement
link = fromString ":link"

-- TODO: not, nth-child, nth-last-child
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how to implement this yet, so I've left several TODOs for those I had to skip

-- TODO: nth-last-of-type, nth-of-type

onlyChild :: Refinement
onlyChild = fromString ":only-child"

onlyOfType :: Refinement
onlyOfType = fromString ":only-of-type"

optional :: Refinement
optional = fromString ":optional"

outOfRange :: Refinement
outOfRange = fromString ":out-of-range"

readOnly :: Refinement
readOnly = fromString ":read-only"

readWrite :: Refinement
readWrite = fromString ":read-write"

required :: Refinement
required = fromString ":required"

right :: Refinement
right = fromString ":right"

root :: Refinement
root = fromString ":root"

scope :: Refinement
scope = fromString ":scope"

target :: Refinement
target = fromString ":target"

valid :: Refinement
valid = fromString ":valid"

visited :: Refinement
visited = fromString ":visited"