-
Notifications
You must be signed in to change notification settings - Fork 839
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ massive cleanup/refactor of src-docs theme context, prefer toggle for light/dark mode + remove defunct tour on language selector
- Loading branch information
Showing
12 changed files
with
193 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
packages/eui/src-docs/src/components/guide_locale_selector/guide_locale_selector.js
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
packages/eui/src-docs/src/components/guide_locale_selector/index.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
export { ThemeProvider, ThemeContext } from './theme_context'; | ||
export { | ||
ThemeProvider, | ||
ThemeContext, | ||
type ThemeContextType, | ||
} from './theme_context'; | ||
export { LanguageSelector } from './language_selector'; |
66 changes: 13 additions & 53 deletions
66
packages/eui/src-docs/src/components/with_theme/language_selector.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,35 @@ | ||
import React, { useContext, useState } from 'react'; | ||
import React, { useContext } from 'react'; | ||
|
||
import { | ||
EuiButtonGroup, | ||
EuiIcon, | ||
EuiLink, | ||
EuiText, | ||
EuiTourStep, | ||
} from '../../../../src/components'; | ||
import { EuiButtonGroup } from '../../../../src/components'; | ||
|
||
import { | ||
ThemeContext, | ||
theme_languages, | ||
THEME_LANGUAGES, | ||
} from './theme_context'; | ||
|
||
const NOTIF_STORAGE_KEY = 'js_vs_sass_notification'; | ||
const NOTIF_STORAGE_VALUE = 'dismissed'; | ||
|
||
export const LanguageSelector = ({ | ||
onChange, | ||
showTour = false, | ||
}: { | ||
onChange?: (id: string) => void; | ||
showTour?: boolean; | ||
}) => { | ||
const themeContext = useContext(ThemeContext); | ||
const toggleIdSelected = themeContext.themeLanguage; | ||
const onLanguageChange = (optionId: string) => { | ||
themeContext.changeThemeLanguage(optionId as THEME_LANGUAGES['id']); | ||
themeContext.setContext({ | ||
themeLanguage: optionId as THEME_LANGUAGES['id'], | ||
}); | ||
onChange?.(optionId); | ||
setTourIsOpen(false); | ||
localStorage.setItem(NOTIF_STORAGE_KEY, NOTIF_STORAGE_VALUE); | ||
}; | ||
|
||
const [isTourOpen, setTourIsOpen] = useState( | ||
localStorage.getItem(NOTIF_STORAGE_KEY) === NOTIF_STORAGE_VALUE | ||
? false | ||
: showTour | ||
); | ||
|
||
const onTourDismiss = () => { | ||
setTourIsOpen(false); | ||
localStorage.setItem(NOTIF_STORAGE_KEY, NOTIF_STORAGE_VALUE); | ||
}; | ||
|
||
return ( | ||
<EuiTourStep | ||
content={ | ||
<EuiText style={{ maxWidth: 320 }}> | ||
<p>Select your preferred styling language with this toggle button.</p> | ||
</EuiText> | ||
} | ||
isStepOpen={isTourOpen} | ||
onFinish={onTourDismiss} | ||
step={1} | ||
stepsTotal={1} | ||
title={ | ||
<> | ||
<EuiIcon type="bell" size="s" /> Theming update | ||
</> | ||
} | ||
footerAction={<EuiLink onClick={onTourDismiss}>Got it!</EuiLink>} | ||
> | ||
<EuiButtonGroup | ||
buttonSize="m" | ||
color="accent" | ||
legend="Language selector" | ||
options={theme_languages} | ||
idSelected={toggleIdSelected} | ||
onChange={(id) => onLanguageChange(id)} | ||
/> | ||
</EuiTourStep> | ||
<EuiButtonGroup | ||
buttonSize="m" | ||
color="accent" | ||
legend="Language selector" | ||
options={theme_languages} | ||
idSelected={toggleIdSelected} | ||
onChange={(id) => onLanguageChange(id)} | ||
/> | ||
); | ||
}; |
Oops, something went wrong.