-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add account icon theme options (#1612)
- Loading branch information
Showing
12 changed files
with
256 additions
and
142 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
54 changes: 54 additions & 0 deletions
54
packages/extension-polkagate/src/components/SelectIdenticonTheme.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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import type { IconTheme } from '@polkadot/react-identicon/types'; | ||
|
||
import { Grid, type SxProps, type Theme } from '@mui/material'; | ||
import { t } from 'i18next'; | ||
import React, { useCallback, useContext } from 'react'; | ||
|
||
import { AccountIconThemeContext } from './contexts'; | ||
import { setStorage } from './Loading'; | ||
import Select2 from './Select2'; | ||
|
||
interface Props { | ||
style?: SxProps<Theme> | undefined; | ||
} | ||
|
||
const THEME_OPTIONS = [ | ||
{ text: 'Dot', value: 'polkadot' }, | ||
{ text: 'Ball', value: 'beachball' }, | ||
{ text: 'Cube', value: 'ethereum' } | ||
]; | ||
|
||
function SelectIdenticonTheme ({ style = {} }: Props) { | ||
const { accountIconTheme, setAccountIconTheme } = useContext(AccountIconThemeContext); | ||
|
||
const onChangeTheme = useCallback((iconTheme: string | number) => { | ||
setStorage('iconTheme', iconTheme).catch(console.error); | ||
setAccountIconTheme(iconTheme as IconTheme); | ||
}, [setAccountIconTheme]); | ||
|
||
return ( | ||
<Grid | ||
container | ||
item | ||
sx={{ ...style }} | ||
> | ||
<Select2 | ||
defaultValue={accountIconTheme} | ||
isIdenticon | ||
label={t('Account Icon')} | ||
labelAlignment='flex-start' | ||
labelFontSize='14px' | ||
labelPaddingLeft='0px' | ||
onChange={onChangeTheme} | ||
options={THEME_OPTIONS} | ||
rounded={false} | ||
textFontSize='18px' | ||
/> | ||
</Grid> | ||
); | ||
} | ||
|
||
export default React.memo(SelectIdenticonTheme); |
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
Oops, something went wrong.