From 74ee5d97052d87b9375a7468cf8fbaffbe10bb1d Mon Sep 17 00:00:00 2001 From: Jason Stoltzfus Date: Fri, 12 Jul 2024 12:18:33 -0400 Subject: [PATCH 1/3] read theme from localStorage --- packages/eui/src-docs/src/views/app_context.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/eui/src-docs/src/views/app_context.js b/packages/eui/src-docs/src/views/app_context.js index 606ce277bb1..33a314348ff 100644 --- a/packages/eui/src-docs/src/views/app_context.js +++ b/packages/eui/src-docs/src/views/app_context.js @@ -49,6 +49,8 @@ export const AppContext = ({ children }) => { const isLocalDev = window.location.host.includes('803'); setEuiDevProviderWarning(isLocalDev ? 'error' : 'warn'); // Note: this can't be in a useEffect, otherwise it fires too late for style memoization warnings to error on page reload + const overrides = JSON.parse(localStorage.getItem('kbn-theme-overrides') || '{}'); + return ( { }} theme={EUI_THEMES.find((t) => t.value === theme)?.provider} colorMode={theme.includes('light') ? 'light' : 'dark'} + modify={overrides} > Date: Fri, 12 Jul 2024 12:25:54 -0400 Subject: [PATCH 2/3] localstorage things --- .../src/views/theme/customizing/values.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/eui/src-docs/src/views/theme/customizing/values.tsx b/packages/eui/src-docs/src/views/theme/customizing/values.tsx index e9980cd6d28..1111a1beed9 100644 --- a/packages/eui/src-docs/src/views/theme/customizing/values.tsx +++ b/packages/eui/src-docs/src/views/theme/customizing/values.tsx @@ -131,6 +131,24 @@ export default () => { <> + + { + const overridesJSON = JSON.stringify(overrides || {}, null, 2) + localStorage.setItem('kbn-theme-overrides', overridesJSON); + location.reload(); + }} fill iconType="copyClipboard"> + Apply to local storage + + + + { + const overridesJSON = JSON.stringify({}, null, 2) + localStorage.setItem('kbn-theme-overrides', overridesJSON); + location.reload(); + }} fill iconType="copyClipboard"> + Reset local storage + + {Object.keys(overrides).length > 0 && ( <> From 3d927ba204e59b20b0d73e43938e8ade06f8ccac Mon Sep 17 00:00:00 2001 From: Jason Stoltzfus Date: Sat, 13 Jul 2024 10:11:15 -0400 Subject: [PATCH 3/3] liiiiiiiint --- .../eui/src-docs/src/views/app_context.js | 4 ++- .../src/views/theme/customizing/values.tsx | 32 +++++++++++++------ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/packages/eui/src-docs/src/views/app_context.js b/packages/eui/src-docs/src/views/app_context.js index 33a314348ff..4259754211b 100644 --- a/packages/eui/src-docs/src/views/app_context.js +++ b/packages/eui/src-docs/src/views/app_context.js @@ -49,7 +49,9 @@ export const AppContext = ({ children }) => { const isLocalDev = window.location.host.includes('803'); setEuiDevProviderWarning(isLocalDev ? 'error' : 'warn'); // Note: this can't be in a useEffect, otherwise it fires too late for style memoization warnings to error on page reload - const overrides = JSON.parse(localStorage.getItem('kbn-theme-overrides') || '{}'); + const overrides = JSON.parse( + localStorage.getItem('kbn-theme-overrides') || '{}' + ); return ( { - { - const overridesJSON = JSON.stringify(overrides || {}, null, 2) - localStorage.setItem('kbn-theme-overrides', overridesJSON); - location.reload(); - }} fill iconType="copyClipboard"> + { + const overridesJSON = JSON.stringify( + overrides || {}, + null, + 2 + ); + localStorage.setItem('kbn-theme-overrides', overridesJSON); + location.reload(); + }} + fill + iconType="copyClipboard" + > Apply to local storage - { - const overridesJSON = JSON.stringify({}, null, 2) - localStorage.setItem('kbn-theme-overrides', overridesJSON); - location.reload(); - }} fill iconType="copyClipboard"> + { + const overridesJSON = JSON.stringify({}, null, 2); + localStorage.setItem('kbn-theme-overrides', overridesJSON); + location.reload(); + }} + fill + iconType="copyClipboard" + > Reset local storage