Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
remove defaultProps and update to newer grafana packages
Browse files Browse the repository at this point in the history
  • Loading branch information
ashharrison90 committed May 13, 2024
1 parent 4b34ad6 commit 7149582
Show file tree
Hide file tree
Showing 3 changed files with 782 additions and 756 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
"rxjs": "7.8.0"
},
"devDependencies": {
"@grafana/data": "^10.0.0",
"@grafana/e2e-selectors": "^10.0.0",
"@grafana/data": "^10.4.0",
"@grafana/e2e-selectors": "^10.4.0",
"@grafana/eslint-config": "^6.0.0",
"@grafana/runtime": "^10.0.0",
"@grafana/runtime": "^10.4.0",
"@grafana/tsconfig": "^1.3.0-rc1",
"@grafana/ui": "^10.0.0",
"@grafana/ui": "^10.4.0",
"@rollup/plugin-node-resolve": "15.0.1",
"@swc/core": "^1.3.56",
"@swc/jest": "^0.2.26",
Expand Down
26 changes: 12 additions & 14 deletions src/QueryEditor/Space.tsx
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';
Expand All @@ -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',
},
]),
Expand Down
Loading

0 comments on commit 7149582

Please sign in to comment.