1module Button.Component where
4import CSS (ColorSpace(..), mix, toHexString)
5import CSS.Safer (cssSafer)
6import Color (fromHexString)
7import Data.Foldable (intercalate)
8import Data.Maybe (fromMaybe)
9import Data.Monoid (guard)
11import Prim.Row (class Lacks, class Union)
12import React.Basic (JSX)
13import React.Basic.DOM (Props_button, unsafeCreateDOMComponent)
14import React.Basic.Hooks (ReactComponent, component, element)
15import React.Basic.Hooks as React
17import Theme (increaseContrast)
18import Theme.Styles (classNames, makeStyles)
19import Theme.Types (CSSTheme)
26derive instance eqButtonType ∷ Eq ButtonType
30 Union attrs attrs_ Props_button =>
31 Lacks "children" attrs =>
36 { children ∷ Array JSX
37 , buttonType ∷ ButtonType
38 , buttonProps ∷ Record attrs
43 makeStyles \(theme ∷ CSSTheme) ->
44 { "@keyframes gradientBG":
46 { "0%": { backgroundPosition: "0% 50%" }
47 , "50%": { backgroundPosition: "100% 50%" }
48 , "100%": { backgroundPosition: "0% 50%" }
54 theme.interfaceColourLightest
57 [ theme.interfaceColourLightest
58 , theme.interfaceColourLighter
60 , color: theme.textColour
65 "1px 1px 10px rgba(0,0,0,0.66)"
68 "1px solid " <> theme.interfaceColourLighter
71 , borderRadius: "20px"
72 , padding: "0px 18px 0px 18px"
77 , fontFamily: theme.textFontFamily
78 , letterSpacing: "0.2em"
79 , textTransform: "uppercase"
85 , theme.interfaceColourDarker
86 , theme.highlightColourDark
87 , theme.highlightColour
90 fromMaybe theme.textColour do
91 hlc <- theme.highlightColour # fromHexString
92 hlcd <- theme.highlightColourDark # fromHexString
93 let bg = if theme.isLight then hlc else mix HSL hlc hlcd 0.5
94 tc <- theme.textColour # fromHexString
95 pure $ increaseContrast bg tc # toHexString
96 , backgroundSize: "400% 400%, 100% 100%"
97 , animation: "$gradientBG 3s ease infinite"
103 , theme.interfaceColourLighter
104 , theme.interfaceColourLightest
106 , boxShadow: "inset 0 0 2px black"
109 { boxShadow: "0 0 0 black"
110 , background: theme.backgroundColour
111 , border: "1px dotted " <> theme.interfaceColourLightest
112 , textDecoration: "line-through"
113 , textDecorationColor: theme.red
119 if theme.isLight then
120 theme.highlightColour
122 linearGradient [ theme.highlightColour, theme.highlightColourDark ]
125 linearGradient [ theme.highlightColourDark, theme.highlightColour ]
128 fromMaybe theme.textColour do
129 hlc <- theme.highlightColour # fromHexString
130 hlcd <- theme.highlightColourDark # fromHexString
132 bg = if theme.isLight then hlc else mix HSL hlc hlcd 0.5
133 tc <- theme.textColour # fromHexString
134 pure $ increaseContrast bg tc # toHexString
137 component "Button" \{ children, buttonType, buttonProps } -> React.do
138 rawClasses <- useStyles
140 classes = flip classNames rawClasses
141 -- [TODO]: How do you do this in a typesafe manner?
142 pure <<< (element $ unsafeCreateDOMComponent "button")
146 , guard (buttonType == HighlightedButton) _.highlightedButton
148 , disabled: buttonType == DisabledButton
154linearGradient ∷ Array String -> String
155linearGradient elems = "linear-gradient(" <> intercalate "," elems <> ")"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list