components APIs
- Header
- Button
- Layout
- Footer
- Text
- Box
- Card
- Table
- Loading
- Select
- Loader
- Toolbar
- Icon
- CodeInput
- BottomSheet
- InfoBlock
- LanguageToggle
- ProgressCircles
- Ripple
- Toggle
- Tag
- Input
- Paginator
- Filter
- AsyncSelect
- CatalogBigButton
- ReadMore
- ConditionalWrapper
- LastCheckedDisplay
- PriceLabel
- PageTitle
- CartTable
- CartFinalPriceTable
- LoadingSpin
- InfoModal
- ProductCard
- RecommendCoupon
- PriceVales
- NomalLayout
- Web3ReactManager
- Popups
- CurrencyInput
- TransactionErrorContent
- TransactionConfirmationModal
- ConfirmationModalContent
- DoubleCurrencyLogo
- CustomModal
- CurrencySearchModal
- CurrencyLogo
- NumericalInput
- Logo
- QuestionHelper
- ListLogo
- DataTable
- WalletModal
- CustomTable
- MinimalPositionCard
- RemoveLiquidityModal
- CustomTooltip
- ColoredSlider
- ToggleSwitch
- FormattedPriceImpact
- SettingsModal
- ConfirmSwapModal
- AdvancedSwapDetails
- AddressInput
- LineChart
- StakeSyrupModal
- AccountDetails
- BetaWarningBanner
- AreaChart
- ChartType
- TokensTable
- PairTable
- TopMovers
- BarChart
- TransactionsTable
- StakeQuickModal
- UnstakeQuickModal
- SyrupCard
- CustomMenu
- SearchInput
- CustomSwitch
- FarmCard
- BuyFiatModal
- MoonpayModal
- RewardSlider
- Swap
- AddLiquidity
- PoolFinderModal
- PoolPositionCard
- SwapTokenDetails
- SuperHeader
- GlobalStyles
- PrimaryButton
- SectionTitle
- Section
- AccentSection
- ChainSelection
- CoinSelection
- AddressSelection
- SendAction
- Buttons
- Content
- Particles
- IconButton
- NotSupported
- InputSearch
- RouteGuard
- SearchBar
- FileInput
- GovBanner
- AuthForm
- DomainDetails
- Subnav
- ColumnFilter
- ImportExport
- selectFilter
- TaggedArrayInput
- FacetFilter
- ButtonSingleLine
- TextMultiline
- ButtonSelect
- BottomSheetBehavior
- InfoButton
- BulletPointX
- BulletPointCheck
- Title
- LoadingIcon
- SelectFilterControls
- CORInputForm
- SdnInputForm
- Navbar
- HomeRoute
- AuthRoute
- DocumentDetails
- DocumentStepper
- AddGame
- Auth
- Effectiveness
- Export
- PokemonType
- Moves
- Member
- MoveSelector
- Type
- Natures
- Move
- PokeInfo
- Share
- Badges
- Status
- UpdateSW
- About
- Builder
- Calculator
- Changelog
- Import
- Pokestats
- Report
- Rules
- Settings
- Tracker
- DarkThemeProvider
- NotificationHandler
- Background
- Indicator
- StyledButton
- StyledText
- Illustration
- OnboardingSlider
- FlexList
- AppLayout
- ScrollableList
- Visualization
- DataSearch
- Region
- App
- CompareApiLegend
- CompareApiBreadcrumbs
- CompareApiLink
- CompareApiCard
- ExploreApiBreadcrumbs
- ExploreApiLink
- ExploreApiSearch
- ExploreApiConst
- ApiLoader
- RefreshButton
- Listing
- PriceModal
- ConfirmationModal
- Transition
- AutoComplete
- useInput
- Avatar
- Badge
- Breadcrumbs
- ButtonDropdown
- ButtonGroup
- Capacity
- Checkbox
- Code
- Collapse
- CssBaseline
- GeistProvider
- Description
- Display
- Divider
- Dot
- Drawer
- useModal
- Fieldset
- Grid
- Image
- Keyboard
- Link
- Modal
- Note
- Page
- Pagination
- Popover
- Progress
- Radio
- Rating
- Slider
- Snippet
- Spacer
- Spinner
- Tabs
- Textarea
- Tooltip
- Tree
- useBodyScroll
- useClasses
- useClickAway
- useClipboard
- useCurrentState
- useKeyboard
- KeyMod
- KeyCode
- useMediaQuery
- useTabs
- useToasts
- User
- useTheme
- Themes
- GeistUIThemes
- useAllThemes
- CollapsableDialog
- Map
- IPForm
- IPMenu
- Container
- Parallax
- Nav
- SEO
- BlogNav
- ExtensionCard
- MenuComp
Other Related APIs
components#useAllThemes TypeScript Examples
The following examples show how to use
components#useAllThemes.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: controls.tsx From geist-ui with MIT License | 4 votes |
Controls: React.FC<unknown> = React.memo(() => {
const theme = useTheme()
const { themes } = useAllThemes()
const { switchTheme, updateChineseState } = useConfigs()
const { pathname } = useRouter()
const { locale } = useLocale()
const isChinese = useMemo(() => locale === CHINESE_LANGUAGE_IDENT, [locale])
const nextLocalePath = useMemo(() => {
const nextLocale = isChinese ? ENGLISH_LANGUAGE_IDENT : CHINESE_LANGUAGE_IDENT
return pathname.replace(locale, nextLocale)
}, [locale, pathname])
const hasCustomTheme = useMemo(() => Themes.hasUserCustomTheme(themes), [themes])
const switchThemes = (type: string) => {
switchTheme(type)
if (typeof window === 'undefined' || !window.localStorage) return
window.localStorage.setItem('theme', type)
}
const switchLanguages = () => {
updateChineseState(!isChinese)
Router.push(nextLocalePath)
}
const redirectGithub = () => {
if (typeof window === 'undefined') return
window.open(GITHUB_URL)
}
return (
<div className="wrapper">
<Keyboard
h="28px"
command
font="12px"
className="shortcuts"
title="Command + K to search.">
K
</Keyboard>
<Spacer w={0.75} />
<Button
w="28px"
h="28px"
py={0}
px={0}
onClick={switchLanguages}
title={isChinese ? '切换语言' : 'switch language'}>
<Text font="13px" style={{ fontWeight: 500 }}>
{isChinese ? 'En' : '中'}
</Text>
</Button>
<Spacer w={0.75} />
<Button
w="28px"
h="28px"
py={0}
px={0}
icon={<GitHubIcon />}
onClick={redirectGithub}
title={isChinese ? '代码仓库' : 'GitHub Repository'}
/>
<Spacer w={0.75} />
<Select
scale={0.5}
h="28px"
pure
onChange={switchThemes}
value={theme.type}
title={isChinese ? '切换主题' : 'Switch Themes'}>
<Select.Option value="light">
<span className="select-content">
<SunIcon size={14} /> {isChinese ? '明亮' : 'Light'}
</span>
</Select.Option>
<Select.Option value="dark">
<span className="select-content">
<MoonIcon size={14} /> {isChinese ? '暗黑' : 'Dark'}
</span>
</Select.Option>
{hasCustomTheme && (
<Select.Option value={CUSTOM_THEME_TYPE}>
<span className="select-content">
<UserIcon size={14} /> {CUSTOM_THEME_TYPE}
</span>
</Select.Option>
)}
</Select>
<style jsx>{`
.wrapper {
display: flex;
align-items: center;
}
.wrapper :global(kbd.shortcuts) {
line-height: 28px !important;
cursor: help;
opacity: 0.75;
border: none;
}
.wrapper :global(.select) {
width: 85px;
min-width: 85px;
}
.select-content {
width: auto;
height: 18px;
display: flex;
justify-content: space-between;
align-items: center;
}
.select-content :global(svg) {
margin-right: 10px;
margin-left: 2px;
}
`}</style>
</div>
)
})