Skip to content

Commit 98127eb

Browse files
authored
Merge pull request #163 from burinc/fix-piano-keys-ui-ux
Fix the contrast of piano keys for better ui/ux
2 parents bbb9943 + f49f57b commit 98127eb

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

src/scittle/audio/audio_playground.cljs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,29 +1009,44 @@
10091009
label])
10101010

10111011
(defn piano-key
1012-
"Piano key component"
1012+
"Piano key component with improved visibility"
10131013
[& {:keys [note label on-play color]}]
10141014
[:button {:on-click #(when on-play (on-play :note note))
10151015
:style (merge-styles
10161016
{:width "50px"
10171017
:height "120px"
1018-
:background (or color "white")
1019-
:color (if (= color "white") "black" "white")
1020-
:border "1px solid #333"
1018+
:background (if (= color "white")
1019+
"linear-gradient(to bottom, #ffffff 0%, #f5f5f5 100%)"
1020+
color)
1021+
:color (if (= color "white") "#333" "white")
1022+
:border "2px solid #333"
10211023
:cursor "pointer"
10221024
:font-weight "bold"
10231025
:font-size "14px"
10241026
:transition "all 0.1s ease"
1025-
:border-radius "0 0 4px 4px"})
1027+
:border-radius "0 0 6px 6px"
1028+
:box-shadow "0 4px 6px rgba(0,0,0,0.2), inset 0 -2px 4px rgba(0,0,0,0.1)"
1029+
:position "relative"})
1030+
:on-mouse-enter (fn [e]
1031+
(set! (.-style.background (.-currentTarget e))
1032+
(if (= color "white")
1033+
"linear-gradient(to bottom, #f0f0f0 0%, #e0e0e0 100%)"
1034+
color)))
1035+
:on-mouse-leave (fn [e]
1036+
(set! (.-style.background (.-currentTarget e))
1037+
(if (= color "white")
1038+
"linear-gradient(to bottom, #ffffff 0%, #f5f5f5 100%)"
1039+
color)))
10261040
:on-mouse-down (fn [e]
10271041
(when on-play
1028-
(set! (.-style.transform (.-currentTarget e)) "scale(0.95)")
1042+
(set! (.-style.transform (.-currentTarget e)) "scale(0.95) translateY(2px)")
10291043
(set! (.-style.boxShadow (.-currentTarget e))
1030-
"inset 0 2px 4px rgba(0,0,0,0.2)")
1044+
"0 2px 3px rgba(0,0,0,0.3), inset 0 2px 4px rgba(0,0,0,0.2)")
10311045
(on-play :note note)))
10321046
:on-mouse-up (fn [e]
1033-
(set! (.-style.transform (.-currentTarget e)) "scale(1)")
1034-
(set! (.-style.boxShadow (.-currentTarget e)) "none"))}
1047+
(set! (.-style.transform (.-currentTarget e)) "scale(1) translateY(0)")
1048+
(set! (.-style.boxShadow (.-currentTarget e))
1049+
"0 4px 6px rgba(0,0,0,0.2), inset 0 -2px 4px rgba(0,0,0,0.1)"))}
10351050
label])
10361051

10371052
(defn bass-key

0 commit comments

Comments
 (0)