Skip to content

Commit ff0dbfa

Browse files
authored
cursor property (#41)
1 parent aeb66ef commit ff0dbfa

File tree

5 files changed

+312
-3
lines changed

5 files changed

+312
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Breaking changes:
1414

1515
New features:
1616
- `box-sizing` property nsaunders/purescript-tecton#31
17+
- `cursor` property nsaunders/purescript-tecton#41
1718
- `word-break` property nsaunders/purescript-tecton#32
1819
- Support for custom pseudo-classes and pseudo-elements via the `PseudoClass` and `PseudoElement` constructors nsaunders/purescript-tecton#38
1920
- A new `unsafeDeclaration` function offers an "escape hatch" for e.g. vendor-prefixed or experimental properties that haven't been added to the library yet. nsaunders/purescript-tecton#40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{-
2+
3+
This example fails to compile because the value of the `cursor` property as
4+
defined in the Basic User Interface Module Level 4 specification requires the
5+
last entry to be a generic/native cursor rather than an image URL.
6+
7+
See https://www.w3.org/TR/css-ui-4/#propdef-cursor for more information.
8+
9+
-}
10+
11+
module TypeError.CursorMissingFallback where
12+
13+
import Data.Tuple.Nested ((/\))
14+
import Tecton (CSS, cursor, universal, url, (:=), (?))
15+
16+
css :: CSS
17+
css = universal ? cursor := url "abc.png" /\ url "xyz.png"

src/Tecton.purs

