This repository has been archived by the owner on Dec 20, 2024. It is now read-only.
-
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.
remove defaultProps and update to newer grafana packages
- Loading branch information
1 parent
4b34ad6
commit 7149582
Showing
3 changed files
with
782 additions
and
756 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { css, cx } from '@emotion/css'; | ||
import React, { useCallback } from 'react'; | ||
import React from 'react'; | ||
|
||
import { GrafanaTheme2 } from '@grafana/data'; | ||
import { useStyles2 } from '@grafana/ui'; | ||
|
@@ -13,28 +13,26 @@ export interface SpaceProps { | |
/** | ||
* @deprecated use the Space component from @grafana/ui instead. Available starting from @grafana/[email protected] | ||
*/ | ||
export const Space = (props: SpaceProps) => { | ||
const styles = useStyles2(useCallback((theme) => getStyles(theme, props), [props])); | ||
export const Space = ({ | ||
v = 0, | ||
h = 0, | ||
layout = 'block', | ||
}: SpaceProps) => { | ||
const styles = useStyles2(getStyles, v, h, layout); | ||
|
||
return <span className={cx(styles.wrapper)} />; | ||
}; | ||
|
||
Space.defaultProps = { | ||
v: 0, | ||
h: 0, | ||
layout: 'block', | ||
}; | ||
|
||
const getStyles = (theme: GrafanaTheme2, props: SpaceProps) => ({ | ||
const getStyles = (theme: GrafanaTheme2, v: SpaceProps['v'], h: SpaceProps['v'], layout: SpaceProps['layout']) => ({ | ||
wrapper: css([ | ||
{ | ||
paddingRight: theme.spacing(props.h ?? 0), | ||
paddingBottom: theme.spacing(props.v ?? 0), | ||
paddingRight: theme.spacing(h ?? 0), | ||
paddingBottom: theme.spacing(v ?? 0), | ||
}, | ||
props.layout === 'inline' && { | ||
layout === 'inline' && { | ||
display: 'inline-block', | ||
}, | ||
props.layout === 'block' && { | ||
layout === 'block' && { | ||
display: 'block', | ||
}, | ||
]), | ||
|
Oops, something went wrong.