etr2460 commented on a change in pull request #10298:
URL: 
https://github.com/apache/incubator-superset/pull/10298#discussion_r456110133



##########
File path: superset-frontend/src/components/Button.tsx
##########
@@ -17,41 +17,75 @@
  * under the License.
  */
 import React from 'react';
-import PropTypes from 'prop-types';
 import { kebabCase } from 'lodash';
 import {
   Button as BootstrapButton,
   Tooltip,
   OverlayTrigger,
 } from 'react-bootstrap';
+import styled from '@superset-ui/style';
 
-const propTypes = {
-  children: PropTypes.node,
-  className: PropTypes.string,
-  tooltip: PropTypes.node,
-  placement: PropTypes.string,
-  onClick: PropTypes.func,
-  disabled: PropTypes.bool,
-  bsSize: PropTypes.string,
-  bsStyle: PropTypes.string,
-  btnStyles: PropTypes.string,
-};
-const defaultProps = {
-  bsSize: 'sm',
-  placement: 'top',
-};
+export type OnClickHandler = React.MouseEventHandler<BootstrapButton>;
+
+export interface ButtonProps {
+  className?: string;
+  tooltip?: string;
+  placement?: string;
+  onClick?: OnClickHandler;
+  disabled?: boolean;
+  bsStyle?: string;
+  btnStyles?: string;
+  bsSize?: BootstrapButton.ButtonProps['bsSize'];
+  style?: BootstrapButton.ButtonProps['style'];
+}
 
 const BUTTON_WRAPPER_STYLE = { display: 'inline-block', cursor: 'not-allowed' 
};
 
-export default function Button(props) {
-  const buttonProps = { ...props };
+const SupersetButton = styled(BootstrapButton)`
+  &.supersetButton {
+    border-radius: ${({ theme }) => theme.gridUnit}px;
+    border: none;
+    color: ${({ theme }) => theme.colors.secondary.light5};
+    font-size: ${({ theme }) => theme.typography.sizes.s};
+    font-weight: ${({ theme }) => theme.typography.weights.bold};
+    min-width: 144px;
+    min-height: 32px;

Review comment:
       do you think a factor of the gridUnit should be used here too?

##########
File path: superset-frontend/src/components/Button.tsx
##########
@@ -17,41 +17,75 @@
  * under the License.
  */
 import React from 'react';
-import PropTypes from 'prop-types';
 import { kebabCase } from 'lodash';
 import {
   Button as BootstrapButton,
   Tooltip,
   OverlayTrigger,
 } from 'react-bootstrap';
+import styled from '@superset-ui/style';
 
-const propTypes = {
-  children: PropTypes.node,
-  className: PropTypes.string,
-  tooltip: PropTypes.node,
-  placement: PropTypes.string,
-  onClick: PropTypes.func,
-  disabled: PropTypes.bool,
-  bsSize: PropTypes.string,
-  bsStyle: PropTypes.string,
-  btnStyles: PropTypes.string,
-};
-const defaultProps = {
-  bsSize: 'sm',
-  placement: 'top',
-};
+export type OnClickHandler = React.MouseEventHandler<BootstrapButton>;
+
+export interface ButtonProps {
+  className?: string;
+  tooltip?: string;
+  placement?: string;
+  onClick?: OnClickHandler;
+  disabled?: boolean;
+  bsStyle?: string;
+  btnStyles?: string;
+  bsSize?: BootstrapButton.ButtonProps['bsSize'];
+  style?: BootstrapButton.ButtonProps['style'];
+}
 
 const BUTTON_WRAPPER_STYLE = { display: 'inline-block', cursor: 'not-allowed' 
};
 
-export default function Button(props) {
-  const buttonProps = { ...props };
+const SupersetButton = styled(BootstrapButton)`
+  &.supersetButton {
+    border-radius: ${({ theme }) => theme.gridUnit}px;

Review comment:
       should this use `theme.borderRadius`? I think they're both set to 4

##########
File path: superset-frontend/src/components/Button.tsx
##########
@@ -17,41 +17,75 @@
  * under the License.
  */
 import React from 'react';
-import PropTypes from 'prop-types';
 import { kebabCase } from 'lodash';
 import {
   Button as BootstrapButton,
   Tooltip,
   OverlayTrigger,
 } from 'react-bootstrap';
+import styled from '@superset-ui/style';
 
-const propTypes = {
-  children: PropTypes.node,
-  className: PropTypes.string,
-  tooltip: PropTypes.node,
-  placement: PropTypes.string,
-  onClick: PropTypes.func,
-  disabled: PropTypes.bool,
-  bsSize: PropTypes.string,
-  bsStyle: PropTypes.string,
-  btnStyles: PropTypes.string,
-};
-const defaultProps = {
-  bsSize: 'sm',
-  placement: 'top',
-};
+export type OnClickHandler = React.MouseEventHandler<BootstrapButton>;
+
+export interface ButtonProps {
+  className?: string;
+  tooltip?: string;
+  placement?: string;
+  onClick?: OnClickHandler;
+  disabled?: boolean;
+  bsStyle?: string;
+  btnStyles?: string;
+  bsSize?: BootstrapButton.ButtonProps['bsSize'];
+  style?: BootstrapButton.ButtonProps['style'];
+}
 
 const BUTTON_WRAPPER_STYLE = { display: 'inline-block', cursor: 'not-allowed' 
};
 
-export default function Button(props) {
-  const buttonProps = { ...props };
+const SupersetButton = styled(BootstrapButton)`
+  &.supersetButton {
+    border-radius: ${({ theme }) => theme.gridUnit}px;
+    border: none;
+    color: ${({ theme }) => theme.colors.secondary.light5};
+    font-size: ${({ theme }) => theme.typography.sizes.s};
+    font-weight: ${({ theme }) => theme.typography.weights.bold};
+    min-width: 144px;
+    min-height: 32px;
+    text-transform: uppercase;
+    margin-left: ${({ theme }) => theme.gridUnit * 4}px;
+    &:first-of-type {
+      margin-left: 0;
+    }
+
+    i {
+      padding: 0 ${({ theme }) => theme.gridUnit * 2}px 0 0;
+    }
+
+    &.primary {
+      background-color: ${({ theme }) => theme.colors.primary.base};
+    }
+    &.secondary {
+      color: ${({ theme }) => theme.colors.primary.base};
+      background-color: ${({ theme }) => theme.colors.primary.light4};
+    }
+    &.danger {
+      background-color: ${({ theme }) => theme.colors.error.base};
+    }
+  }
+`;
+
+const Button: React.FunctionComponent<ButtonProps> = props => {

Review comment:
       instead of using arrow functions like this, I think it's better to do:
   ```tsx
   export default function Button(props: ButtonProps) {
   ...
   ```
   
   The arrow function results in an anonymous function and makes stack traces 
harder to read




----------------------------------------------------------------
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]

Reply via email to