Skip to content

Commit

Permalink
Change mouse pointer when hovering over a piece
Browse files Browse the repository at this point in the history
  • Loading branch information
opsb committed Jan 22, 2018
1 parent b0998bb commit 2c311e9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 10 additions & 4 deletions assets/src/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Html exposing (Html, div, h1, img)
import Html.Attributes exposing (src)
import List.Extra as List
import Svg exposing (svg, rect, Svg, g, text_, text)
import Svg.Attributes exposing (width, height, rx, ry, viewBox, x, y, fill, fontSize, style, transform)
import Svg.Attributes exposing (width, height, rx, ry, viewBox, x, y, fill, fontSize, style, transform, class)
import Svg.Events exposing (onMouseDown, onMouseUp, onMouseMove)
import Arithmetic exposing (isEven)
import Piece
Expand Down Expand Up @@ -231,11 +231,11 @@ dragView { drag, mousePosition, mouseMovementX } =
, y <| toString <| mousePosition.y - offset
, height (toString squareSize)
, width (toString squareSize)
, style "pointer-events: none;"
]
[ pieceView piece
player
[ style "pointer-events: none;"
, transform <| "rotate(" ++ (toString rotation) ++ " 0 0)"
[ transform <| "rotate(" ++ (toString rotation) ++ " 0 0)"
]
(toFloat <| squareSize // 2)
(toFloat <| squareSize // 2)
Expand Down Expand Up @@ -280,7 +280,7 @@ squarePieceView square location =
pieceView : Piece -> Player -> (List (Svg.Attribute msg) -> Float -> Float -> Svg msg)
pieceView piece player attrs left top =
g
attrs
(attrs ++ [ class "piece" ])
[ case piece of
Pawn ->
case player of
Expand Down Expand Up @@ -371,10 +371,15 @@ letterView rankIndex =
[ fontSize <| toString <| coordsFontSize
, x <| toString <| (squareSize - coordsFontSize)
, y <| toString <| (8 + squareSize - coordsFontSize)
, noTextSelect
]
[ text (indexToRank rankIndex) ]


noTextSelect =
style "user-select: none;"


coordsFontSize =
14

Expand All @@ -385,6 +390,7 @@ numberView fileIndex =
[ fontSize <| toString <| coordsFontSize
, x "5"
, y "18"
, noTextSelect
]
[ text <| toString <| fileIndex + 1 ]

Expand Down
4 changes: 4 additions & 0 deletions assets/src/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ img {
margin: 20px 0;
max-width: 200px;
}

.piece {
cursor: pointer;
}

0 comments on commit 2c311e9

Please sign in to comment.