@@ -6,28 +6,53 @@ module ECharts.Theme
66 , roma
77 , shine
88 , vintage
9+ , BuiltInTheme (..)
10+ , parseBuiltInTheme
11+ , builtInToTheme
912 ) where
1013
14+ import Prelude (($), (<>))
15+ import Data.Either (Either (..))
1116import Data.Foreign (Foreign )
1217
13- foreign import forceExport :: Foreign
18+ foreign import forceExport ∷ Foreign
1419
1520data Theme = ByName String | FromObject Foreign
21+ data BuiltInTheme = Infographic | Macarons | Roma | Shine | Vintage | Dark
22+
23+ parseBuiltInTheme ∷ String → Either String BuiltInTheme
24+ parseBuiltInTheme str = case str of
25+ " infographic" → Right Infographic
26+ " macarons" → Right Macarons
27+ " roma" → Right Roma
28+ " shine" → Right Shine
29+ " vintage" → Right Vintage
30+ " dark" → Right Dark
31+ _ → Left $ " `" <> str <> " ` is not builtin theme"
32+
33+ builtInToTheme ∷ BuiltInTheme → Theme
34+ builtInToTheme = case _ of
35+ Infographic → ByName " infographic"
36+ Macarons → ByName " macarons"
37+ Roma → ByName " roma"
38+ Shine → ByName " shine"
39+ Vintage → ByName " vintage"
40+ Dark → ByName " dark"
1641
1742dark ∷ Theme
18- dark = ByName " dark "
43+ dark = builtInToTheme Dark
1944
2045infographic ∷ Theme
21- infographic = ByName " infographic "
46+ infographic = builtInToTheme Infographic
2247
2348macarons ∷ Theme
24- macarons = ByName " macarons "
49+ macarons = builtInToTheme Macarons
2550
2651roma ∷ Theme
27- roma = ByName " roma "
52+ roma = builtInToTheme Roma
2853
2954shine ∷ Theme
30- shine = ByName " shine "
55+ shine = builtInToTheme Shine
3156
3257vintage ∷ Theme
33- vintage = ByName " vintage "
58+ vintage = builtInToTheme Vintage
0 commit comments