Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create table component based on ant design Table #21520

Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
0357202
ant design Table component work in progress
eric-briscoe Jul 30, 2022
c58edf1
Merge branch 'master' into ericbriscoe/sc-51384/create-table-componen…
eric-briscoe Aug 22, 2022
3409c07
Merge branch 'master' into ericbriscoe/sc-51384/create-table-componen…
eric-briscoe Aug 23, 2022
bdd1460
Work in progress, enabled resizeable columns in Table, added draft de…
eric-briscoe Aug 26, 2022
0d2ca7a
Update DesignSystem.stories.mdx
eric-briscoe Aug 26, 2022
bf9dd0a
Merge branch 'master' into ericbriscoe/sc-51384/create-table-componen…
eric-briscoe Aug 28, 2022
3a9d2ea
Merge branch 'master' into ericbriscoe/sc-51384/create-table-componen…
eric-briscoe Sep 12, 2022
668185f
Updates documentation, adds tests, separates resizable column and dra…
eric-briscoe Sep 19, 2022
367009c
Merge branch 'master' into ericbriscoe/sc-51384/create-table-componen…
eric-briscoe Sep 19, 2022
c99f556
Updates to markdown overview docs for table and additional Storybook …
eric-briscoe Sep 19, 2022
89f779e
Adds numeric cell renderer, updated buton cell renderer, adds documen…
eric-briscoe Sep 20, 2022
571a4b2
Cell renderer work in progress
eric-briscoe Sep 22, 2022
82674d6
Merge branch 'master' into ericbriscoe/sc-51384/create-table-componen…
eric-briscoe Oct 11, 2022
75b68f5
Fixes Lint and TS errors
eric-briscoe Oct 21, 2022
400e3d9
Improving folder structure, adding additional tests
eric-briscoe Oct 24, 2022
ee7521a
Merge branch 'master' into ericbriscoe/sc-51384/create-table-componen…
eric-briscoe Oct 24, 2022
f4b2017
Removes unnecessary code causing an import error
eric-briscoe Oct 28, 2022
a8e7f05
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 7, 2022
33f4c69
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 7, 2022
49d456d
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 7, 2022
d355c7d
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 7, 2022
3c5d543
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 7, 2022
d28af9a
Update superset-frontend/src/components/Table/index.tsx
eric-briscoe Nov 7, 2022
0180d67
Update superset-frontend/src/components/Table/sorters.test.ts
eric-briscoe Nov 7, 2022
31d13bb
Update superset-frontend/src/components/Table/utils/utils.ts
eric-briscoe Nov 7, 2022
3306524
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 7, 2022
60c306b
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 7, 2022
8dab6ff
Update superset-frontend/src/components/Table/index.tsx
eric-briscoe Nov 7, 2022
5dd4376
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 7, 2022
60c13f8
Update superset-frontend/src/components/Table/cell-renderers/ActionCe…
eric-briscoe Nov 7, 2022
9d5ef1e
Update superset-frontend/src/components/Table/cell-renderers/ActionCe…
eric-briscoe Nov 7, 2022
d86ebce
Update superset-frontend/src/components/Table/cell-renderers/ActionCe…
eric-briscoe Nov 7, 2022
aabe653
Update superset-frontend/src/components/Table/cell-renderers/ActionCe…
eric-briscoe Nov 7, 2022
62aba0a
Update superset-frontend/src/components/Table/index.tsx
eric-briscoe Nov 7, 2022
200e582
Update superset-frontend/src/components/Table/index.tsx
eric-briscoe Nov 7, 2022
8ca700e
Updates addressing PR comments for ACT Test errors, removal to type: …
eric-briscoe Nov 7, 2022
6170190
Merge branch 'ericbriscoe/sc-51384/create-table-component-based-on-an…
eric-briscoe Nov 7, 2022
7417321
Remove addition to global style for action cell shadows
eric-briscoe Nov 7, 2022
f30422f
Merge branch 'master' into ericbriscoe/sc-51384/create-table-componen…
eric-briscoe Nov 7, 2022
6dec34c
Removing storybook log file which should not have bend comitted
eric-briscoe Nov 7, 2022
bd16641
Update superset-frontend/src/components/DesignSystem.stories.mdx
eric-briscoe Nov 8, 2022
ca0a2d9
Update superset-frontend/src/components/DesignSystem.stories.mdx
eric-briscoe Nov 8, 2022
1fd223b
Update superset-frontend/src/components/Table/index.tsx
eric-briscoe Nov 8, 2022
648c8fd
Update superset-frontend/src/components/Table/index.tsx
eric-briscoe Nov 8, 2022
00c258b
Update superset-frontend/src/components/Table/index.tsx
eric-briscoe Nov 8, 2022
2fd2589
Update superset-frontend/src/components/Table/index.tsx
eric-briscoe Nov 8, 2022
488e6ba
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 8, 2022
5aa6c9e
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 8, 2022
af08fb5
Update superset-frontend/src/components/Table/cell-renderers/NumericC…
eric-briscoe Nov 8, 2022
d81cfaa
Update superset-frontend/src/components/Table/cell-renderers/NumericC…
eric-briscoe Nov 8, 2022
83495e3
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 8, 2022
b7889be
Update superset-frontend/src/components/Table/Table.test.tsx
eric-briscoe Nov 8, 2022
0d9f650
Update superset-frontend/src/components/Table/cell-renderers/ActionCe…
eric-briscoe Nov 8, 2022
cb12a4c
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 8, 2022
34c5b02
Update superset-frontend/src/components/Table/cell-renderers/ActionCe…
eric-briscoe Nov 8, 2022
4d63da8
Update superset-frontend/src/components/Table/cell-renderers/ActionCe…
eric-briscoe Nov 8, 2022
26af43d
Addresses PR comments
eric-briscoe Nov 8, 2022
11d230c
Apply suggestions from code review
eric-briscoe Nov 8, 2022
109feae
Consolidates initializeInteractiveTable function into the useEffect i…
eric-briscoe Nov 9, 2022
c4eb12f
Improve comments on why derivedColumns is excluded for effect depende…
eric-briscoe Nov 9, 2022
1a25f33
Adding comment in test file to clarify appendDataToMenu test purpose …
eric-briscoe Nov 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion superset-frontend/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ module.exports = {
builder: 'webpack5',
},
stories: [
'../src/@(components|common|filters|explore)/**/*.stories.@(tsx|jsx|mdx)',
'../src/@(components|common|filters|explore)/**/*.stories.@(tsx|jsx)',
'../src/@(components|common|filters|explore)/**/*.*.@(mdx)',
],
addons: [
'@storybook/addon-essentials',
Expand Down
10 changes: 9 additions & 1 deletion superset-frontend/.storybook/preview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,15 @@ addParameters({
['Controls', 'Display', 'Feedback', 'Input', '*'],
['Overview', 'Examples', '*'],
'Design System',
['Foundations', 'Components', 'Patterns', '*'],
[
'Introduction',
'Foundations',
'Components',
['Overview', 'Examples', '*'],
'Patterns',
'*',
],
['Overview', 'Examples', '*'],
'*',
],
},
Expand Down
4 changes: 3 additions & 1 deletion superset-frontend/src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ export type ButtonStyle =
| 'link'
| 'dashed';

export type ButtonSize = 'default' | 'small' | 'xsmall';

export type ButtonProps = Omit<AntdButtonProps, 'css'> &
Pick<TooltipProps, 'placement'> & {
tooltip?: string;
className?: string;
buttonSize?: 'default' | 'small' | 'xsmall';
buttonSize?: ButtonSize;
buttonStyle?: ButtonStyle;
cta?: boolean;
showMarginRight?: boolean;
Expand Down
25 changes: 25 additions & 0 deletions superset-frontend/src/components/DesignSystem.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Meta, Source } from '@storybook/addon-docs';
import AtomicDesign from './atomic-design.png';

<Meta title="Design System/Introduction" />

# Superset Design System

A design system is a complete set of standards intended to manage design at scale using reusable components and patterns.

You can get an overview of Atomic Design concepts and a link to the full book on the topic here:

<a href="https://bradfrost.com/blog/post/atomic-web-design/" target="_blank">
Intro to Atomic Design
</a>

While the Superset Design System will use Atomic Design principles, we choose a different language to describe the elements.

| Atomic Design | Atoms | Molecules | Organisms | Templates | Pages / Screens |
| :-------------- | :---------: | :--------: | :-------: | :-------: | :-------------: |
| Superset Design | Foundations | Components | Patterns | Templates | Features |

<img
src={AtomicDesign}
alt="Atoms = Foundations, Molecules = Components, Organisms = Patterns, Templates = Templates, Pages / Screens = Features"
/>
26 changes: 24 additions & 2 deletions superset-frontend/src/components/Dropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import React, { RefObject } from 'react';
import { AntdDropdown } from 'src/components';
import { DropDownProps } from 'antd/lib/dropdown';
import { styled } from '@superset-ui/core';
import Icons from 'src/components/Icons';

const MenuDots = styled.div`
width: ${({ theme }) => theme.gridUnit * 0.75}px;
Expand Down Expand Up @@ -66,14 +67,35 @@ const MenuDotsWrapper = styled.div`
padding-left: ${({ theme }) => theme.gridUnit}px;
`;

export enum IconOrientation {
VERTICAL = 'vertical',
HORIZONTAL = 'horizontal',
}
export interface DropdownProps extends DropDownProps {
overlay: React.ReactElement;
iconOrientation?: IconOrientation;
}

export const Dropdown = ({ overlay, ...rest }: DropdownProps) => (
const RenderIcon = (
iconOrientation: IconOrientation = IconOrientation.VERTICAL,
) => {
const component =
iconOrientation === IconOrientation.HORIZONTAL ? (
<Icons.MoreHoriz iconSize="xl" />
) : (
<MenuDots />
);
return component;
};

export const Dropdown = ({
overlay,
iconOrientation = IconOrientation.VERTICAL,
...rest
}: DropdownProps) => (
<AntdDropdown overlay={overlay} {...rest}>
<MenuDotsWrapper data-test="dropdown-trigger">
<MenuDots />
{RenderIcon(iconOrientation)}
</MenuDotsWrapper>
</AntdDropdown>
);
Expand Down
4 changes: 2 additions & 2 deletions superset-frontend/src/components/Loading/Loading.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const LoadingGallery = () => (
}}
>
<h4>{position}</h4>
<Loading position={position} image="/src/assets/images/loading.gif" />
<Loading position={position} />
</div>
))}
</>
Expand Down Expand Up @@ -71,7 +71,7 @@ InteractiveLoading.story = {
};

InteractiveLoading.args = {
image: '/src/assets/images/loading.gif',
image: '',
className: '',
};

Expand Down
4 changes: 1 addition & 3 deletions superset-frontend/src/components/Loading/Loading.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ test('Rerendering correctly with default props', () => {
render(<Loading />);
const loading = screen.getByRole('status');
const classNames = loading.getAttribute('class')?.split(' ');
const imagePath = loading.getAttribute('src');
const ariaLive = loading.getAttribute('aria-live');
const ariaLabel = loading.getAttribute('aria-label');
expect(loading).toBeInTheDocument();
expect(imagePath).toBe('/static/assets/images/loading.gif');
expect(classNames).toContain('floating');
expect(classNames).toContain('loading');
expect(ariaLive).toContain('polite');
Expand All @@ -56,7 +54,7 @@ test('support for extra classes', () => {
expect(classNames).toContain('extra-class');
});

test('Diferent image path', () => {
test('Different image path', () => {
render(<Loading image="/src/assets/images/loading.gif" />);
const loading = screen.getByRole('status');
const imagePath = loading.getAttribute('src');
Expand Down
6 changes: 4 additions & 2 deletions superset-frontend/src/components/Loading/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import React from 'react';
import { styled } from '@superset-ui/core';
import cls from 'classnames';
import Loader from 'src/assets/images/loading.gif';

export type PositionOption =
| 'floating'
Expand All @@ -35,6 +36,7 @@ export interface Props {
const LoaderImg = styled.img`
z-index: 99;
width: 50px;
height: unset;
position: relative;
margin: 10px;
&.inline {
Expand All @@ -57,14 +59,14 @@ const LoaderImg = styled.img`
`;
export default function Loading({
position = 'floating',
image = '/static/assets/images/loading.gif',
image,
className,
}: Props) {
return (
<LoaderImg
className={cls('loading', position, className)}
alt="Loading..."
src={image}
src={image || Loader}
role="status"
aria-live="polite"
aria-label="Loading"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
import { Meta, Source } from '@storybook/addon-docs';
import { Meta, Source, Story } from '@storybook/addon-docs';

<Meta title="MetadataBar/Overview" />
<Meta title="Design System/Components/MetadataBar/Overview" />

# Usage
# Metadata bar

The metadata bar component is used to display additional information about an entity. Some of the common applications in Superset are:
The metadata bar component is used to display additional information about an entity.

## Usage

Some of the common applications in Superset are:

- Display the chart's metadata in Explore to help the user understand what dashboards this chart is added to and get
to know the details of the chart
- Display the database's metadata in a drill to detail modal to help the user understand what data they are looking
at while accessing the feature in the dashboard

# Variations
## Basic example

<Story id="design-system-components-metadatabar-examples--basic" />
eric-briscoe marked this conversation as resolved.
Show resolved Hide resolved

## Variations

The metadata bar is by default a static component (besides the links in text).
The variations in this component are related to content and entity type as all of the details are predefined
Expand All @@ -25,7 +33,7 @@ have the same icon and when hovered it will present who created the entity, its
To extend the list of content types, a developer needs to request the inclusion of the new type in the design system.
This process is important to make sure the new type is reviewed by the design team, improving Superset consistency.

To check each content type in detail and its interactions, check the [MetadataBar](/story/metadatabar--component) page.
To check each content type in detail and its interactions, check the [MetadataBar](/story/design-system-components-metadatabar-examples--basic) page.
Below you can find the configurations for each content type:

<Source
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import { useResizeDetector } from 'react-resize-detector';
import MetadataBar, { MetadataBarProps, MetadataType } from '.';

export default {
title: 'MetadataBar',
title: 'Design System/Components/MetadataBar/Examples',
component: MetadataBar,
};

const A_WEEK_AGO = 'a week ago';

export const Component = ({
export const Basic = ({
items,
onClick,
}: MetadataBarProps & {
Expand Down Expand Up @@ -61,15 +61,15 @@ export const Component = ({
);
};

Component.story = {
Basic.story = {
parameters: {
knobs: {
disable: true,
},
},
};

Component.args = {
Basic.args = {
items: [
{
type: MetadataType.SQL,
Expand Down Expand Up @@ -99,7 +99,7 @@ Component.args = {
],
};

Component.argTypes = {
Basic.argTypes = {
onClick: {
action: 'onClick',
table: {
Expand Down
Loading