github.com/minio/console@v1.4.1/web-app/src/screens/Console/Dashboard/TimeStatItem.tsx (about)

     1  // This file is part of MinIO Console Server
     2  // Copyright (c) 2022 MinIO, Inc.
     3  //
     4  // This program is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Affero General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // This program is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12  // GNU Affero General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Affero General Public License
    15  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    16  
    17  import React from "react";
    18  import styled from "styled-components";
    19  import get from "lodash/get";
    20  import { Box, Loader, SuccessIcon } from "mds";
    21  
    22  const TimeStatBase = styled.div(({ theme }) => ({
    23    display: "grid",
    24    alignItems: "center",
    25    gap: 8,
    26    height: 33,
    27    paddingLeft: 15,
    28    gridTemplateColumns: "20px 1.5fr .5fr 20px",
    29    background: get(theme, "boxBackground", "#FBFAFA"), // #EBF9EE
    30    "& .min-icon": {
    31      height: "12px",
    32      width: "12px",
    33      fill: get(theme, "signalColors.good", "#4CCB92"),
    34    },
    35    "& .ok-icon": {
    36      height: "8px",
    37      width: "8px",
    38      fill: get(theme, "signalColors.good", "#4CCB92"),
    39      color: get(theme, "signalColors.good", "#4CCB92"),
    40    },
    41    "& .timeStatLabel": {
    42      fontSize: "12px",
    43      color: get(theme, "signalColors.good", "#4CCB92"),
    44      fontWeight: 600,
    45    },
    46    "& .timeStatValue": {
    47      fontSize: "12px",
    48      color: get(theme, "signalColors.good", "#4CCB92"),
    49    },
    50  }));
    51  
    52  const TimeStatItem = ({
    53    icon,
    54    label,
    55    value,
    56    loading = false,
    57  }: {
    58    icon: any;
    59    label: any;
    60    value: string;
    61    loading?: boolean;
    62  }) => {
    63    return (
    64      <TimeStatBase className="dashboard-time-stat-item">
    65        {loading ? <Loader style={{ width: 10, height: 10 }} /> : icon}
    66        <Box className={"timeStatLabel"}>{label}</Box>
    67        <Box className={"timeStatValue"}>{value}</Box>
    68        {value !== "n/a" ? <SuccessIcon className="ok-icon" /> : null}
    69      </TimeStatBase>
    70    );
    71  };
    72  
    73  export default TimeStatItem;