You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2020/06/30 02:22:46 UTC

[GitHub] [incubator-superset] etr2460 commented on a change in pull request #10178: style: [WIP] new toast design closer to SIP-34

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



##########
File path: superset-frontend/src/messageToasts/components/ToastPresenter.tsx
##########
@@ -0,0 +1,96 @@
+/**
+ * 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 styled from '@superset-ui/style';
+import Toast from './Toast';
+
+const StyledToastPresenter = styled.div`
+  max-width: 600px;
+  position: fixed;
+  bottom: 0px;
+  right: -110px;
+  transform: translate(-50%, 0);
+  z-index: ${({ theme }) => theme.zIndex.max};
+
+  .toast {
+    background: ${({ theme }) => theme.colors.grayscale.dark1};
+    border-radius: ${({ theme }) => theme.borderRadius};
+    box-shadow: 0 2px 4px 0
+      fade(
+        ${({ theme }) => theme.colors.grayscale.dark2},
+        ${({ theme }) => theme.opacity.mediumLight}
+      );
+    color: ${({ theme }) => theme.colors.grayscale.light5};
+    opacity: 0;
+    position: relative;
+    transform: translateY(-100%);
+    white-space: pre-line;
+    will-change: transform, opacity;
+    transition: transform ${({ theme }) => theme.transitionTiming}s,
+      opacity ${({ theme }) => theme.transitionTiming}s;
+
+    &:after {
+      content: '';
+      position: absolute;
+      top: 0;
+      left: 0;
+      width: 6px;
+      height: 100%;
+    }
+  }
+
+  .toast > button {
+    color: ${({ theme }) => theme.colors.grayscale.light5};
+    opacity: 1;
+  }
+
+  .toast--visible {
+    opacity: 1;
+    transform: translateY(0);
+  }
+`;
+
+type ToastType =
+  | 'INFO_TOAST'
+  | 'SUCCESS_TOAST'
+  | 'WARNING_TOAST'
+  | 'DANGER_TOAST';
+
+type ToastShape = {
+  id: string;
+  toastType: ToastType;
+  text: string;
+  duration: number;
+};
+
+interface ToastPresenterProps {
+  toasts: Array<ToastShape>;
+  removeToast: () => void;
+}
+
+const ToastPresenter = ({ toasts, removeToast }: ToastPresenterProps) =>
+  toasts.length > 0 && (
+    <StyledToastPresenter id="toast-presenter">

Review comment:
       Do you think using a [Portal](https://reactjs.org/docs/portals.html) for this might make it easier? 

##########
File path: superset-frontend/package.json
##########
@@ -61,14 +61,14 @@
     "@emotion/core": "^10.0.28",
     "@superset-ui/chart": "^0.14.1",
     "@superset-ui/chart-composition": "^0.14.1",
-    "@superset-ui/color": "^0.14.2",
+    "@superset-ui/chart-controls": "^0.14.1",
+    "@superset-ui/color": "^0.14.1",

Review comment:
       were the downgrades here intentional?

##########
File path: superset-frontend/src/messageToasts/components/Toast.tsx
##########
@@ -31,24 +30,43 @@ import {
   DANGER_TOAST,
 } from '../constants';
 
-const propTypes = {
-  toast: toastShape.isRequired,
-  onCloseToast: PropTypes.func.isRequired,
-};
+const ToastContianer = styled.div`
+  display: flex;
+  justify-content: center;
+  align-items: center;
+
+  span {
+    padding: 0 11px;
+  }
+`;
+
+type ToastType =
+  | 'INFO_TOAST'
+  | 'SUCCESS_TOAST'
+  | 'WARNING_TOAST'
+  | 'DANGER_TOAST';
+
+interface ToastPresenterProps {
+  toast: { id: string; toastType: ToastType; text: string; duration: number };
+  onCloseToast: (arg0: string) => void;

Review comment:
       let's name this argument

##########
File path: superset-frontend/src/messageToasts/components/ToastPresenter.tsx
##########
@@ -0,0 +1,96 @@
+/**
+ * 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 styled from '@superset-ui/style';
+import Toast from './Toast';
+
+const StyledToastPresenter = styled.div`
+  max-width: 600px;
+  position: fixed;
+  bottom: 0px;
+  right: -110px;
+  transform: translate(-50%, 0);
+  z-index: ${({ theme }) => theme.zIndex.max};
+
+  .toast {
+    background: ${({ theme }) => theme.colors.grayscale.dark1};
+    border-radius: ${({ theme }) => theme.borderRadius};
+    box-shadow: 0 2px 4px 0
+      fade(
+        ${({ theme }) => theme.colors.grayscale.dark2},
+        ${({ theme }) => theme.opacity.mediumLight}
+      );
+    color: ${({ theme }) => theme.colors.grayscale.light5};
+    opacity: 0;
+    position: relative;
+    transform: translateY(-100%);
+    white-space: pre-line;
+    will-change: transform, opacity;
+    transition: transform ${({ theme }) => theme.transitionTiming}s,
+      opacity ${({ theme }) => theme.transitionTiming}s;
+
+    &:after {
+      content: '';
+      position: absolute;
+      top: 0;
+      left: 0;
+      width: 6px;
+      height: 100%;
+    }
+  }
+
+  .toast > button {
+    color: ${({ theme }) => theme.colors.grayscale.light5};
+    opacity: 1;
+  }
+
+  .toast--visible {
+    opacity: 1;
+    transform: translateY(0);
+  }
+`;
+
+type ToastType =
+  | 'INFO_TOAST'
+  | 'SUCCESS_TOAST'
+  | 'WARNING_TOAST'
+  | 'DANGER_TOAST';
+
+type ToastShape = {
+  id: string;
+  toastType: ToastType;
+  text: string;
+  duration: number;
+};
+
+interface ToastPresenterProps {
+  toasts: Array<ToastShape>;
+  removeToast: () => void;
+}
+
+const ToastPresenter = ({ toasts, removeToast }: ToastPresenterProps) =>
+  toasts.length > 0 && (
+    <StyledToastPresenter id="toast-presenter">

Review comment:
       Although looking at the diff, it seems like this was written like this before, so up to you if you want to see if a Portal is easier or not




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org