Skip to content

Commit 162430e

Browse files
committed
Merge branch 'master' into kimi/hotfix/firefox
2 parents 603525a + e236caa commit 162430e

File tree

11 files changed

+235
-131
lines changed

11 files changed

+235
-131
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# purescript-lumi-components [![Build Status](https://travis-ci.org/lumihq/purescript-lumi-components.svg?branch=master)](https://travis-ci.org/lumihq/purescript-lumi-components)
22

3-
[lumihq.github.io/purescript-lumi-components](https://lumihq.github.io/purescript-lumi-components/)
3+
- [lumihq.github.io/purescript-lumi-components](https://lumihq.github.io/purescript-lumi-components/)
4+
- [purescript-lumi-components on Pursuit](https://pursuit.purescript.org/packages/purescript-lumi-components/)
45

56
This is a component library focused on Lumi's specific UI and UX needs. Available components are found in `src/components`.
67

@@ -32,7 +33,7 @@ You can run production builds (output minified, static files to `build/`) using
3233

3334
```sh
3435
pulp version 0.x.y
35-
git push --follow-tags
36+
pulp publish
3637
npm run deploy
3738
```
3839

bower.json

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"purescript-coroutines": "^5.0.0",
1919
"purescript-fixed-precision": "^4.0.0",
2020
"purescript-foldable-traversable": "^4.0.0",
21-
"purescript-foreign-object": "^1.0.0",
21+
"purescript-foreign-object": ">= 1.0.0 < 3.0.0",
2222
"purescript-generics-rep": "^6.0.0",
2323
"purescript-foreign": "^5.0.0",
2424
"purescript-gen": "^2.0.0",
@@ -27,24 +27,22 @@
2727
"purescript-nullable": "^4.0.0",
2828
"purescript-numbers": "^6.0.0",
2929
"purescript-prelude": "^4.0.1",
30-
"purescript-profunctor-lenses": "^4.0.0",
30+
"purescript-profunctor-lenses": ">=4.0.0 <7.0.0",
3131
"purescript-random": "^4.0.0",
32-
"purescript-react-basic": "^8.0.0 || ^9.0.0",
32+
"purescript-react-basic": ">= 8.0.0 < 10.0.0",
3333
"purescript-react-dnd-basic": "^6.0.0",
34-
"purescript-record": "^1.0.0",
35-
"purescript-simple-json": "^4.0.0",
34+
"purescript-record": ">= 1.0.0 < 3.0.0",
35+
"purescript-simple-json": ">=4.0.0 <7.0.0",
3636
"purescript-strings": "^4.0.0",
3737
"purescript-tuples": "^5.0.0",
38-
"purescript-typelevel-prelude": "^3.0.0",
3938
"purescript-unsafe-reference": "^3.0.1",
40-
"purescript-web-html": "^1.0.0",
41-
"purescript-web-storage": "^2.0.0",
39+
"purescript-web-html": ">=1.0.0 <3.0.0",
40+
"purescript-web-storage": ">=2.0.0 <4.0.0",
4241
"purescript-validation": "^4.0.0",
4342
"purescript-js-timers": "^4.0.1",
44-
"purescript-heterogeneous": "^0.3.0",
43+
"purescript-heterogeneous": ">=0.3.0 <0.5.0",
4544
"purescript-free": "^5.1.0",
46-
"purescript-colors": "^5.0.0",
47-
"purescript-record-extra": "^2.0.2"
45+
"purescript-colors": "^5.0.0"
4846
},
4947
"devDependencies": {
5048
"purescript-debug": "^4.0.0",

docs/Examples/Border.example.purs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ module Lumi.Components.Examples.Border where
22

33
import Prelude
44

5-
import Data.Maybe (Maybe(..))
6-
import Lumi.Components.Border (border, borderSquare, borderRound, borderSquareTop, borderSquareBottom, borderTop, borderBottom)
5+
import Lumi.Components.Border (borderBottom, borderRound, borderSquare, borderSquareBottom, borderSquareTop, borderTop)
76
import Lumi.Components.Column (column, column_)
87
import Lumi.Components.Example (example)
9-
import Lumi.Components.Spacing (Space(..))
108
import Lumi.Components.Text (h2_)
11-
import React.Basic (Component, JSX, createComponent, makeStateless)
12-
import React.Basic.DOM (css)
9+
import React.Basic (JSX)
1310
import React.Basic.DOM as R
1411

1512
docs :: JSX

docs/Examples/DropdownButton.example.purs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import Effect.Console (log)
99
import Lumi.Components.Button (button, defaults, secondary)
1010
import Lumi.Components.Color (colors)
1111
import Lumi.Components.Column (column, column_)
12-
import Lumi.Components.DropdownButton (dropdownButton, dropdownMenu, dropdownButtonDefaults, dropdownMenuDefaults)
12+
import Lumi.Components.DropdownButton (dropdownButton, dropdownButtonDefaults, dropdownIcon, dropdownIconDefaults, dropdownMenu, dropdownMenuDefaults)
13+
import Lumi.Components.Example (example)
1314
import Lumi.Components.Input (input, text_)
1415
import Lumi.Components.InputGroup (inputGroup)
1516
import Lumi.Components.Spacing (Space(..), vspace)
1617
import Lumi.Components.Text (body_, h2_)
17-
import Lumi.Components.Example (example)
1818
import React.Basic (JSX)
1919
import React.Basic.DOM as R
2020

@@ -197,4 +197,27 @@ docs =
197197
"""
198198
]
199199
}
200+
201+
, h2_ "using an arbitrary icon in place of the button"
202+
, example $
203+
dropdownIcon dropdownIconDefaults
204+
{ content = R.div
205+
{ style: R.css { width: "328px", padding: "12px" }
206+
, children:
207+
[ button secondary
208+
{ title = "I can be any element"
209+
, style = R.css { width: "100%", marginBottom: "8px" }
210+
}
211+
, button secondary
212+
{ title = "I can be any element"
213+
, style = R.css { width: "100%", marginBottom: "8px" }
214+
}
215+
, button defaults
216+
{ title = "I can be any element"
217+
, style = R.css { width: "100%" }
218+
}
219+
]
220+
}
221+
}
222+
200223
]

docs/Examples/EditableTable.example.purs

Lines changed: 102 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,30 @@ import Prelude
55
import Data.Array.NonEmpty (filter, fromArray, fromNonEmpty, length, snoc)
66
import Data.BigInt (fromInt, fromString, toNumber, toString)
77
import Data.Either (Either(..))
8-
import Data.Foldable (sum)
8+
import Data.Foldable (sum, traverse_)
9+
import Data.Foldable as Array
910
import Data.Maybe (Maybe(..), fromMaybe)
1011
import Data.NonEmpty ((:|))
12+
import Data.Nullable as Nullable
1113
import Data.Number (isNaN)
1214
import Data.Number.Format (fixed, toStringWith)
15+
import Effect.Console (log)
1316
import Global (readInt)
1417
import Lumi.Components.Column (column_)
15-
import Lumi.Components.EditableTable (editableTable)
18+
import Lumi.Components.DropdownButton (dropdownIcon, dropdownIconDefaults)
19+
import Lumi.Components.EditableTable (editableTable, editableTableDefaults)
20+
import Lumi.Components.Example (example)
21+
import Lumi.Components.Input (CheckboxState(..), alignToInput, input, switch)
1622
import Lumi.Components.Input as Input
23+
import Lumi.Components.Link as Link
1724
import Lumi.Components.Row (row_)
18-
import Lumi.Components.Text (body, body_, nbsp, text)
19-
import Lumi.Components.Example (example)
25+
import Lumi.Components.Spacing (Space(..), hspace)
26+
import Lumi.Components.Text (body, body_, nbsp, p_, text)
2027
import React.Basic (Component, JSX, createComponent, make)
2128
import React.Basic.DOM as R
22-
import React.Basic.DOM.Events (targetValue)
29+
import React.Basic.DOM.Events (stopPropagation, targetChecked, targetValue)
2330
import React.Basic.Events (handler)
31+
import React.Basic.Events (handler) as Events
2432

2533
component :: Component Unit
2634
component = createComponent "EditableTableExample"
@@ -40,63 +48,72 @@ docs = unit # make component
4048
, price: 0.23
4149
}
4250
]
51+
, customRemoveCell: false
4352
}
4453

4554
, render: \self ->
46-
column_
47-
[ example $
48-
editableTable
49-
{ addLabel: "Add another row"
50-
, columns:
51-
[ { label: "Description"
52-
, renderCell: \row -> Input.input Input.text_
53-
{ value = row.description
54-
, onChange = handler targetValue \value ->
55-
updateRow self row { description = fromMaybe row.description value }
56-
, style = R.css { width: "100%" }
57-
}
58-
}
59-
, { label: "Quantity"
60-
, renderCell: \row -> Input.input Input.number
61-
{ value = toString row.quantity
62-
, onChange = handler targetValue \value ->
63-
updateRow self row { quantity = fromMaybe row.quantity $ fromString =<< value }
64-
}
65-
}
66-
, { label: "Price"
67-
, renderCell: \row -> Input.input Input.number
68-
{ value = show row.price
69-
, onChange = handler targetValue \value ->
70-
updateRow self $ fromMaybe row do
71-
value' <- readInt 10 <$> value
72-
pure if isNaN value'
73-
then row
74-
else row { price = value' }
75-
}
76-
}
77-
, { label: "Total"
78-
, renderCell: \row -> R.text $ toMoneyString (calculateTotal row)
79-
}
55+
column_ $ pure $ example $ column_
56+
[ row_
57+
[ alignToInput $ body_ "Custom remove cell?"
58+
, input switch
59+
{ checked = if self.state.customRemoveCell then On else Off
60+
, onChange = Events.handler (stopPropagation >>> targetChecked)
61+
(traverse_ (\checked -> self.setState (_ { customRemoveCell = checked })))
62+
}
63+
]
64+
, editableTable
65+
{ addLabel: "Add another row"
66+
, columns:
67+
[ { label: "Description"
68+
, renderCell: \row -> Input.input Input.text_
69+
{ value = row.description
70+
, onChange = handler targetValue \value ->
71+
updateRow self row { description = fromMaybe row.description value }
72+
, style = R.css { width: "100%" }
73+
}
74+
}
75+
, { label: "Quantity"
76+
, renderCell: \row -> Input.input Input.number
77+
{ value = toString row.quantity
78+
, onChange = handler targetValue \value ->
79+
updateRow self row { quantity = fromMaybe row.quantity $ fromString =<< value }
80+
}
81+
}
82+
, { label: "Price"
83+
, renderCell: \row -> Input.input Input.number
84+
{ value = show row.price
85+
, onChange = handler targetValue \value ->
86+
updateRow self $ fromMaybe row do
87+
value' <- readInt 10 <$> value
88+
pure if isNaN value'
89+
then row
90+
else row { price = value' }
91+
}
92+
}
93+
, { label: "Total"
94+
, renderCell: \row -> R.text $ toMoneyString (calculateTotal row)
95+
}
96+
]
97+
, maxRows: 5
98+
, onRowAdd: addRow self
99+
, onRowRemove: removeRow self
100+
, removeCell: removeCell self
101+
, readonly: false
102+
, rowEq: eq
103+
, rows: Right self.state.rows
104+
, summary:
105+
row_
106+
[ text body
107+
{ children = [ R.text "Total:" ]
108+
, style = R.css { fontWeight: "bold" }
109+
}
110+
, body_ nbsp
111+
, body_ nbsp
112+
, body_ nbsp
113+
, body_ nbsp
114+
, body_ $ toMoneyString $ sum $ calculateTotal <$> self.state.rows
80115
]
81-
, maxRows: 5
82-
, onRowAdd: addRow self
83-
, onRowRemove: removeRow self
84-
, readonly: false
85-
, rowEq: eq
86-
, rows: Right self.state.rows
87-
, summary:
88-
row_
89-
[ text body
90-
{ children = [ R.text "Total:" ]
91-
, style = R.css { fontWeight: "bold" }
92-
}
93-
, body_ nbsp
94-
, body_ nbsp
95-
, body_ nbsp
96-
, body_ nbsp
97-
, body_ $ toMoneyString $ sum $ calculateTotal <$> self.state.rows
98-
]
99-
}
116+
}
100117
]
101118
}
102119
where
@@ -129,3 +146,30 @@ docs = unit # make component
129146

130147
toMoneyString value =
131148
"$" <> toStringWith (fixed 2) value
149+
150+
removeCell self =
151+
if self.state.customRemoveCell
152+
then \onRemove row ->
153+
row_
154+
[ hspace S16
155+
, dropdownIcon dropdownIconDefaults
156+
{ alignment = Nullable.notNull "right"
157+
, content = R.div
158+
{ style: R.css { width: "328px", padding: "12px" }
159+
, children:
160+
[ Link.link Link.defaults
161+
{ className = pure "lumi-dropdown-menu-item"
162+
, text = p_ "Do something with this row"
163+
, navigate = pure $ log $ "Did something: " <> show row
164+
}
165+
, onRemove # Array.foldMap \onRemove' ->
166+
Link.link Link.defaults
167+
{ className = pure "lumi-dropdown-menu-item"
168+
, text = p_ "Remove this row"
169+
, navigate = pure $ onRemove' row
170+
}
171+
]
172+
}
173+
}
174+
]
175+
else editableTableDefaults.removeCell

src/Lumi/Components/Color.purs

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,9 @@ module Lumi.Components.Color
66
, colorNames
77
) where
88

9-
import Prelude
10-
11-
import Color (rgba)
9+
import Color (rgb, rgba)
1210
import Color as C
13-
import Data.Maybe (fromMaybe)
1411
import Data.Newtype (class Newtype)
15-
import Record.Extra (mapRecord)
1612

1713
type Color = C.Color
1814

@@ -45,31 +41,29 @@ type ColorMap a =
4541
}
4642

4743
colors :: ColorMap Color
48-
colors = mapRecord (fromMaybe transparent <<< C.fromHexString)
49-
{ black: "#232220"
50-
, black1: "#91908d"
51-
, black2: "#bebcb9"
52-
, black3: "#dddddc"
53-
, black4: "#e7e6e5"
54-
, black5: "#f5f4f2"
55-
, black6: "#f7f6f4"
56-
, black7: "#f9f8f7"
57-
, black8: "#fbfaf9"
58-
, primary: "#0044e4"
59-
, primary1: "#a6bef6"
60-
, primary2: "#bfd0f8"
61-
, primary3: "#d9e3fb"
62-
, primary4: "#edf2fd"
63-
, secondary: "#91908d"
64-
, accent1: "#49b860"
65-
, accent2: "#ffa502"
66-
, accent3: "#f1500d"
67-
, accent33: "#fde5db"
68-
, white: "#ffffff"
69-
, transparent: "transparent"
44+
colors =
45+
{ black: rgb 0x23 0x22 0x20
46+
, black1: rgb 0x91 0x90 0x8d
47+
, black2: rgb 0xbe 0xbc 0xb9
48+
, black3: rgb 0xdd 0xdd 0xdc
49+
, black4: rgb 0xe7 0xe6 0xe5
50+
, black5: rgb 0xf5 0xf4 0xf2
51+
, black6: rgb 0xf7 0xf6 0xf4
52+
, black7: rgb 0xf9 0xf8 0xf7
53+
, black8: rgb 0xfb 0xfa 0xf9
54+
, primary: rgb 0x00 0x44 0xe4
55+
, primary1: rgb 0xa6 0xbe 0xf6
56+
, primary2: rgb 0xbf 0xd0 0xf8
57+
, primary3: rgb 0xd9 0xe3 0xfb
58+
, primary4: rgb 0xed 0xf2 0xfd
59+
, secondary: rgb 0x91 0x90 0x8d
60+
, accent1: rgb 0x49 0xb8 0x60
61+
, accent2: rgb 0xff 0xa5 0x02
62+
, accent3: rgb 0xf1 0x50 0x0d
63+
, accent33: rgb 0xfd 0xe5 0xdb
64+
, white: rgb 0xff 0xff 0xff
65+
, transparent: rgba 0 0 0 0.0
7066
}
71-
where
72-
transparent = rgba 0 0 0 0.0
7367

7468
colorNames :: ColorMap ColorName
7569
colorNames =

0 commit comments

Comments
 (0)