|
1 | 1 | module ECharts.Theme |
2 | 2 | ( Theme(..) |
| 3 | + , BuiltInTheme |
| 4 | + , builtInThemeName |
3 | 5 | , dark |
4 | 6 | , infographic |
5 | 7 | , macarons |
6 | 8 | , roma |
7 | 9 | , shine |
8 | 10 | , vintage |
9 | | - , BuiltInTheme(..) |
10 | | - , parseBuiltInTheme |
11 | | - , builtInToTheme |
12 | 11 | ) where |
13 | 12 |
|
14 | | -import Prelude (($), (<>)) |
15 | 13 | import Data.Either (Either(..)) |
16 | 14 | import Data.Foreign (Foreign) |
17 | 15 |
|
18 | | -foreign import forceExport ∷ Foreign |
| 16 | +type Theme = Either BuiltInTheme Foreign |
19 | 17 |
|
20 | | -data Theme = ByName String | FromObject Foreign |
21 | | -data BuiltInTheme = Infographic | Macarons | Roma | Shine | Vintage | Dark |
| 18 | +foreign import data BuiltInTheme :: Type |
22 | 19 |
|
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" |
| 20 | +foreign import builtInThemeName :: BuiltInTheme -> String |
32 | 21 |
|
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" |
| 22 | +dark :: Theme |
| 23 | +dark = Left _dark |
41 | 24 |
|
42 | | -dark ∷ Theme |
43 | | -dark = builtInToTheme Dark |
| 25 | +infographic :: Theme |
| 26 | +infographic = Left _infographic |
44 | 27 |
|
45 | | -infographic ∷ Theme |
46 | | -infographic = builtInToTheme Infographic |
| 28 | +macarons :: Theme |
| 29 | +macarons = Left _macarons |
47 | 30 |
|
48 | | -macarons ∷ Theme |
49 | | -macarons = builtInToTheme Macarons |
| 31 | +roma :: Theme |
| 32 | +roma = Left _roma |
50 | 33 |
|
51 | | -roma ∷ Theme |
52 | | -roma = builtInToTheme Roma |
| 34 | +shine :: Theme |
| 35 | +shine = Left _shine |
53 | 36 |
|
54 | | -shine ∷ Theme |
55 | | -shine = builtInToTheme Shine |
| 37 | +vintage :: Theme |
| 38 | +vintage = Left _vintage |
56 | 39 |
|
57 | | -vintage ∷ Theme |
58 | | -vintage = builtInToTheme Vintage |
| 40 | +foreign import _dark :: BuiltInTheme |
| 41 | +foreign import _infographic :: BuiltInTheme |
| 42 | +foreign import _macarons :: BuiltInTheme |
| 43 | +foreign import _roma :: BuiltInTheme |
| 44 | +foreign import _shine :: BuiltInTheme |
| 45 | +foreign import _vintage :: BuiltInTheme |
0 commit comments