Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5e3b476
Enhance custom icon
geido Dec 30, 2020
cc65119
Minor fix
geido Dec 30, 2020
019af15
Merge remote-tracking branch 'upstream/master' into custom_icons_to_antd
geido Jan 22, 2021
a1a4301
Move DashboardList icon trash icon to enhanced
geido Jan 22, 2021
002dffe
Enhance trash icon on lists
geido Jan 25, 2021
5bc2641
Enhance actions icons card view
geido Jan 25, 2021
6919d8c
Add storybook entry for custom icons
geido Jan 25, 2021
6f22fff
Test delete button
geido Jan 25, 2021
62fb017
Merge remote-tracking branch 'upstream/master' into custom_icons_to_antd
geido Jan 25, 2021
4cda25b
Remove commented line
geido Jan 25, 2021
a2237cc
Fix linting issue
geido Jan 25, 2021
a53a851
Enhance Antd icons
geido Jan 28, 2021
7eb6087
Merge remote-tracking branch 'upstream/master' into custom_icons_to_antd
geido Jan 28, 2021
24d1cea
Enhance existing icons up to BoltSmallRunIcon
geido Jan 28, 2021
1ffb30f
Remove unused import
geido Jan 28, 2021
7a3fbcb
Import/Exports all icons from index
geido Jan 29, 2021
c4300a7
Export all existing icons
geido Feb 1, 2021
e74f4eb
Implement more enhanced icons
geido Feb 1, 2021
cbefb3a
Add data-id on edit buttons
geido Feb 1, 2021
199e054
Fix lint issue
geido Feb 2, 2021
a14df94
Inherit color
geido Feb 3, 2021
af0a123
Merge remote-tracking branch 'upstream/master' into custom_icons_to_antd
geido Feb 3, 2021
0179487
Apply original color to actions
geido Feb 3, 2021
a2452c4
Fix linting issue
geido Feb 4, 2021
d2d9159
Merge
geido Feb 22, 2021
8edcb7e
Fix typo
geido Feb 22, 2021
0de8fe9
Change ModeHoriz to MoreHoriz
geido Feb 23, 2021
95139f4
Merge remote-tracking branch 'upstream/master' into custom_icons_to_antd
geido Feb 23, 2021
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
16 changes: 11 additions & 5 deletions superset-frontend/src/CRUD/CollectionTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import React, { ReactNode } from 'react';
import shortid from 'shortid';
import { t, styled } from '@superset-ui/core';
import Button from 'src/components/Button';
import Icons from 'src/components/Icons';
import Fieldset from './Fieldset';
import { recurseReactClone } from './utils';
import './crud.less';
Expand Down Expand Up @@ -251,13 +252,18 @@ export default class CRUDCollection extends React.PureComponent<
}
if (allowDeletes) {
tds.push(
<td key="__actions" data-test="crud-delete-option">
<i
{...{ 'data-test': 'crud-delete-icon' }}
role="button"
<td
key="__actions"
data-test="crud-delete-option"
className="text-primary"
>
<Icons.Trash
aria-label="Delete item"
className="pointer"
data-test="crud-delete-icon"
iconSize="m"
role="button"
tabIndex={0}
className="fa fa-trash text-primary pointer"
onClick={this.deleteItem.bind(this, record.id)}
/>
</td>,
Expand Down
31 changes: 31 additions & 0 deletions superset-frontend/src/components/Icons/AntdEnhanced.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* 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 * as AntdIcons from '@ant-design/icons/lib/icons';
import Icon from './Icon';
import IconType from './IconType';

const AntdEnhancedIcons = Object.keys(AntdIcons)
.map(k => ({
[k]: (props: IconType) => <Icon component={AntdIcons[k]} {...props} />,
}))
.reduce((l, r) => ({ ...l, ...r }));

export default AntdEnhancedIcons;
50 changes: 50 additions & 0 deletions superset-frontend/src/components/Icons/Icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* 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 AntdIcon from '@ant-design/icons';
import { styled } from '@superset-ui/core';
import { CustomIconComponentProps } from '@ant-design/icons/lib/components/Icon';
import IconType from './IconType';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const EnhancedIcon = ({ iconColor, iconSize, ...rest }: IconType) => (
<AntdIcon viewBox={rest.viewBox || '0 0 24 24'} {...rest} />
);

const Icon = styled(EnhancedIcon)<IconType>`
${({ iconColor }) => iconColor && `color: ${iconColor};`};
font-size: ${({ iconSize, theme }) =>
iconSize ? `${theme.typography.sizes[iconSize]}px` : '24px'};
`;

export const renderIcon = (
SVGComponent:
| React.ComponentClass<
CustomIconComponentProps | React.SVGProps<SVGSVGElement>,
any
>
| React.FunctionComponent<
CustomIconComponentProps | React.SVGProps<SVGSVGElement>
>
| undefined,
props: IconType,
) => <Icon component={SVGComponent} {...props} />;

export default Icon;
28 changes: 28 additions & 0 deletions superset-frontend/src/components/Icons/IconType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* 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 AntdIcon from '@ant-design/icons';

type AntdIconType = typeof AntdIcon.defaultProps;
type IconType = AntdIconType & {
iconColor?: string;
iconSize?: 's' | 'm' | 'l' | 'xl' | 'xxl';
};

export default IconType;
83 changes: 83 additions & 0 deletions superset-frontend/src/components/Icons/icons.stories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/**
* 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 { withKnobs, select } from '@storybook/addon-knobs';
import { styled, supersetTheme } from '@superset-ui/core';
import Icons from '.';
import Icon from './Icon';

export default {
title: 'Icons',
component: Icon,
decorators: [withKnobs],
};

const palette = {};
Object.entries(supersetTheme.colors).forEach(([familyName, family]) => {
Object.entries(family).forEach(([colorName, colorValue]) => {
palette[`${familyName} / ${colorName}`] = colorValue;
});
});

const colorKnob = {
label: 'Color',
options: {
Default: null,
...palette,
},
defaultValue: null,
};

const IconSet = styled.div`
display: flex;
flex-direction: row;
flex-wrap: wrap;
`;

const IconBlock = styled.div`
flex-grow: 0;
flex-shrink: 0;
flex-basis: 10%;
text-align: center;
padding: ${({ theme }) => theme.gridUnit * 2}px;
div {
white-space: nowrap;
font-size: ${({ theme }) => theme.typography.sizes.s}px;
}
`;

export const SupersetIcon = () => (
<IconSet>
{Object.keys(Icons).map(k => {
const IconComponent = Icons[k];
return (
<IconBlock key={k}>
<IconComponent
iconColor={select(
colorKnob.label,
colorKnob.options,
colorKnob.defaultValue,
colorKnob.groupId,
)}
/>
</IconBlock>
);
})}
</IconSet>
);
Loading