Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Themes #2628

Draft
wants to merge 332 commits into
base: next
Choose a base branch
from
Draft

Themes #2628

Show file tree
Hide file tree
Changes from 174 commits
Commits
Show all changes
332 commits
Select commit Hold shift + click to select a range
c545f6a
fix: boxplot dark mode border
zachstence Oct 16, 2024
79cf321
fix: remove debug prop
zachstence Oct 16, 2024
c9b9ead
feat: Tabs uses theme
zachstence Oct 16, 2024
2ea56f3
feat: compute dark color scale for USMap
zachstence Oct 16, 2024
bc5a5bd
feat: PropListing uses theme
zachstence Oct 16, 2024
40568c2
chore: pnpm i
zachstence Oct 17, 2024
6c72059
chore: pnpm i
zachstence Oct 17, 2024
24e6416
chore: format
zachstence Oct 17, 2024
61eeff9
feat: TableGroupIcon uses theme
zachstence Oct 17, 2024
26aaf05
feat: ChevronToggle uses theme
zachstence Oct 17, 2024
899a038
fix: QueryViewer chevron uses theme
zachstence Oct 17, 2024
fd694eb
fix: areas and points selected colors use theme
zachstence Oct 17, 2024
152e768
fix: reference point color aliasing
zachstence Oct 17, 2024
0aa95a1
fix: use evidenceThemes() plugin in storybook
zachstence Oct 17, 2024
f144195
chore: changesets
zachstence Oct 17, 2024
3180caa
Merge branch 'feat/2499-theming' into feat/2499-theming_themes-in-js
zachstence Oct 17, 2024
ab319c1
chore: pnpm i
zachstence Oct 17, 2024
0307613
feat: add css vars for theme
zachstence Oct 17, 2024
2eda249
feat: BigLink css var theming
zachstence Oct 17, 2024
a7b1ac3
feat: CodeBlock copy icon theming
zachstence Oct 17, 2024
64d8a43
feat: Details css var theming
zachstence Oct 17, 2024
a6d8871
feat: QueryViewer css var theming
zachstence Oct 17, 2024
405e489
feat: misc css var theming
zachstence Oct 17, 2024
1f21ef9
feat: settings page theming
zachstence Oct 17, 2024
3bf7701
feat: CompilerToggle theming
zachstence Oct 17, 2024
1e8c3c9
feat: Bubble tooltip theming
zachstence Oct 17, 2024
91c9405
feat: Value placeholder theming
zachstence Oct 17, 2024
3bd44ed
feat: ErrorChart theming
zachstence Oct 17, 2024
8f9d9b6
feat: DataTable theming
zachstence Oct 17, 2024
0a60458
feat: EnterFullScreen button theming
zachstence Oct 17, 2024
484b5de
feat: table index theming
zachstence Oct 17, 2024
8b85d63
feat: VennDiagram theming
zachstence Oct 17, 2024
a6b581b
feat: DevTools theming
zachstence Oct 17, 2024
8dd700d
feat: error page theming
zachstence Oct 17, 2024
29b8019
feat: misc theming
zachstence Oct 17, 2024
262ca2d
refactor: interface name
zachstence Oct 17, 2024
f590998
refactor: initChart function
zachstence Oct 17, 2024
87d18a6
refactor: theme store names
zachstence Oct 17, 2024
75120cb
fix: prop default value
zachstence Oct 17, 2024
4d69ac2
chore: remove debug logs
zachstence Oct 17, 2024
9b2e673
docs: document $evidence/themes virtual module
zachstence Oct 17, 2024
468f543
Merge branch 'feat/2499-theming' into feat/2499-theming_themes-in-js
zachstence Oct 17, 2024
457ad4d
chore: format
zachstence Oct 17, 2024
9e27b5b
Merge branch 'next' into feat/2499-theming
zachstence Oct 17, 2024
1cae122
Merge branch 'feat/2499-theming' into feat/2499-theming_themes-in-js
zachstence Oct 17, 2024
fb79fcc
feat: DateRange theming
zachstence Oct 17, 2024
af8877c
feat: Dropdown error theming
zachstence Oct 17, 2024
be59ad3
fix: shadcn badge theming
zachstence Oct 17, 2024
ddbbda4
feat: unused shadcn component theming
zachstence Oct 17, 2024
3cb593e
feat: misc theming
zachstence Oct 17, 2024
d215e2b
feat: SchemaExplorer theming
zachstence Oct 17, 2024
482eb16
feat: SqlConsole theming
zachstence Oct 17, 2024
2a40c6d
feat: Toast theming
zachstence Oct 17, 2024
c0a8a52
feat: BreadCrumbs theming
zachstence Oct 17, 2024
a487ea7
feat: LoadingSkeleton theming
zachstence Oct 17, 2024
e5c07fe
feat: sidebar badge theming
zachstence Oct 17, 2024
3d64566
feat: Sidebar selected uses primary from theme
zachstence Oct 17, 2024
ce4688b
feat: NewSourceForm and SourceConfigForm theming
zachstence Oct 17, 2024
a3a9b92
feat: storybook DebugBar theming
zachstence Oct 17, 2024
1f78244
feat: ChartLoading theming
zachstence Oct 17, 2024
491a15e
feat: LinkButton theming
zachstence Oct 17, 2024
36f70e1
chore: resolve merge conflict
zachstence Oct 18, 2024
95a94a4
Merge pull request #2655 from evidence-dev/feat/2499-theming_themes-i…
zachstence Oct 18, 2024
1b2ac86
Merge branch 'next' into feat/2499-theming
zachstence Oct 18, 2024
9640c82
chore: pnpm i
zachstence Oct 18, 2024
001db12
chore: dont lint storybook-static
zachstence Oct 18, 2024
3da2e62
feat: ErrorOverlay theming
zachstence Oct 18, 2024
6c755a0
feat: BigValueError theming
zachstence Oct 18, 2024
29ec77d
feat: Delta skeleton theming
zachstence Oct 18, 2024
ec9ea5f
feat: EmptyChart theming
zachstence Oct 18, 2024
307dbe5
feat: ErrorChart theming
zachstence Oct 18, 2024
d613c31
feat: Value skeleton theming
zachstence Oct 18, 2024
b6c13a9
feat: ValueError theming
zachstence Oct 18, 2024
4531cdd
feat: Legend theming
zachstence Oct 18, 2024
09b07f8
fix: table row theming
zachstence Oct 18, 2024
b8bc98e
feat: anchors use primary color
zachstence Oct 18, 2024
b5e2aa7
feat: remove VITE_EVIDENCE_THEMES feature flag
zachstence Oct 18, 2024
7daad95
fix: add $evidence/themes to optimizeDeps.exclude to fix running temp…
zachstence Oct 18, 2024
efd7afe
chore: pnpm i
zachstence Oct 21, 2024
3460e33
feat: localStorageStore accepts serialize/deserialize functions
zachstence Oct 21, 2024
c0fc69c
refactor: theme isnt serialized as JSON in local storage
zachstence Oct 21, 2024
9d2488c
feat: set theme in app.html script to prevent FOUC
zachstence Oct 21, 2024
2aa2af1
refactor: system theme store initial value isnt always light
zachstence Oct 21, 2024
e6428f5
fix: enable SSR on dev server
zachstence Oct 22, 2024
f53e1c7
feat: loading splash theming
zachstence Oct 22, 2024
b7d5295
chore: format
zachstence Oct 22, 2024
0186b35
chore: pnpm i
zachstence Oct 22, 2024
855c249
fix: increase contrast of search box border
zachstence Oct 22, 2024
eadd15e
fix: adjust alert color/styles
zachstence Oct 22, 2024
835f8d0
refactor: replace base-content/XX with base-content-muted
zachstence Oct 22, 2024
94017ad
feat: lighten details icon
zachstence Oct 22, 2024
aacc5af
feat: use 950 shade for dark mode base-100
zachstence Oct 22, 2024
0b99e15
Merge branch 'next' into feat/2499-theming
zachstence Oct 24, 2024
349bd4a
chore: pnpm i
zachstence Oct 24, 2024
4ffd8bd
fix: DataTable scaleColor reactivity
zachstence Oct 24, 2024
661de15
fix: revert Modal button to LinkButton style rather than using Button…
zachstence Oct 24, 2024
f27b912
fix: CodeBlock copy button has transparent background
zachstence Oct 24, 2024
927e1fd
fix: chart update on theme change uses new options
zachstence Oct 24, 2024
86882a1
fix: Fullscreen dialog text color
zachstence Oct 24, 2024
59aac33
fix: focus rings base-content -> base-content-muted
zachstence Oct 24, 2024
852f0a9
chore: remove debug code
zachstence Oct 24, 2024
17b1fb3
fix: reduce opacity of tabs colors
zachstence Oct 24, 2024
6f2badf
fix: reduce opacity of codeblock background
zachstence Oct 24, 2024
5630bd2
fix: reduce opacity of border of LinkButton and Modal button on hover
zachstence Oct 24, 2024
2355bbc
fix: reduce opacity of alert background to fix contrast info of alert…
zachstence Oct 24, 2024
7f768fc
feat: echarts uses theme
zachstence Oct 24, 2024
d300c07
feat: adjust base colors to be closer to base-100
zachstence Oct 24, 2024
25d7c18
Merge branch 'next' into feat/2499-theming
zachstence Oct 25, 2024
b72178a
fix: getEvidenceConfig schema type is z.ZodSchema
zachstence Oct 25, 2024
9518474
refactor: change nesting in theme config
zachstence Oct 29, 2024
b7b9fd9
Merge branch 'next' into feat/2499-theming
zachstence Nov 4, 2024
25df5f1
Merge branch 'next' into feat/2499-theming
zachstence Nov 5, 2024
67d97f2
chore: pnpm i
zachstence Nov 5, 2024
13c39ff
feat: implement defaultAppearance and appearanceSwitcher themes confi…
zachstence Nov 5, 2024
56d64d9
fix: include defaults in defaultThemesConfig
zachstence Nov 5, 2024
f405236
feat: enable themes on docs
zachstence Nov 5, 2024
ae16f05
feat: implement colorPalettes and colorScales
zachstence Nov 5, 2024
086f07a
feat: replace chartColours and mapColours with theme colorPalettes
zachstence Nov 5, 2024
42c5be4
feat: enable themes on docs
zachstence Nov 5, 2024
cf64867
Merge branch 'feat/2499-theming_config-options' into feat/2499-themin…
zachstence Nov 5, 2024
3fc263b
Merge branch 'next' into feat/2499-theming
zachstence Nov 6, 2024
b50a398
Merge branch 'feat/2499-theming' into feat/2499-theming_config-options
zachstence Nov 6, 2024
8dddcad
Merge branch 'feat/2499-theming_config-options' into feat/2499-themin…
zachstence Nov 6, 2024
637ec6c
fix: add back USMap docs
zachstence Nov 6, 2024
05ed6f7
Merge branch 'feat/2499-theming' into feat/2499-theming_config-options
zachstence Nov 6, 2024
2703fa2
Merge branch 'feat/2499-theming_config-options' into feat/2499-themin…
zachstence Nov 6, 2024
33f758a
refactor: e2e test utils for interacting with kebab menu and appearance
zachstence Nov 6, 2024
26b1074
feat: support custom color tokens, automatically create css vars
zachstence Nov 6, 2024
1eb1227
Merge pull request #2739 from evidence-dev/feat/2499-theming_user-col…
zachstence Nov 7, 2024
5bcd71a
Merge pull request #2727 from evidence-dev/feat/2499-theming_config-o…
zachstence Nov 7, 2024
9bd8a8a
feat: remove gray scale colors from default color palettes
zachstence Nov 7, 2024
d9398d3
Merge pull request #2729 from evidence-dev/feat/2499-theming_color-pa…
zachstence Nov 7, 2024
b3d941d
Merge branch 'next' into feat/2499-theming
zachstence Nov 12, 2024
88486f4
fix: reexport index.js from .d.ts file
zachstence Nov 12, 2024
9ea1c5d
feat: theme color resolution functions
zachstence Nov 12, 2024
fee0c2e
Merge branch 'next' into feat/2499-theming
zachstence Nov 13, 2024
f60fa8d
Merge branch 'feat/2499-theming' into feat/2499-theming_color-names-i…
zachstence Nov 13, 2024
9169b76
chore: pnpm i
zachstence Nov 13, 2024
b2a982c
Merge branch 'feat/2499-theming' into feat/2499-theming_color-names-i…
zachstence Nov 13, 2024
33835e3
refactor: reorganize tailwind package so we dont import server code o…
zachstence Nov 13, 2024
d4b6004
refactor: ThemeStores is a class
zachstence Nov 13, 2024
14a6fab
refactor: move resolveColor* functions to ThemeStores class
zachstence Nov 13, 2024
60e3d41
refactor: move subscription to onMount with cleanup, add MutationObse…
zachstence Nov 13, 2024
1fe0edb
refactor: ThemeStores.resolveColor* return stores derived from curren…
zachstence Nov 13, 2024
8df21bb
feat: TabDisplay uses resolveColor
zachstence Nov 13, 2024
678806d
Merge branch 'next' into feat/2499-theming
zachstence Nov 15, 2024
a52b6a3
Merge branch 'feat/2499-theming' into feat/2499-theming_color-names-i…
zachstence Nov 15, 2024
b45a58f
chore: npm i
zachstence Nov 15, 2024
498e130
feat: ButtonGroup uses resolveColor
zachstence Nov 15, 2024
115144c
feat: ThemeStores.resolve* trims user input
zachstence Nov 15, 2024
6fb141a
feat: ChevronToggle uses resolveColor
zachstence Nov 15, 2024
40628d1
feat: ThemeStores.resolve* handles unknown input
zachstence Nov 15, 2024
a42f4ba
feat: AreaChart and Area use resolveColor and resolveColorPalette
zachstence Nov 15, 2024
8be5d5b
feat: BarChart and Bar use resolveColor and resolveColorPalette
zachstence Nov 15, 2024
d1742e1
fix: BoxPlot accepts hex color
zachstence Nov 15, 2024
2b2942f
feat: Box and BoxPlot use resolveColor
zachstence Nov 15, 2024
26f3915
fix: BubbleChart reactivity
zachstence Nov 15, 2024
060cd9b
feat: Bubble and BubbleChart use resolveColor and resolveColorPalette
zachstence Nov 15, 2024
67098d3
feat: BigValue uses resolveColor
zachstence Nov 15, 2024
627d1e9
feat: _Chart uses resolveColor and resolveColorPalette
zachstence Nov 15, 2024
6bdd3e5
feat: Sparkline uses resolveColor
zachstence Nov 15, 2024
a2f38c4
feat: Value uses resolveColor
zachstence Nov 15, 2024
4f01d28
chore: comment
zachstence Nov 15, 2024
c19e0a7
fix: colorPalette default should be 'default'
zachstence Nov 15, 2024
201dc26
feat: FunnelChart uses resolveColor and resolveColorPalette
zachstence Nov 15, 2024
87feb12
fix: ThemeStores resolveColorPalette/Scale allow array of strings
zachstence Nov 15, 2024
d06b38d
feat: CalendarHeatmap uses resolveColorPalette
zachstence Nov 15, 2024
479ef03
feat: Heatmap uses resolveColorPalette
zachstence Nov 15, 2024
c04b6ad
feat: Hist and Histogram use resolveColor and resolveColorPalette
zachstence Nov 15, 2024
a384453
feat: Line and LineChart use resolveColor and resolveColorPalette
zachstence Nov 15, 2024
30c34ef
feat: Areas uses resolveColor and resolveColorPalette
zachstence Nov 15, 2024
b99e805
feat: Bubbles and BubbleMap use resolveColorPalette
zachstence Nov 15, 2024
173a578
feat: Points and PointMap use resolveColor and resolveColorPalette
zachstence Nov 15, 2024
4c046d2
feat: USMap uses resolveColorPalette and resolveColorScale
zachstence Nov 15, 2024
4fd5f2a
feat: SankeyDiagram uses resolveColor and resolveColorPalette
zachstence Nov 15, 2024
7d94653
chore: remove debug logs
zachstence Nov 15, 2024
ae23f42
fix: Scatter reactivity
zachstence Nov 15, 2024
88636d9
feat: Scatter and ScatterPlot use resolveColor and resolveColorPalette
zachstence Nov 15, 2024
f10ab04
feat: DataTable row color props use resolveColor
zachstence Nov 15, 2024
7aeef6b
feat: deprecate/remove usage of color system CSS vars
zachstence Nov 15, 2024
f4b7b0e
feat: move reference color constants to theme, use resolveColor
zachstence Nov 15, 2024
4449095
feat: Column uses resolveColor
zachstence Nov 15, 2024
cc915fa
chore: format
zachstence Nov 15, 2024
b1e9640
feat: resolveColor supports objects and arrays, seriesColors uses res…
zachstence Nov 18, 2024
8bc71ec
chore: remove debug log
zachstence Nov 18, 2024
70a7896
feat: BoxPlot uses resolveColor when color is column name
zachstence Nov 18, 2024
0c94912
Merge branch 'next' into feat/2499-theming
zachstence Nov 18, 2024
51da54b
Merge branch 'feat/2499-theming' into feat/2499-theming_color-names-i…
zachstence Nov 18, 2024
4ebcd7a
test: genericize variable names
zachstence Nov 18, 2024
0dc5329
refactor: split resolveColorsObject from resolveColor
zachstence Nov 18, 2024
740673b
feat: resolveColor and resolveColorsObject whitespace trimming
zachstence Nov 18, 2024
4922d49
chore: reorganize tests
zachstence Nov 18, 2024
a9517b3
feat: resolveColor handles string tuple
zachstence Nov 18, 2024
cb4eeaa
feat: resolveColorPalette and resolveColorScale handle color tuples
zachstence Nov 18, 2024
0c640cd
chore: clean up @evidence-dev/tailwind types
zachstence Nov 18, 2024
33ad525
test: Tabs color tuple story
zachstence Nov 18, 2024
82274fd
fix: resolveColorsObject undefined handling
zachstence Nov 18, 2024
7331a0e
test: LineChart colorPalette color tuple story
zachstence Nov 18, 2024
67f9ab6
chore: pnpm i
zachstence Nov 18, 2024
49a6946
fix: activeMode -> activeAppearance
zachstence Nov 18, 2024
285f5c9
Merge branch 'feat/2499-theming_color-names-in-props' into feat/2499-…
zachstence Nov 18, 2024
73480da
chore: remove usage of undefined function
zachstence Nov 18, 2024
c2264c3
feat: DocTab uses theme
zachstence Nov 18, 2024
3729f2e
Merge branch 'next' into feat/2499-theming
zachstence Nov 18, 2024
ef51c44
Merge branch 'feat/2499-theming' into feat/2499-theming_color-names-i…
zachstence Nov 18, 2024
4e5c677
Merge branch 'feat/2499-theming_color-names-in-props' into feat/2499-…
zachstence Nov 18, 2024
81a1643
Merge branch 'feat/2499-theming' into feat/2499-theming_doc-tabs
zachstence Nov 18, 2024
5a0f825
chore: pnpm i
zachstence Nov 18, 2024
d27d87b
test: get first home link
zachstence Nov 18, 2024
adec3e3
test: enable appearanceSwitcher for e2e/themes
zachstence Nov 18, 2024
f982fa3
chore: remove debug log
zachstence Nov 18, 2024
9b16a4a
chore: format
zachstence Nov 18, 2024
57ae322
Merge branch 'feat/2499-theming' into feat/2499-theming_color-names-i…
zachstence Nov 19, 2024
1457c18
chore: pnpm i
zachstence Nov 19, 2024
540bc0b
Merge pull request #2813 from evidence-dev/feat/2499-theming_doc-tabs
zachstence Nov 19, 2024
9390d4a
feat: Chart xAxisTitle uses theme instead of uiColours
zachstence Nov 19, 2024
fa54851
chore: remove invisible axis in Sparkline
zachstence Nov 19, 2024
7f9a343
feat: Sparkline uses theme instead of uiColours
zachstence Nov 19, 2024
3c4a76c
feat: CalendarHeatmap uses theme instead of uiColours
zachstence Nov 19, 2024
aaeff0e
feat: Heatmap uses theme instead of uiColours
zachstence Nov 19, 2024
d47c900
feat: Areas and Points use theme instead of uiColours
zachstence Nov 19, 2024
b5b8626
chore: remove unused uiColours
zachstence Nov 19, 2024
0d2d8d0
Merge pull request #2776 from evidence-dev/feat/2499-theming_color-na…
zachstence Nov 19, 2024
a70fd0c
Merge pull request #2812 from evidence-dev/feat/2499-theming_color-tu…
zachstence Nov 19, 2024
9a45c14
Merge pull request #2814 from evidence-dev/feat/2499-theming_remove-u…
zachstence Nov 19, 2024
c291557
refactor: move themes.js -> themes/themes.js
zachstence Nov 19, 2024
ca954b2
feat: convertLightToDark
zachstence Nov 19, 2024
e8ce2d2
feat: ThemeStores.resolveColor converts light to dark
zachstence Nov 19, 2024
f09883c
fix: non builtin colors may have undefined value
zachstence Nov 19, 2024
33d9581
refactor: move color resolution logic to static method
zachstence Nov 19, 2024
302a017
feat: ThemeStores.resolveColorsObject converts light to dark
zachstence Nov 19, 2024
51adfd0
feat: ThemeStores.resolveColorPalette and resolveColorScale converts …
zachstence Nov 19, 2024
a607cf4
Merge pull request #2817 from evidence-dev/feat/2499-theming_convert-…
zachstence Nov 19, 2024
d062cc5
Merge branch 'next' into feat/2499-theming
zachstence Nov 19, 2024
7a159de
chore: remove duplicate classes
zachstence Nov 19, 2024
78f4516
fix: use pretty-scrollbar for CategoricalLegend
zachstence Nov 19, 2024
9d2bdc5
feat: map legends use theme
zachstence Nov 19, 2024
2fb3deb
Merge pull request #2818 from evidence-dev/feat/2499-theming_map-legend
zachstence Nov 19, 2024
40e8b3c
feat: Alert uses base instead of neutral for default styling
zachstence Nov 19, 2024
af60fee
feat: default Badge uses primary instead of neutral
zachstence Nov 19, 2024
3e3d02c
feat: secondary Badge uses secondary instead of base
zachstence Nov 19, 2024
2a3833c
feat: Toast uses info instead of neutral for info status
zachstence Nov 19, 2024
14f08e8
test: fix storybook WithEvidence styles
zachstence Nov 19, 2024
011f108
feat: Delta uses base instead of neutral
zachstence Nov 19, 2024
93ac5dd
feat: Value uses base-content-muted instead of neutral
zachstence Nov 19, 2024
bb6f599
feat: CustomFormatsSection disabled submit button uses reduced opacit…
zachstence Nov 19, 2024
515c281
feat: query debugger DataPreview uses primary instead of neutral
zachstence Nov 19, 2024
04430e5
feat: USMap uses base instead of neutral
zachstence Nov 19, 2024
6d2cbb9
chore: remove neutral and neutral-content colors
zachstence Nov 19, 2024
48fc5d5
feat: support primary, secondary, accent in button
zachstence Nov 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/dull-spoons-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@evidence-dev/evidence': patch
---

