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

Theme customization #7886

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions packages/eui/src-docs/src/views/app_context.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ 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 (
<EuiProvider
cache={{
Expand All @@ -57,6 +61,7 @@ export const AppContext = ({ children }) => {
}}
theme={EUI_THEMES.find((t) => t.value === theme)?.provider}
colorMode={theme.includes('light') ? 'light' : 'dark'}
modify={overrides}
>
<Helmet>
<link
Expand Down
30 changes: 30 additions & 0 deletions packages/eui/src-docs/src/views/theme/customizing/values.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,36 @@ export default () => {
<>
<EuiBottomBar position="sticky">
<EuiFlexGroup responsive={false} justifyContent="flexEnd">
<EuiFlexItem grow={false}>
<EuiButton
onClick={() => {
const overridesJSON = JSON.stringify(
overrides || {},
null,
2
);
localStorage.setItem('kbn-theme-overrides', overridesJSON);
location.reload();
}}
fill
iconType="copyClipboard"
>
Apply to local storage
</EuiButton>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton
onClick={() => {
const overridesJSON = JSON.stringify({}, null, 2);
localStorage.setItem('kbn-theme-overrides', overridesJSON);
location.reload();
}}
fill
iconType="copyClipboard"
>
Reset local storage
</EuiButton>
</EuiFlexItem>
{Object.keys(overrides).length > 0 && (
<>
<EuiFlexItem grow={false}>
Expand Down
Loading