diff options
author | Kristóf Marussy <kristof@marussy.com> | 2024-04-12 15:38:00 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2024-04-12 17:39:51 +0200 |
commit | 5d03b40dc995a704e803896ee4de04f03289f42d (patch) | |
tree | 84ba46983787e64dd93cf3c392f7737280fa8812 /subprojects/frontend/src/graph/export | |
parent | feat(docs): add edit link (diff) | |
download | refinery-5d03b40dc995a704e803896ee4de04f03289f42d.tar.gz refinery-5d03b40dc995a704e803896ee4de04f03289f42d.tar.zst refinery-5d03b40dc995a704e803896ee4de04f03289f42d.zip |
refactor(frontend): remember export setting for auto theme
Diffstat (limited to 'subprojects/frontend/src/graph/export')
-rw-r--r-- | subprojects/frontend/src/graph/export/ExportSettingsStore.ts | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/subprojects/frontend/src/graph/export/ExportSettingsStore.ts b/subprojects/frontend/src/graph/export/ExportSettingsStore.ts index 478227af..7c691a7b 100644 --- a/subprojects/frontend/src/graph/export/ExportSettingsStore.ts +++ b/subprojects/frontend/src/graph/export/ExportSettingsStore.ts | |||
@@ -7,18 +7,21 @@ | |||
7 | import { makeAutoObservable } from 'mobx'; | 7 | import { makeAutoObservable } from 'mobx'; |
8 | 8 | ||
9 | export type ExportFormat = 'svg' | 'pdf' | 'png'; | 9 | export type ExportFormat = 'svg' | 'pdf' | 'png'; |
10 | export type ExportTheme = 'light' | 'dark' | 'dynamic'; | 10 | export type StaticTheme = 'light' | 'dark'; |
11 | export type ExportTheme = StaticTheme | 'dynamic'; | ||
11 | 12 | ||
12 | export default class ExportSettingsStore { | 13 | export default class ExportSettingsStore { |
13 | format: ExportFormat = 'svg'; | 14 | format: ExportFormat = 'svg'; |
14 | 15 | ||
15 | theme: ExportTheme = 'light'; | 16 | private staticTheme: StaticTheme = 'light'; |
16 | 17 | ||
17 | transparent = true; | 18 | private _theme: ExportTheme = 'light'; |
18 | 19 | ||
19 | embedSVGFonts = false; | 20 | private _transparent = true; |
20 | 21 | ||
21 | embedPDFFonts = true; | 22 | private embedSVGFonts = false; |
23 | |||
24 | private embedPDFFonts = true; | ||
22 | 25 | ||
23 | scale = 100; | 26 | scale = 100; |
24 | 27 | ||
@@ -28,24 +31,17 @@ export default class ExportSettingsStore { | |||
28 | 31 | ||
29 | setFormat(format: ExportFormat): void { | 32 | setFormat(format: ExportFormat): void { |
30 | this.format = format; | 33 | this.format = format; |
31 | if (this.theme === 'dynamic' && this.format !== 'svg') { | ||
32 | this.theme = 'light'; | ||
33 | } | ||
34 | } | 34 | } |
35 | 35 | ||
36 | setTheme(theme: ExportTheme): void { | 36 | setTheme(theme: ExportTheme): void { |
37 | this.theme = theme; | 37 | this._theme = theme; |
38 | if (this.theme === 'dynamic') { | 38 | if (theme !== 'dynamic') { |
39 | this.format = 'svg'; | 39 | this.staticTheme = theme; |
40 | this.transparent = true; | ||
41 | } | 40 | } |
42 | } | 41 | } |
43 | 42 | ||
44 | toggleTransparent(): void { | 43 | toggleTransparent(): void { |
45 | this.transparent = !this.transparent; | 44 | this._transparent = !this._transparent; |
46 | if (!this.transparent && this.theme === 'dynamic') { | ||
47 | this.theme = 'light'; | ||
48 | } | ||
49 | } | 45 | } |
50 | 46 | ||
51 | toggleEmbedFonts(): void { | 47 | toggleEmbedFonts(): void { |
@@ -56,7 +52,18 @@ export default class ExportSettingsStore { | |||
56 | this.scale = scale; | 52 | this.scale = scale; |
57 | } | 53 | } |
58 | 54 | ||
55 | get theme(): ExportTheme { | ||
56 | return this.format === 'svg' ? this._theme : this.staticTheme; | ||
57 | } | ||
58 | |||
59 | get transparent(): boolean { | ||
60 | return this.theme === 'dynamic' ? true : this._transparent; | ||
61 | } | ||
62 | |||
59 | get embedFonts(): boolean { | 63 | get embedFonts(): boolean { |
64 | if (this.theme === 'dynamic') { | ||
65 | return false; | ||
66 | } | ||
60 | return this.format === 'pdf' ? this.embedPDFFonts : this.embedSVGFonts; | 67 | return this.format === 'pdf' ? this.embedPDFFonts : this.embedSVGFonts; |
61 | } | 68 | } |
62 | 69 | ||
@@ -65,9 +72,6 @@ export default class ExportSettingsStore { | |||
65 | this.embedPDFFonts = embedFonts; | 72 | this.embedPDFFonts = embedFonts; |
66 | } | 73 | } |
67 | this.embedSVGFonts = embedFonts; | 74 | this.embedSVGFonts = embedFonts; |
68 | if (this.embedSVGFonts && this.theme === 'dynamic') { | ||
69 | this.theme = 'light'; | ||
70 | } | ||
71 | } | 75 | } |
72 | 76 | ||
73 | get canSetDynamicTheme(): boolean { | 77 | get canSetDynamicTheme(): boolean { |