+33
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ import Tecton.Internal
1919
, active
2020
, adjacentSibling
2121
, after
22+
, alias
2223
, alignContent
2324
, alignItems
2425
, alignSelf
2526
, alignmentBaseline
2627
, all
28+
, allScroll
2729
, alphabetic
2830
, alt
2931
, alternate
@@ -103,6 +105,7 @@ import Tecton.Internal
103105
, canvas
104106
, capitalize
105107
, caption
108+
, cell
106109
, center
107110
, central
108111
, ch
@@ -121,6 +124,7 @@ import Tecton.Internal
121124
, cm
122125
, code
123126
, col
127+
, colResize
124128
, colgroup
125129
, collapse
126130
, collection
@@ -137,12 +141,16 @@ import Tecton.Internal
137141
, contentBox
138142
, contenteditable
139143
, contents
144+
, contextMenu
140145
, controls
141146
, coords
147+
, copy
142148
, cover
149+
, crosshair
143150
, cubicBezier
144151
, currentColor
145152
, cursive
153+
, cursor
146154
, dashed
147155
, data'
148156
, datetime
@@ -173,6 +181,7 @@ import Tecton.Internal
173181
, dpi
174182
, draggable
175183
, dt
184+
, eResize
176185
, ease
177186
, easeIn
178187
, easeInOut
@@ -188,6 +197,7 @@ import Tecton.Internal
188197
, enctype
189198
, end
190199
, even
200+
, ewResize
191201
, ex
192202
, expanded
193203
, extraCondensed
@@ -234,6 +244,8 @@ import Tecton.Internal
234244
, fullWidth
235245
, gap
236246
, georgian
247+
, grab
248+
, grabbing
237249
, grid
238250
, gridAutoColumns
239251
, gridAutoFlow
@@ -258,6 +270,7 @@ import Tecton.Internal
258270
, headers
259271
, hebrew
260272
, height
273+
, help
261274
, hidden
262275
, high
263276
, hiragana
@@ -384,22 +397,31 @@ import Tecton.Internal
384397
, mm
385398
, mongolian
386399
, monospace
400+
, move
387401
, ms
388402
, multiple
389403
, muted
390404
, myanmar
405+
, nResize
391406
, name
392407
, nav
408+
, neResize
409+
, neswResize
393410
, nil
411+
, noDrop
394412
, noRepeat
395413
, none
396414
, normal
397415
, not
416+
, notAllowed
398417
, novalidate
399418
, nowrap
419+
, nsResize
400420
, nthChild
401421
, nthLastChild
402422
, nthOfType
423+
, nwResize
424+
, nwseResize
403425
, oblique
404426
, odd
405427
, ol
@@ -508,6 +530,7 @@ import Tecton.Internal
508530
, persian
509531
, perspective
510532
, placeholder
533+
, pointer
511534
, polygon
512535
, polyline
513536
, portrait
@@ -552,11 +575,13 @@ import Tecton.Internal
552575
, round
553576
, row
554577
, rowGap
578+
, rowResize
555579
, rowReverse
556580
, rows
557581
, rowspan
558582
, rtl
559583
, running
584+
, sResize
560585
, safe
561586
, sandbox
562587
, sansSerif
@@ -568,6 +593,7 @@ import Tecton.Internal
568593
, scope
569594
, screen
570595
, scroll
596+
, seResize
571597
, sec
572598
, section
573599
, select
@@ -612,6 +638,7 @@ import Tecton.Internal
612638
, sup
613639
, super
614640
, svg
641+
, swResize
615642
, systemUI
616643
, tabindex
617644
, table
@@ -628,6 +655,7 @@ import Tecton.Internal
628655
, tbody
629656
, td
630657
, telugu
658+
, text
631659
, textAlign
632660
, textBottom
633661
, textDecorationColor
@@ -688,6 +716,7 @@ import Tecton.Internal
688716
, usemap
689717
, value
690718
, verticalAlign
719+
, verticalText
691720
, vh
692721
, video
693722
, visibility
@@ -696,6 +725,8 @@ import Tecton.Internal
696725
, vmax
697726
, vmin
698727
, vw
728+
, wResize
729+
, wait
699730
, wavy
700731
, whiteSpace
701732
, width
@@ -710,6 +741,8 @@ import Tecton.Internal
710741
, xxLarge
711742
, xxSmall
712743
, zIndex
744+
, zoomIn
745+
, zoomOut
713746
, (#+)
714747
, (#-)
715748
, ($=)

src/Tecton/Internal.purs

+132-1
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ module Tecton.Internal
242242
, class FontStretchKeyword
243243
, class FontStyleKeyword
244244
, class FontWeightKeyword
245+
, class GenericCursorKeyword
245246
, class GenericFontFamilyKeyword
246247
, class IsAnimationNameList
247248
, class IsAttachmentList
@@ -258,6 +259,8 @@ module Tecton.Internal
258259
, class IsColor
259260
, class IsColorStopListHead
260261
, class IsColorStopListTail
262+
, class IsCursorImage
263+
, class IsCursorList
261264
, class IsExtensibleSelector
262265
, class IsFontFaceFontStyle
263266
, class IsFontFaceFontWeight
@@ -384,6 +387,7 @@ module Tecton.Internal
384387
, cubicBezier
385388
, currentColor
386389
, cursive
390+
, cursor
387391
, dashed
388392
, data'
389393
, datetime
@@ -967,6 +971,38 @@ module Tecton.Internal
967971
, xxLarge
968972
, xxSmall
969973
, zIndex
974+
, contextMenu
975+
, help
976+
, pointer
977+
, wait
978+
, cell
979+
, crosshair
980+
, text
981+
, verticalText
982+
, alias
983+
, copy
984+
, move
985+
, noDrop
986+
, notAllowed
987+
, grab
988+
, grabbing
989+
, eResize
990+
, nResize
991+
, neResize
992+
, nwResize
993+
, sResize
994+
, seResize
995+
, swResize
996+
, wResize
997+
, ewResize
998+
, nsResize
999+
, neswResize
1000+
, nwseResize
1001+
, colResize
1002+
, rowResize
1003+
, allScroll
1004+
, zoomIn
1005+
, zoomOut
9701006
) where
9711007

9721008
import Prelude hiding (add, bottom, sub, top)
@@ -7130,6 +7166,101 @@ instance declarationOutlineOffset ::
71307166
Declaration "outline-offset" (Measure t) where
71317167
pval = const val
71327168

7169+
-- https://www.w3.org/TR/css-ui-4/#propdef-cursor
7170+
7171+
cursor = Proxy :: Proxy "cursor"
7172+
7173+
instance Property "cursor"
7174+
7175+
contextMenu = Proxy :: Proxy "context-menu"
7176+
help = Proxy :: Proxy "help"
7177+
pointer = Proxy :: Proxy "pointer"
7178+
wait = Proxy :: Proxy "wait"
7179+
cell = Proxy :: Proxy "cell"
7180+
crosshair = Proxy :: Proxy "crosshair"
7181+
text = Proxy :: Proxy "text"
7182+
verticalText = Proxy :: Proxy "vertical-text"
7183+
alias = Proxy :: Proxy "alias"
7184+
copy = Proxy :: Proxy "copy"
7185+
move = Proxy :: Proxy "move"
7186+
noDrop = Proxy :: Proxy "no-drop"
7187+
notAllowed = Proxy :: Proxy "not-allowed"
7188+
grab = Proxy :: Proxy "grab"
7189+
grabbing = Proxy :: Proxy "grabbing"
7190+
eResize = Proxy :: Proxy "e-resize"
7191+
nResize = Proxy :: Proxy "n-resize"
7192+
neResize = Proxy :: Proxy "ne-resize"
7193+
nwResize = Proxy :: Proxy "nw-resize"
7194+
sResize = Proxy :: Proxy "s-resize"
7195+
seResize = Proxy :: Proxy "se-resize"
7196+
swResize = Proxy :: Proxy "sw-resize"
7197+
wResize = Proxy :: Proxy "w-resize"
7198+
ewResize = Proxy :: Proxy "ew-resize"
7199+
nsResize = Proxy :: Proxy "ns-resize"
7200+
neswResize = Proxy :: Proxy "nesw-resize"
7201+
nwseResize = Proxy :: Proxy "nwse-resize"
7202+
colResize = Proxy :: Proxy "col-resize"
7203+
rowResize = Proxy :: Proxy "row-resize"
7204+
allScroll = Proxy :: Proxy "all-scroll"
7205+
zoomIn = Proxy :: Proxy "zoom-in"
7206+
zoomOut = Proxy :: Proxy "zoom-out"
7207+
7208+
class GenericCursorKeyword (s :: Symbol)
7209+
7210+
instance GenericCursorKeyword "auto"
7211+
instance GenericCursorKeyword "default"
7212+
instance GenericCursorKeyword "none"
7213+
instance GenericCursorKeyword "context-menu"
7214+
instance GenericCursorKeyword "help"
7215+
instance GenericCursorKeyword "pointer"
7216+
instance GenericCursorKeyword "progress"
7217+
instance GenericCursorKeyword "wait"
7218+
instance GenericCursorKeyword "cell"
7219+
instance GenericCursorKeyword "crosshair"
7220+
instance GenericCursorKeyword "text"
7221+
instance GenericCursorKeyword "vertical-text"
7222+
instance GenericCursorKeyword "alias"
7223+
instance GenericCursorKeyword "copy"
7224+
instance GenericCursorKeyword "move"
7225+
instance GenericCursorKeyword "no-drop"
7226+
instance GenericCursorKeyword "not-allowed"
7227+
instance GenericCursorKeyword "grab"
7228+
instance GenericCursorKeyword "grabbing"
7229+
instance GenericCursorKeyword "e-resize"
7230+
instance GenericCursorKeyword "n-resize"
7231+
instance GenericCursorKeyword "ne-resize"
7232+
instance GenericCursorKeyword "nw-resize"
7233+
instance GenericCursorKeyword "s-resize"
7234+
instance GenericCursorKeyword "se-resize"
7235+
instance GenericCursorKeyword "sw-resize"
7236+
instance GenericCursorKeyword "w-resize"
7237+
instance GenericCursorKeyword "ew-resize"
7238+
instance GenericCursorKeyword "ns-resize"
7239+
instance GenericCursorKeyword "nesw-resize"
7240+
instance GenericCursorKeyword "nwse-resize"
7241+
instance GenericCursorKeyword "col-resize"
7242+
instance GenericCursorKeyword "row-resize"
7243+
instance GenericCursorKeyword "all-scroll"
7244+
instance GenericCursorKeyword "zoom-in"
7245+
instance GenericCursorKeyword "zoom-out"
7246+
7247+
class IsCursorImage (a :: Type)
7248+
7249+
instance IsCursorImage URL
7250+
instance IsCursorImage (URL ~ Int ~ Int)
7251+
7252+
class IsCursorList (a :: Type)
7253+
7254+
instance GenericCursorKeyword s => IsCursorList (Proxy s)
7255+
instance (IsCursorImage x, IsCursorList xs) => IsCursorList (x /\ xs)
7256+
7257+
instance declarationCursor ::
7258+
( IsCursorList xs
7259+
, MultiVal xs
7260+
) =>
7261+
Declaration "cursor" xs where
7262+
pval = const $ intercalateMultiVal (val "," <> Val _.separator)
7263+
71337264
-- https://www.w3.org/TR/css-ui-4/#propdef-appearance
71347265

71357266
appearance = Proxy :: Proxy "appearance"
@@ -7148,7 +7279,7 @@ instance AppearanceKeyword "menulist-button"
71487279

71497280
instance declarationAppearance ::
71507281
( AppearanceKeyword s
7151-
, IsSymbol s
7282+
, ToVal (Proxy s)
71527283
) =>
71537284
Declaration "appearance" (Proxy s) where
71547285
pval = const val

0 commit comments

Comments
 (0)