Browse Source

update to camelCase

namnguyen 11 months ago
parent
commit
678fa7f779

+ 26 - 0
frontend/taipy-gui/public/stylekit/controls/metric.css

@@ -0,0 +1,26 @@
+/*
+ * Copyright 2021-2024 Avaiga Private Limited
+ *
+ * Licensed 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.
+ */
+
+/**************************************************************
+
+                   TAIPY METRIC
+
+***************************************************************/
+
+/*************************************************
+              OVERRIDES / NORMALIZATION
+**************************************************/
+
+.taipy-metric {
+    max-width: 100%;
+}

+ 1 - 0
frontend/taipy-gui/public/stylekit/stylekit.css

@@ -32,6 +32,7 @@
 @import 'controls/expandable.css';
 @import 'controls/image.css';
 @import 'controls/input.css';
+@import 'controls/metric.css';
 @import 'controls/navbar.css';
 @import 'controls/number.css';
 @import 'controls/slider.css';

+ 12 - 8
frontend/taipy-gui/src/components/Taipy/Metric.tsx

@@ -15,6 +15,7 @@ import React, {CSSProperties, lazy, Suspense, useMemo} from 'react';
 import {Data} from "plotly.js";
 import Box from "@mui/material/Box";
 import Skeleton from "@mui/material/Skeleton";
+import Tooltip from "@mui/material/Tooltip";
 import {useClassNames, useDynamicJsonProperty, useDynamicProperty} from "../../utils/hooks";
 import {extractPrefix, extractSuffix, sprintfToD3Converter} from "../../utils/formatConversion";
 import {TaipyBaseProps, TaipyHoverProps} from "./utils";
@@ -58,6 +59,7 @@ const Metric = (props: MetricProps) => {
     const className = useClassNames(props.libClassName, props.dynamicClassName, props.className);
     const baseLayout = useDynamicJsonProperty(props.layout, props.defaultLayout || "", emptyLayout);
     const baseStyle = useDynamicJsonProperty(props.style, props.defaultStyle || "", defaultStyle);
+    const hover = useDynamicProperty(props.hoverText, props.defaultHoverText, undefined);
 
     const data = useMemo(() => {
         return [
@@ -117,14 +119,16 @@ const Metric = (props: MetricProps) => {
 
     return (
         <Box data-testid={props.testId} className={className}>
-            <Suspense fallback={<Skeleton key="skeleton" sx={skelStyle}/>}>
-                <Plot
-                    data={data as Data[]}
-                    layout={baseLayout}
-                    style={style}
-                    useResizeHandler
-                />
-            </Suspense>
+            <Tooltip title={hover || ""}>
+                <Suspense fallback={<Skeleton key="skeleton" sx={skelStyle}/>}>
+                    <Plot
+                        data={data as Data[]}
+                        layout={baseLayout}
+                        style={style}
+                        useResizeHandler
+                    />
+                </Suspense>
+            </Tooltip>
         </Box>
     );
 }