1module Button.Component where
5import CSS (ColorSpace(..), mix, toHexString)
6import CSS.Safer (cssSafer)
7import Color (fromHexString)
8import Data.Foldable (intercalate)
9import Data.Maybe (fromMaybe)
10import Data.Monoid (guard)
12import Prim.Row (class Lacks, class Union)
13import React.Basic (JSX)
14import React.Basic.DOM (Props_button, unsafeCreateDOMComponent)
15import React.Basic.Hooks (ReactComponent, component, element)
16import React.Basic.Hooks as React
18import Theme (increaseContrast)
19import Theme.Styles (classNames, makeStyles)
20import Theme.Types (CSSTheme)
27derive instance eqButtonType ∷ Eq ButtonType
31 Union attrs attrs_ Props_button =>
32 Lacks "children" attrs =>
33 Lacks "className" attrs =>
38 { children ∷ Array JSX
39 , buttonType ∷ ButtonType
40 , buttonProps ∷ Record attrs
45 makeStyles \(theme ∷ CSSTheme) ->
46 { "@keyframes gradientBG":
48 { "0%": { backgroundPosition: "0% 50%" }
49 , "50%": { backgroundPosition: "100% 50%" }
50 , "100%": { backgroundPosition: "0% 50%" }
57 theme.interfaceColourLightest
60 [ theme.interfaceColourLightest
61 , theme.interfaceColourLighter
63 , color: theme.textColour
68 "1px 1px 10px rgba(0,0,0,0.66)"
71 then "1px solid " <> theme.interfaceColourLighter
74 , borderRadius: "20px"
75 , padding: "0px 18px 0px 18px"
80 , fontFamily: theme.textFontFamily
81 , letterSpacing: "0.2em"
82 , textTransform: "uppercase"
88 , theme.interfaceColourDarker
89 , theme.highlightColourDark
90 , theme.highlightColour
92 , color: theme.interfaceColourLighter
93 , backgroundSize: "400% 400%, 100% 100%"
94 , animation: "$gradientBG 3s ease infinite"
100 , theme.interfaceColourLighter
101 , theme.interfaceColourLightest
103 , boxShadow: "inset 0 0 2px black"
106 { boxShadow: "0 0 0 black"
107 , background: theme.backgroundColour
108 , border: "1px dotted " <> theme.interfaceColourLightest
109 , textDecoration: "line-through"
110 , textDecorationColor: theme.red
118 theme.highlightColour
120 linearGradient [ theme.highlightColour, theme.highlightColourDark ]
123 linearGradient [ theme.highlightColourDark, theme.highlightColour ]
125 , color: fromMaybe theme.textColour
127 hlc <- theme.highlightColour # fromHexString
128 hlcd <- theme.highlightColourDark # fromHexString
129 let bg = if theme.isLight then hlc else mix HSL hlc hlcd 0.5
130 tc <- theme.textColour # fromHexString
131 pure $ increaseContrast bg tc # toHexString
135 component "Button" \{ children, buttonType, buttonProps } -> React.do
136 rawClasses <- useStyles
138 classes = flip classNames rawClasses
139 -- [TODO]: How do you do this in a typesafe manner?
140 pure <<< (element $ unsafeCreateDOMComponent "button")
144 , guard (buttonType == HighlightedButton) _.highlightedButton
146 , disabled: buttonType == DisabledButton
152linearGradient ∷ Array String -> String
153linearGradient 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