Skip to content

Commit

Permalink
refactor(space): Migrate Space to Ant Design 5
Browse files Browse the repository at this point in the history
  • Loading branch information
msyavuz committed Jan 3, 2025
1 parent 91d1648 commit 1512e08
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 3 deletions.
60 changes: 60 additions & 0 deletions superset-frontend/src/components/Space/Space.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/*
* Re-exporting of components in src/components to facilitate
* their imports by other components.
* E.g. import { Select } from 'src/components'
*/

import { Space, SpaceProps } from 'src/components/Space';

export default {
title: 'Space',
component: Space,
};

export const InteractiveSpace = (args: SpaceProps) => (
<Space {...args}>
{new Array(20).fill(null).map((_, i) => (
<p key={i}>Item</p>
))}
</Space>
);

InteractiveSpace.args = {
direction: 'horizontal',
size: 'small',
wrap: 'false',
};

InteractiveSpace.argTypes = {
align: {
control: { type: 'select' },
options: ['start', 'end', 'center', 'baseline', ''],
},
direction: {
control: { type: 'select' },
options: ['vertical', 'horizontal'],
},
size: {
control: { type: 'select' },
options: ['small', 'middle', 'large'],
},
};
26 changes: 26 additions & 0 deletions superset-frontend/src/components/Space/Space.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { render } from 'spec/helpers/testing-library';
import { Space } from '.';

test('should render', () => {
const { container } = render(<Space />);
expect(container).toBeInTheDocument();
});
33 changes: 33 additions & 0 deletions superset-frontend/src/components/Space/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/*
* Re-exporting of components in src/components to facilitate
* their imports by other components.
* E.g. import { Select } from 'src/components'
*/

import { Space as AntdSpace } from 'antd-v5';
import type { SpaceProps } from 'antd-v5/es/space';

export function Space(props: SpaceProps) {
return <AntdSpace {...props} />;
}

export { SpaceProps };
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import { useState } from 'react';
import { css, useTheme } from '@superset-ui/core';
import { Radio } from 'src/components/Radio';
import { Space } from 'src/components';
import { Space } from 'src/components/Space';
import Icons from 'src/components/Icons';
import Popover from 'src/components/Popover';

Expand Down
1 change: 0 additions & 1 deletion superset-frontend/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export {
Grid,
Row,
Skeleton,
Space,
Steps,
Tag,
Tree,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
import { Global } from '@emotion/react';
import { Column } from 'react-table';
import { debounce } from 'lodash';
import { Space } from 'src/components';
import { Space } from 'src/components/Space';
import { Input } from 'src/components/Input';
import {
BOOL_FALSE_DISPLAY,
Expand Down

0 comments on commit 1512e08

Please sign in to comment.