Add evidenceThemes() plugin for \$evidence/themes virtual module
Add CSS for Leaflet dark mode
5 changes: 5 additions & 0 deletions .changeset/fluffy-islands-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/core-components': patch
---

Use theme tokens in JS
6 changes: 6 additions & 0 deletions .changeset/fluffy-jeans-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@evidence-dev/tailwind': patch
---

Add Vite plugin for $evidence/themes virtual module
Add secondary and accent colors to defaultThemes
6 changes: 6 additions & 0 deletions .changeset/lemon-boxes-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@evidence-dev/core-components': patch
'@evidence-dev/tailwind': patch
---

Theming for page background, page text, page header, evidence logo, markdown elements, Alert, Button, Accordion, BigLink, Delta, BigValue, ButtonGroup, Checkbox, and some of DataTable
5 changes: 5 additions & 0 deletions .changeset/purple-pugs-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/component-utilities': patch
---

Switch between echarts light/dark theme depending on selected theme"
5 changes: 5 additions & 0 deletions .changeset/three-lamps-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/sdk': patch
---

Dont throw error when evidence.plugins.yaml isnt found
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ packages/evidence/scripts/svelte.config.js
packages/ui/icons/src

# Don't lint playwright reports
**/playwright-report*
**/playwright-report*

storybook-static
4 changes: 2 additions & 2 deletions e2e/themes/evidence.config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
themes:
light:
mySemanticColor: "#ff0000"
primary: "#ff0000"
dark:
mySemanticColor: "#00ff00"
primary: "#00ff00"

