-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve filter selection and editing behavior (#3265)
* feat: create ReadOnly component to block editing and show a message * refactor: reverse the order of filter action buttons * refactor: apodization filter restore,reset,save, and cancel actions * refactor: baseline correction filter restore,reset,save, and cancel actions * refactor: zero filling filter restore,reset,save, and cancel actions * refactor: exclusion zones filter restore,reset,save, and cancel actions * refactor: pashe correction filter restore,reset,save, and cancel actions * refactor: shift filter restore,reset,save, and cancel actions * test: fix selectors * refactor: filter action buttons * fix: enable editing just in the active filter * refactor: rename reset button titles * refactor: do not reset the spectrum after applying changes
- Loading branch information
1 parent
ea224b8
commit 5fa9fd1
Showing
26 changed files
with
523 additions
and
481 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** @jsxImportSource @emotion/react */ | ||
import { keyframes } from '@emotion/react'; | ||
import styled from '@emotion/styled'; | ||
import { ReactNode, useState } from 'react'; | ||
import { IoLockClosedOutline } from 'react-icons/io5'; | ||
|
||
const fadeIn = keyframes` | ||
from { | ||
opacity: 0; | ||
transform: translateY(-10px); | ||
} | ||
to { | ||
opacity: 1; | ||
transform: translateY(0); | ||
} | ||
`; | ||
|
||
const Overlay = styled.div` | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
cursor: not-allowed; | ||
`; | ||
|
||
const MessageContainer = styled.div<{ show: boolean }>` | ||
background-color: white; | ||
padding: 16px; | ||
border-radius: 5px; | ||
align-items: center; | ||
box-shadow: 0 2px 10px rgb(0 0 0 / 10%); | ||
display: ${({ show }) => (show ? 'flex' : 'none')}; | ||
animation: ${fadeIn} 0.3s ease; | ||
gap: 8px; | ||
`; | ||
|
||
interface ReadOnlyProps { | ||
enabled: boolean; | ||
children: ReactNode; | ||
message?: string; | ||
messageDisplayDuration?: number; | ||
} | ||
|
||
export function ReadOnly(props: ReadOnlyProps) { | ||
const { | ||
enabled, | ||
children, | ||
message = 'Read only', | ||
messageDisplayDuration = 800, | ||
} = props; | ||
const [showMessage, setShowMessage] = useState(false); | ||
|
||
function handleOverlayClick() { | ||
setShowMessage(true); | ||
setTimeout(() => setShowMessage(false), messageDisplayDuration); | ||
} | ||
|
||
return ( | ||
<div style={{ position: 'relative' }}> | ||
{children} | ||
{enabled && ( | ||
<Overlay | ||
onClick={handleOverlayClick} | ||
style={{ backdropFilter: showMessage ? 'blur(1px)' : 'none' }} | ||
> | ||
<MessageContainer show={showMessage}> | ||
<IoLockClosedOutline fontSize={18} /> | ||
<span>{message}</span> | ||
</MessageContainer> | ||
</Overlay> | ||
)} | ||
</div> | ||
); | ||
} |
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
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.