rusackas commented on a change in pull request #13409:
URL: https://github.com/apache/superset/pull/13409#discussion_r588835416
##########
File path: superset-frontend/src/components/RefreshLabel/index.tsx
##########
@@ -16,32 +16,38 @@
* specific language governing permissions and limitations
* under the License.
*/
-import React from 'react';
-import PropTypes from 'prop-types';
+import React, { MouseEventHandler } from 'react';
+import { useTheme } from '@superset-ui/core';
import { Tooltip } from 'src/common/components/Tooltip';
+import Icon, { IconProps } from 'src/components/Icon';
-import './RefreshLabel.less';
+export interface RefreshLabelProps {
+ onClick: MouseEventHandler<SVGSVGElement>;
+ tooltipContent: string;
+}
-const propTypes = {
- onClick: PropTypes.func,
- tooltipContent: PropTypes.string.isRequired,
-};
+const RefreshLabel = ({ onClick, tooltipContent }: RefreshLabelProps) => {
+ const theme = useTheme();
-class RefreshLabel extends React.PureComponent {
- render() {
- return (
- <Tooltip title={this.props.tooltipContent} id="cache-desc-tooltip">
- <i
- aria-label="Icon"
- role="button"
- tabIndex={0}
- className="RefreshLabel fa fa-refresh pointer"
- onClick={this.props.onClick}
- />
- </Tooltip>
- );
- }
-}
-RefreshLabel.propTypes = propTypes;
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ const IconWithoutRef = React.forwardRef((props: IconProps, ref: any) => (
+ <Icon {...props} />
+ ));
+
+ return (
+ <Tooltip title={tooltipContent}>
+ <IconWithoutRef
+ role="button"
+ onClick={onClick}
+ name="refresh"
+ css={{
Review comment:
> About CSS-y approach I understand that it doesn't require switching
the brain from CSS to JS styles but I still think that type checking is a clear
winner. Let me know if you agree. Otherwise, I can revisit. Thank you for your
review.
The ability to more easily port from `css` to `styled` or back was the
bigger selling point, but type checking probably wins over that. Seems OK to
me.
As for autocomplete, I have an IDE plugin (`ts-styled-plugin` if memory
serves) that takes care of intellisense/autocomplete with the styled/string
implementation, which is helpful :)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]