forked from elastic/eui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Docs] Add ThemeLanguages and new Breakpoints page (elastic#5227)
* Added a ThemeSelector for optionally showing/changing content based on JS or Sass theming language * Added some theme helper components like alert banners, values table, and example row * [Manual] Copied the outputs json version of Sass for easier consumption in docs rather that sass-loader * Rearranging sidenav to promote Theme section and adding “Breakpoints” * Fixed some routing and notices
- Loading branch information
Showing
33 changed files
with
3,987 additions
and
278 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
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
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 +1,2 @@ | ||
export { ThemeProvider, ThemeContext } from './theme_context'; | ||
export { LanguageSelector } from './language_selector'; |
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React, { useContext, useState } from 'react'; | ||
|
||
import { | ||
EuiButtonGroup, | ||
EuiIcon, | ||
EuiLink, | ||
EuiText, | ||
EuiTourStep, | ||
} from '../../../../src/components'; | ||
|
||
import { | ||
ThemeContext, | ||
theme_languages, | ||
THEME_LANGUAGES, | ||
} from './theme_context'; | ||
|
||
const NOTIF_STORAGE_KEY = 'js_vs_sass_notification'; | ||
|
||
export const LanguageSelector = ({ | ||
onChange, | ||
}: { | ||
onChange?: (id: string) => void; | ||
}) => { | ||
const themeContext = useContext(ThemeContext); | ||
const toggleIdSelected = themeContext.themeLanguage; | ||
const onLanguageChange = (optionId: string) => { | ||
themeContext.changeThemeLanguage(optionId as THEME_LANGUAGES['id']); | ||
onChange?.(optionId); | ||
setTourIsOpen(false); | ||
localStorage.setItem(NOTIF_STORAGE_KEY, 'dismissed'); | ||
}; | ||
|
||
const [isTourOpen, setTourIsOpen] = useState( | ||
localStorage.getItem(NOTIF_STORAGE_KEY) !== 'dismissed' | ||
); | ||
|
||
const onTourDismiss = () => { | ||
setTourIsOpen(false); | ||
localStorage.setItem(NOTIF_STORAGE_KEY, 'dismissed'); | ||
}; | ||
|
||
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> | ||
); | ||
}; |
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
Oops, something went wrong.