-
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.
[SALAD-23118] WebApp: Reusable modal component / GetNotifiedDemandCha…
…ngesModal - added (#1232) * ModalWithOverlay component - added * ModalWithOverlay: unnecessary prop - removed * temp * GetNotifiedDemandChangesModal - added * ModalWithOverlay import - simplified * GetNotifiedDemandChangesModal appears on Get Notified Button click * Demand Monitor UI: styling - improved * ReviewAfterRedemption: styling - fixed * ModalWithOverlay: styles - improved * ReviewAfterRedemption: textarea area width increased
- Loading branch information
Showing
18 changed files
with
387 additions
and
174 deletions.
There are no files selected for viewing
File renamed without changes.
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
43 changes: 43 additions & 0 deletions
43
packages/web-app/src/components/Dropdown/DropdownLight/DropdownLight.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,43 @@ | ||
import type { FC } from 'react' | ||
import type { CSSObjectWithLabel } from 'react-select' | ||
import { DefaultTheme } from '../../../SaladTheme' | ||
import type { DropdownStylesConfig } from '../Dropdown' | ||
import { Dropdown, type Props } from '../Dropdown' | ||
|
||
const dropdownLightStyles: DropdownStylesConfig = { | ||
control: (baseStyles: CSSObjectWithLabel) => ({ | ||
...baseStyles, | ||
backgroundColor: DefaultTheme.lightGreen, | ||
width: '230px', | ||
borderRadius: 0, | ||
}), | ||
menu: (baseStyles: CSSObjectWithLabel) => ({ | ||
...baseStyles, | ||
color: DefaultTheme.darkBlue, | ||
backgroundColor: DefaultTheme.lightGreen, | ||
}), | ||
option: (baseStyles: CSSObjectWithLabel, state: { isSelected: boolean; isFocused: boolean }) => { | ||
let backgroundColor = DefaultTheme.lightGreen | ||
if (state.isSelected) { | ||
backgroundColor = DefaultTheme.darkBlue | ||
} else if (state.isFocused) { | ||
backgroundColor = DefaultTheme.green | ||
} | ||
|
||
return { | ||
...baseStyles, | ||
backgroundColor, | ||
color: state.isSelected ? DefaultTheme.lightGreen : DefaultTheme.darkBlue, | ||
cursor: 'pointer', | ||
} | ||
}, | ||
singleValue: (baseStyles: CSSObjectWithLabel) => ({ | ||
...baseStyles, | ||
transition: 'opacity 300ms', | ||
color: DefaultTheme.darkBlue, | ||
}), | ||
} | ||
|
||
export const DropdownLight: FC<Omit<Props, 'customStyles' | 'classes'>> = ({ options, value, onChange }) => { | ||
return <Dropdown customStyles={dropdownLightStyles} options={options} value={value} onChange={onChange} /> | ||
} |
1 change: 1 addition & 0 deletions
1
packages/web-app/src/components/Dropdown/DropdownLight/index.ts
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 @@ | ||
export * from './DropdownLight' |
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,2 @@ | ||
export * from './Dropdown' | ||
export * from './DropdownLight' |
61 changes: 61 additions & 0 deletions
61
packages/web-app/src/components/ModalWithOverlay/ModalWithOverlay.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,61 @@ | ||
import { X } from '@saladtechnologies/garden-icons' | ||
import type CSS from 'csstype' | ||
import type { FC } from 'react' | ||
import { useRef } from 'react' | ||
import type { WithStyles } from 'react-jss' | ||
import withStyles from 'react-jss' | ||
import { useDetectClickOutsideElement } from '../../hooks/useDetectClickOutsideElement' | ||
import type { SaladTheme } from '../../SaladTheme' | ||
|
||
const styles: (theme: SaladTheme) => Record<string, CSS.Properties> = (theme: SaladTheme) => ({ | ||
modalOverlay: { | ||
position: 'fixed', | ||
width: '100%', | ||
height: '100%', | ||
zIndex: 1000000000, | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
backgroundColor: '#00000070', | ||
fontFamily: theme.fontMallory, | ||
top: '0px', | ||
left: '0px', | ||
}, | ||
modalContainer: { | ||
position: 'relative', | ||
backgroundColor: theme.darkBlue, | ||
overflow: 'hidden', | ||
boxSizing: 'border-box', | ||
}, | ||
closeIcon: { | ||
position: 'absolute', | ||
right: '16px', | ||
top: '16px', | ||
color: theme.lightGreen, | ||
width: '16px', | ||
height: '16px', | ||
cursor: 'pointer', | ||
}, | ||
}) | ||
|
||
interface Props extends WithStyles<typeof styles> { | ||
onCloseClick: () => void | ||
children: JSX.Element | ||
} | ||
|
||
const _ModalWithOverlay: FC<Props> = ({ classes, onCloseClick, children }) => { | ||
const modalContainerRef = useRef(null) | ||
|
||
useDetectClickOutsideElement(modalContainerRef, onCloseClick) | ||
|
||
return ( | ||
<div className={classes.modalOverlay}> | ||
<div className={classes.modalContainer} ref={modalContainerRef}> | ||
{children} | ||
<X className={classes.closeIcon} onClick={onCloseClick} /> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export const ModalWithOverlay = withStyles(styles)(_ModalWithOverlay) |
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 @@ | ||
export * from './ModalWithOverlay' |
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.