Skip to content

Commit

Permalink
chore: Moves Card to the components folder
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina committed Apr 22, 2021
1 parent c760030 commit 4054ccf
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 17 deletions.
5 changes: 5 additions & 0 deletions superset-frontend/.storybook/preview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@ addParameters({
{ name: 'Medium', value: '32px', default: true },
{ name: 'Large', value: '64px' },
],
options: {
storySort: {
method: 'alphabetical',
},
},
});
2 changes: 1 addition & 1 deletion superset-frontend/src/SqlLab/components/QueryTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import React, { useMemo } from 'react';
import PropTypes from 'prop-types';
import moment from 'moment';
import Card from 'src/common/components/Card';
import Card from 'src/components/Card';
import ProgressBar from 'src/components/ProgressBar';
import Label from 'src/components/Label';
import { t } from '@superset-ui/core';
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/SqlLab/components/TableElement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/
import React from 'react';
import PropTypes from 'prop-types';
import Card from 'src/common/components/Card';
import Collapse from 'src/components/Collapse';
import Card from 'src/components/Card';
import ButtonGroup from 'src/components/ButtonGroup';
import shortid from 'shortid';
import { t, styled } from '@superset-ui/core';
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/common/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export { default as List, ListItemProps } from 'antd/lib/list';

export { default as Collapse } from 'src/components/Collapse';
export { default as Badge } from 'src/components/Badge';
export { default as Card } from './Card';
export { default as Card } from 'src/components/Card';
export { default as Progress } from 'src/components/ProgressBar';

export const MenuItem = styled(AntdMenu.Item)`
Expand Down
58 changes: 58 additions & 0 deletions superset-frontend/src/components/Card/Card.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* 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 React from 'react';
import Card, { CardProps } from '.';

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

export const InteractiveCard = (args: CardProps) => <Card {...args} />;

InteractiveCard.args = {
padded: true,
title: 'Card title',
children: 'Card content',
bordered: true,
loading: false,
hoverable: false,
};

InteractiveCard.argTypes = {
onClick: {
table: {
disable: true,
},
action: 'onClick',
},
theme: {
table: {
disable: true,
},
},
};

InteractiveCard.story = {
parameters: {
knobs: {
disable: true,
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,24 @@
* under the License.
*/
import React from 'react';
import { styled } from '@superset-ui/core';
import { SupersetTheme } from '@superset-ui/core';
import AntdCard, { CardProps as AntdCardProps } from 'antd/lib/card';

interface CardProps extends AntdCardProps {
export interface CardProps extends AntdCardProps {
padded?: boolean;
}

const Card = styled(({ padded, ...props }: CardProps) => (
<AntdCard {...props} />
))`
background-color: ${({ theme }) => theme.colors.grayscale.light4};
border-radius: ${({ theme }) => theme.borderRadius}px;
.ant-card-body {
padding: ${({ padded, theme }) =>
padded ? theme.gridUnit * 4 : theme.gridUnit}px;
}
`;
const Card = ({ padded, ...props }: CardProps) => (
<AntdCard
{...props}
css={(theme: SupersetTheme) => ({
backgroundColor: theme.colors.grayscale.light4,
borderRadius: theme.borderRadius,
'.ant-card-body': {
padding: padded ? theme.gridUnit * 4 : theme.gridUnit,
},
})}
/>
);

export default Card;
2 changes: 1 addition & 1 deletion superset-frontend/src/datasource/DatasourceEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Col } from 'react-bootstrap';
import Card from 'src/common/components/Card';
import { Radio } from 'src/components/Radio';
import Card from 'src/components/Card';
import Alert from 'src/components/Alert';
import Badge from 'src/components/Badge';
import shortid from 'shortid';
Expand Down

0 comments on commit 4054ccf

Please sign in to comment.