-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
8 changed files
with
89 additions
and
35 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
packages/synapse-react-client/src/assets/mui_components/Kinomics.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
6 changes: 3 additions & 3 deletions
6
packages/synapse-react-client/src/assets/mui_components/Proteomics.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { SxProps, Theme } from '@mui/material' | ||
import { spreadSx } from './spreadSx' | ||
|
||
describe('spreadSx', () => { | ||
const sxObject: SxProps<Theme> = { color: 'red' } | ||
const nestedSxObject: SxProps<Theme> = [{ color: 'blue' }] | ||
const sxFunction: SxProps<Theme> = theme => ({ | ||
color: theme.palette.primary.main, | ||
}) | ||
const nestedSxFunction: SxProps<Theme> = [ | ||
theme => ({ color: theme.palette.secondary.main }), | ||
] | ||
|
||
it('Removes undefined sx', () => { | ||
expect(spreadSx(sxObject, undefined)).toEqual([sxObject]) | ||
}) | ||
it('Flattens a nested array', () => { | ||
expect(spreadSx(sxObject, nestedSxObject)).toEqual([ | ||
sxObject, | ||
nestedSxObject[0], | ||
]) | ||
}) | ||
it('Handles a mix of functions and objects', () => { | ||
expect( | ||
spreadSx( | ||
sxObject, | ||
nestedSxObject, | ||
sxFunction, | ||
nestedSxFunction, | ||
undefined, | ||
), | ||
).toEqual([sxObject, nestedSxObject[0], sxFunction, nestedSxFunction[0]]) | ||
}) | ||
}) |
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,14 @@ | ||
import { Theme } from '@mui/material' | ||
import { SxProps } from '@mui/system' | ||
|
||
/** | ||
* Utility to combine multiple SxProps into a single SxProps object that can be passed to a component. | ||
* | ||
* See https://github.com/mui/material-ui/issues/29274#issuecomment-953980228 | ||
* @param sxProps | ||
*/ | ||
export function spreadSx( | ||
...sxProps: (SxProps<Theme> | undefined)[] | ||
): SxProps<Theme> { | ||
return sxProps.filter(sx => sx !== undefined).flat() | ||
} |