plugins:
components:
Expand Down
8 changes: 4 additions & 4 deletions e2e/themes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"name": "e2e-themes",
"version": "0.0.9",
"scripts": {
"build": "cross-env VITE_EVIDENCE_THEMES=true evidence build",
"build:strict": "cross-env VITE_EVIDENCE_THEMES=true evidence build:strict",
"dev": "cross-env VITE_EVIDENCE_THEMES=true evidence dev",
"build": "cross-env evidence build",
"build:strict": "cross-env evidence build:strict",
"dev": "cross-env evidence dev",
"sources": "evidence sources",
"preview": "cross-env VITE_EVIDENCE_THEMES=true evidence preview",
"preview": "cross-env evidence preview",
"test:preview": "playwright test",
"test:dev": "cross-env DEV=true playwright test"
},
Expand Down
2 changes: 1 addition & 1 deletion e2e/themes/pages/index.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<div data-testid="div-with-background" class="w-20 h-20 bg-mySemanticColor">
<div data-testid="div-with-background" class="w-20 h-20 bg-primary">
</div>
5 changes: 3 additions & 2 deletions packages/evidence/scripts/build-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ fsExtra.outputFileSync(
import { createLogger } from 'vite';
import { sourceQueryHmr } from '@evidence-dev/sdk/vite';
import { isDebug } from '@evidence-dev/sdk/utils';
import { evidenceThemes } from '@evidence-dev/tailwind';

const logger = createLogger();
const loggerWarn = logger.warn;
Expand All @@ -75,7 +76,7 @@ fsExtra.outputFileSync(
/** @type {import('vite').UserConfig} */
const config =
{
plugins: [sveltekit(), evidenceVitePlugin(), sourceQueryHmr()],
plugins: [sveltekit(), evidenceVitePlugin(), sourceQueryHmr(), evidenceThemes()],
optimizeDeps: {
include: ['echarts-stat', 'echarts', 'blueimp-md5', 'nanoid', '@uwdata/mosaic-sql',
// We need these to prevent HMR from doing a full page reload
Expand All @@ -93,7 +94,7 @@ fsExtra.outputFileSync(
])

],
exclude: ['svelte-icons', '@evidence-dev/universal-sql']
exclude: ['svelte-icons', '@evidence-dev/universal-sql', '$evidence/themes']
},
ssr: {
external: ['@evidence-dev/telemetry', 'blueimp-md5', 'nanoid', '@uwdata/mosaic-sql', '@evidence-dev/plugin-connector']
Expand Down
75 changes: 46 additions & 29 deletions packages/lib/component-utilities/src/echarts.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,48 @@
import { registerTheme, init, connect } from 'echarts';
import { evidenceThemeLight } from './echartsThemes';
import { evidenceThemeDark, evidenceThemeLight } from './echartsThemes';
import debounce from 'debounce';
import * as chartWindowDebug from './chartWindowDebug';

/**
* @typedef {import("echarts").EChartsOption & {
* dispatch?: ReturnType<typeof import("svelte").createEventDispatcher>;
* showAllXAxisLabels?: boolean;
* theme: 'light' | 'dark';
* }
* } ActionParams
* } EChartsActionOptions
*/

const ANIMATION_DURATION = 500;

/** @type {import("svelte/action").Action<HTMLElement, ActionParams>} */
export default (node, option) => {
/** @param {HTMLElement} node */
/** @param {EChartsActionOptions} options */
const echartsAction = (node, options) => {
// https://github.com/evidence-dev/evidence/issues/1323
const useSvg =
['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(
navigator.platform
// ios breaks w/ canvas if the canvas is too large
) && node.clientWidth * 3 * node.clientHeight * 3 > 16777215;

registerTheme('evidence-light', evidenceThemeLight);
registerTheme('light', evidenceThemeLight);
registerTheme('dark', evidenceThemeDark);

const chart = init(node, 'evidence-light', {
renderer: useSvg ? 'svg' : (option.renderer ?? 'canvas')
});
let chart;

const initChart = () => {
chart = init(node, options.theme, {
renderer: useSvg ? 'svg' : (options.renderer ?? 'canvas')
});
};

initChart();

chartWindowDebug.set(chart.id, chart);

// If connectGroup supplied, connect chart to other charts matching that connectGroup
if (option.connectGroup) {
chart.group = option.connectGroup;
connect(option.connectGroup);
if (options.connectGroup) {
chart.group = options.connectGroup;
connect(options.connectGroup);
}

// This function applies overrides to the echarts config generated by our chart components.
Expand All @@ -44,19 +53,19 @@ export default (node, option) => {

// Series Color override
const applySeriesColors = () => {
if (option.seriesColors) {
if (options.seriesColors) {
/** @type {import("echarts").EChartsOption} */
const prevOption = chart.getOption();
if (!prevOption) return;
const newOption = { ...prevOption };
for (const seriesName of Object.keys(option.seriesColors)) {
for (const seriesName of Object.keys(options.seriesColors)) {
const matchingSeriesIndex = prevOption.series.findIndex((s) => s.name === seriesName);
if (matchingSeriesIndex !== -1) {
newOption.series[matchingSeriesIndex] = {
...newOption.series[matchingSeriesIndex],
itemStyle: {
...newOption.series[matchingSeriesIndex].itemStyle,
color: option.seriesColors[seriesName]
color: options.seriesColors[seriesName]
}
};
}
Expand All @@ -67,18 +76,18 @@ export default (node, option) => {

// Check if echartsOptions are provided and apply them
const applyEchartsOptions = () => {
if (option.echartsOptions) {
if (options.echartsOptions) {
chart.setOption({
...option.echartsOptions
...options.echartsOptions
});
}
};

// seriesOptions - loop through series and apply same changes to each
const applySeriesOptions = () => {
let tempSeries = [];
if (option.seriesOptions) {
const reference_index = option.config.series.reduce(
if (options.seriesOptions) {
const reference_index = options.config.series.reduce(
(acc, { evidenceSeriesType }, reference_index) => {
if (
evidenceSeriesType === 'reference_line' ||
Expand All @@ -92,11 +101,11 @@ export default (node, option) => {
[]
);

for (let i = 0; i < option.config.series.length; i++) {
for (let i = 0; i < options.config.series.length; i++) {
if (reference_index.includes(i)) {
tempSeries.push({});
} else {
tempSeries.push({ ...option.seriesOptions });
tempSeries.push({ ...options.seriesOptions });
}
}
chart.setOption({ series: tempSeries });
Expand All @@ -105,7 +114,7 @@ export default (node, option) => {

// Initial options set:
chart.setOption({
...option.config,
...options.config,
animationDuration: ANIMATION_DURATION,
animationDurationUpdate: ANIMATION_DURATION
});
Expand All @@ -115,7 +124,7 @@ export default (node, option) => {
applySeriesOptions();

// Click event handler:
const dispatch = option.dispatch;
const dispatch = options.dispatch;
chart.on('click', function (params) {
dispatch('click', params);
});
Expand Down Expand Up @@ -144,7 +153,7 @@ export default (node, option) => {

// Label width setting:
const updateLabelWidths = () => {
if (option.showAllXAxisLabels) {
if (options.showAllXAxisLabels) {
// Make sure we operate on an up-to-date options object
/** @type {import("echarts").EChartsOption} */
const prevOption = chart.getOption();
Expand All @@ -160,7 +169,7 @@ export default (node, option) => {
// We disable this behavior because it doesn't make sense on horizontal bar charts
// Category labels will grow to be visible
// Value labels are interpolatable anyway
if (!option.swapXY) {
if (!options.swapXY) {
/** @type {import("echarts").EChartsOption} */
const newOption = {
xAxis: {
Expand All @@ -176,11 +185,17 @@ export default (node, option) => {
}
};

const updateChart = (newOption) => {
option = newOption;
/** @param {EChartsActionOptions} newOptions */
const updateChart = (newOptions) => {
if (newOptions.theme !== options.theme) {
chart.dispose();
initChart();
}

options = newOptions;
chart.setOption(
{
...option.config,
...options.config,
animationDuration: ANIMATION_DURATION,
animationDurationUpdate: ANIMATION_DURATION
},
Expand All @@ -202,9 +217,9 @@ export default (node, option) => {
window[Symbol.for('chart renders')] ??= 0;
window[Symbol.for('chart renders')]++;
return {
update(option) {
update(options) {
window[Symbol.for('chart renders')]++;
updateChart(option);
updateChart(options);
},
destroy() {
if (resizeObserver) {
Expand All @@ -219,3 +234,5 @@ export default (node, option) => {
}
};
};

export default echartsAction;
5 changes: 3 additions & 2 deletions packages/lib/component-utilities/src/echartsThemes.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,9 @@ export const evidenceThemeDark = {
},
boxplot: {
itemStyle: {
borderWidth: 0,
borderColor: '#cccccc'
borderWidth: 1.5,
borderColor: '#cccccc',
color: '#0a0a0a'
}
},
parallel: {
Expand Down
12 changes: 9 additions & 3 deletions packages/lib/component-utilities/src/stores.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,21 @@ const getStoreVal = (store) => {
return v;
};

/** @template T @typedef {{ serialize: (value: T) => string; deserialize: (raw: string) => T }} SerializeAndDeserialize */

/**
* Implementation of a writable store that also saves it's values to localStorage
* @template T
* @param {string} key localStorage key
* @param {T} init
* @param {SerializeAndDeserialize<T>} [serializeAndDeserialize]
* @returns {Writable<T>}
*/
export const localStorageStore = (key, init) => {
const store = writable(browser ? (JSON.parse(localStorage.getItem(key)) ?? init) : init);
export const localStorageStore = (key, init, serializeAndDeserialize) => {
const serialize = serializeAndDeserialize?.serialize ?? JSON.stringify;
const deserialize = serializeAndDeserialize?.deserialize ?? JSON.parse;

const store = writable(browser ? (deserialize(localStorage.getItem(key)) ?? init) : init);
const { subscribe, set } = store;

/** @type {(v: T) => void} */
Expand All @@ -88,7 +94,7 @@ export const localStorageStore = (key, init) => {
if (typeof v === 'undefined' || v === null) {
localStorage.removeItem(key);
} else {
localStorage.setItem(key, JSON.stringify(v));
localStorage.setItem(key, serialize(v));
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ z = x + y
\`\`\`css
pre {
overflow: scroll;
background: var(--grey-800);
background: var(--neutral);
border-radius: 3px;
display: flex;
flex-direction: row;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const transformQueries = {

target.classList.add('text-xs');
target.classList.add('leading-tight');
target.classList.add('bg-gray-200');
target.classList.add('bg-base-300');
target.classList.add('p-2');
target.classList.add('w-fit');
target.classList.add('min-w-[60ch]');
Expand Down
3 changes: 3 additions & 0 deletions packages/ui/core-components/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { mergeConfig } from 'vite';
import { evidenceThemes } from '@evidence-dev/tailwind';

/** @type { import('@storybook/sveltekit').StorybookConfig } */
const config = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx|svelte)'],
addons: [
'@storybook/addon-essentials',
'@storybook/addon-themes',
'@storybook/addon-interactions',
'@storybook/addon-svelte-csf',
'@chromatic-com/storybook'
Expand All @@ -14,6 +16,7 @@ const config = {
},
async viteFinal(config) {
return mergeConfig(config, {
plugins: [evidenceThemes()],
server: {
fs: {
strict: false
Expand Down
Loading