-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add notifications preference block to the profile page
- Loading branch information
Showing
3 changed files
with
134 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,85 @@ | ||
import type { ReactNode } from 'react' | ||
import { Component } from 'react' | ||
import classNames from 'classnames' | ||
import type { FC } from 'react' | ||
import type { WithStyles } from 'react-jss' | ||
import withStyles from 'react-jss' | ||
import type { OptionsOrGroups } from 'react-select' | ||
import type { OptionProps, OptionsOrGroups } from 'react-select' | ||
import Select from 'react-select' | ||
import type { SaladTheme } from '../SaladTheme' | ||
|
||
const styles = (theme: SaladTheme) => ({ | ||
container: { | ||
color: theme.lightGreen, | ||
}, | ||
dark: { | ||
fontFamily: theme.fontGroteskBook19, | ||
fontSize: 12, | ||
color: theme.lightGreen, | ||
}, | ||
light: { | ||
fontFamily: theme.fontMallory, | ||
fontSize: 16, | ||
}, | ||
}) | ||
|
||
interface Props extends WithStyles<typeof styles> { | ||
type?: 'dark' | 'light' | ||
options?: OptionsOrGroups<any, any> | ||
onChange?: (value?: any) => void | ||
} | ||
|
||
const customStyles = { | ||
singleValue: (provided: any, state: any) => { | ||
const opacity = state.isDisabled ? 0.5 : 1 | ||
const transition = 'opacity 300ms' | ||
const color = '#DBF1C1' | ||
const darkColorsTheme = { | ||
neutral0: '#0A2133', | ||
primary25: '#1F4F22', | ||
primary: '#DBF1C1', | ||
primary50: '#B2D530', | ||
neutral20: '#DBF1C1', | ||
} | ||
|
||
return { ...provided, opacity, transition, color } | ||
}, | ||
const lightColorsTheme = { | ||
primary: 'transparent', | ||
neutral20: '#0A2133', | ||
primary25: '#DBF1C1', | ||
primary50: '#B2D530', | ||
} | ||
|
||
class _Dropdown extends Component<Props> { | ||
public override render(): ReactNode { | ||
const { options, onChange, classes } = this.props | ||
|
||
return ( | ||
<Select | ||
className={classes.container} | ||
options={options} | ||
onChange={onChange} | ||
defaultValue={options && options[0]} | ||
styles={customStyles} | ||
theme={(selectTheme) => ({ | ||
// TODO: Get the theme data using react-jss | ||
...selectTheme, | ||
borderRadius: 0, | ||
colors: { | ||
...selectTheme.colors, | ||
neutral0: '#0A2133', | ||
primary25: '#1F4F22', | ||
primary: '#DBF1C1', | ||
neutral20: '#DBF1C1', | ||
}, | ||
})} | ||
/> | ||
) | ||
const _Dropdown: FC<Props> = ({ classes, type = 'dark', options, onChange }) => { | ||
const customStyles = { | ||
option: (styles: any, { isSelected }: OptionProps) => { | ||
return { | ||
...styles, | ||
color: type === 'dark' ? styles.color : isSelected ? '#53A626' : '#0A2133', | ||
cursor: 'pointer', | ||
} | ||
}, | ||
singleValue: (provided: any, state: any) => { | ||
const opacity = state.isDisabled ? 0.5 : 1 | ||
const transition = 'opacity 300ms' | ||
const colorValue = type === 'dark' ? '#DBF1C1' : '#0A2133' | ||
|
||
return { ...provided, opacity, transition, color: colorValue } | ||
}, | ||
} | ||
|
||
return ( | ||
<Select | ||
className={classNames(classes.container, { | ||
[classes.dark]: type === 'dark', | ||
[classes.light]: type === 'light', | ||
})} | ||
options={options} | ||
onChange={onChange} | ||
defaultValue={options && options[0]} | ||
styles={customStyles} | ||
theme={(selectTheme) => ({ | ||
// TODO: Get the theme data using react-jss | ||
...selectTheme, | ||
borderRadius: 0, | ||
colors: { | ||
...selectTheme.colors, | ||
...(type === 'dark' ? darkColorsTheme : lightColorsTheme), | ||
}, | ||
})} | ||
/> | ||
) | ||
} | ||
|
||
export const Dropdown = withStyles(styles)(_Dropdown) |
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
10 changes: 10 additions & 0 deletions
10
packages/web-app/src/modules/account-views/account-views/components/assets/constants.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,10 @@ | ||
export const accountNotificationPreferenceDropdownOptions = [ | ||
{ | ||
label: 'Enabled', | ||
value: true, | ||
}, | ||
{ | ||
label: 'Disabled', | ||
value: false, | ||
}, | ||
] |