Skip to content

Commit a437260

Browse files
committed
better img colums style
1 parent 443e384 commit a437260

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

ghcjs/delivery-calculator/src/App/Xlsx.hs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ newXlsx st imgs = xlsx
1818
xlsx =
1919
fromXlsx 0
2020
$ def
21-
& atSheet "Delivery Calculator"
21+
& atSheet "Delivery_Calculator"
2222
?~ sheet
2323
sheet =
2424
def
2525
& #wsDrawing
2626
.~ Just (Drawing mempty)
2727
& #wsRowPropertiesMap
2828
.~ newRowProps rows
29+
& #wsColumnsProperties
30+
.~ newColProps (fmap snd rows)
2931
& addHeader st
3032
& flip (foldl $ addRow imgs) rows
3133
rows =
@@ -43,10 +45,28 @@ newRowProps =
4345
. fmap
4446
( \(rowIdx, rowVal) ->
4547
if any (\x -> x ^. #fieldType == FieldTypeImage) rowVal
46-
then Just (rowIdx, def & #rowHeight ?~ CustomHeight 200)
48+
then Just (rowIdx, def & #rowHeight ?~ CustomHeight 180)
4749
else Nothing
4850
)
4951

52+
newColProps :: [[Field DynamicField Unique]] -> [ColumnsProperties]
53+
newColProps rows = nubOrd $ do
54+
row <- rows
55+
(colIdx, colVal) <- zip [1 ..] row
56+
if colVal ^. #fieldType /= FieldTypeImage
57+
then mempty
58+
else
59+
pure
60+
ColumnsProperties
61+
{ cpMin = colIdx,
62+
cpMax = colIdx,
63+
cpWidth = Just 45,
64+
cpStyle = Nothing,
65+
cpHidden = False,
66+
cpCollapsed = False,
67+
cpBestFit = False
68+
}
69+
5070
addHeader :: St Unique -> Worksheet -> Worksheet
5171
addHeader st sheet =
5272
case sortOn length headers of

pub/xlsx/src/Codec/Xlsx/Types.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ data ColumnsProperties = ColumnsProperties
179179
-- fit'.
180180
cpBestFit :: Bool
181181
}
182-
deriving (Eq, Show, Generic)
182+
deriving (Eq, Ord, Show, Generic)
183183

184184
instance NFData ColumnsProperties
185185

0 commit comments

Comments
 (0)