From 9186fa84d788af7e416b26946a8014b093cdc3c7 Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Thu, 21 Oct 2021 16:04:56 +0300 Subject: [PATCH] Convert ClusterOverview styles to css modules Signed-off-by: Alex Andreev --- ...-issues.scss => cluster-issues.module.css} | 53 ++++++++----------- .../components/+cluster/cluster-issues.tsx | 14 ++--- .../+cluster/cluster-metric-switchers.tsx | 6 +-- ...etrics.scss => cluster-metrics.module.css} | 8 +-- .../components/+cluster/cluster-metrics.tsx | 9 ++-- ...rview.scss => cluster-overview.module.css} | 13 +---- .../components/+cluster/cluster-overview.tsx | 4 +- ...ers.scss => cluster-pie-charts.module.css} | 15 ++++-- .../+cluster/cluster-pie-charts.scss | 50 ----------------- .../+cluster/cluster-pie-charts.tsx | 18 +++---- 10 files changed, 62 insertions(+), 128 deletions(-) rename src/renderer/components/+cluster/{cluster-issues.scss => cluster-issues.module.css} (72%) rename src/renderer/components/+cluster/{cluster-metrics.scss => cluster-metrics.module.css} (90%) rename src/renderer/components/+cluster/{cluster-overview.scss => cluster-overview.module.css} (89%) rename src/renderer/components/+cluster/{cluster-metric-switchers.scss => cluster-pie-charts.module.css} (80%) delete mode 100644 src/renderer/components/+cluster/cluster-pie-charts.scss diff --git a/src/renderer/components/+cluster/cluster-issues.scss b/src/renderer/components/+cluster/cluster-issues.module.css similarity index 72% rename from src/renderer/components/+cluster/cluster-issues.scss rename to src/renderer/components/+cluster/cluster-issues.module.css index 99ba313472..b3c7388552 100644 --- a/src/renderer/components/+cluster/cluster-issues.scss +++ b/src/renderer/components/+cluster/cluster-issues.module.css @@ -19,62 +19,51 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -.ClusterIssues { + .ClusterIssues { min-height: 350px; position: relative; grid-area: issues; + padding: calc(var(--margin) * 2) 0; + background: var(--contentColor); - &.OnlyClusterIssues { + &:global(.OnlyClusterIssues) { grid-row: row1-start / row2-end; } @media (max-width: 1150px) { grid-area: unset; - &.OnlyClusterIssues { + &:global(.OnlyClusterIssues) { grid-row: auto; } } .SubHeader { - .Icon { + padding-top: 0; + padding-bottom: 0; + + :global(.Icon) { font-size: 130%; - color: $colorError; + color: var(--colorError); } } - .Table { - .TableHead { - background-color: transparent; - border-bottom: 1px solid $borderFaintColor; - - .TableCell { - padding-top: 0; - } - } - - .TableCell { - white-space: nowrap; - text-overflow: ellipsis; - - &.message { - flex-grow: 3; - } - - &.object { - flex-grow: 2; - } - } + .message { + white-space: nowrap; + text-overflow: ellipsis; + flex-grow: 3; } - .no-issues { - .Icon { - color: white; - } + .object { + white-space: nowrap; + text-overflow: ellipsis; + flex-grow: 2; + } + .noIssues { .ok-title { font-size: large; - color: $textColorAccent; + color: var(--textColorAccent); font-weight: bold; } } diff --git a/src/renderer/components/+cluster/cluster-issues.tsx b/src/renderer/components/+cluster/cluster-issues.tsx index 3f9b5c6b90..a5e09370c7 100644 --- a/src/renderer/components/+cluster/cluster-issues.tsx +++ b/src/renderer/components/+cluster/cluster-issues.tsx @@ -19,7 +19,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import "./cluster-issues.scss"; +import styles from "./cluster-issues.module.css"; import React from "react"; import { observer } from "mobx-react"; @@ -121,10 +121,10 @@ export class ClusterIssues extends React.Component { selected={selfLink === kubeSelectedUrlParam.get()} onClick={prevDefault(() => toggleDetails(selfLink))} > - + {message} - + {getName()} @@ -148,8 +148,8 @@ export class ClusterIssues extends React.Component { if (!warnings.length) { return ( -
-
+
+
No issues found
Everything is fine in the Cluster
@@ -158,7 +158,7 @@ export class ClusterIssues extends React.Component { return ( <> - + {" "} <>Warnings: {warnings.length} @@ -186,7 +186,7 @@ export class ClusterIssues extends React.Component { render() { return ( -
+
{this.renderContent()}
); diff --git a/src/renderer/components/+cluster/cluster-metric-switchers.tsx b/src/renderer/components/+cluster/cluster-metric-switchers.tsx index b80dd10527..aa2ff2985f 100644 --- a/src/renderer/components/+cluster/cluster-metric-switchers.tsx +++ b/src/renderer/components/+cluster/cluster-metric-switchers.tsx @@ -19,8 +19,6 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import "./cluster-metric-switchers.scss"; - import React from "react"; import { observer } from "mobx-react"; import { nodesStore } from "../+nodes/nodes.store"; @@ -36,7 +34,7 @@ export const ClusterMetricSwitchers = observer(() => { const disableMetrics = !metricsValues.length; return ( -
+
{
-
+
{ } if (!memoryCapacity || !cpuCapacity) { - return ; + return ; } return ( @@ -106,12 +106,13 @@ export const ClusterMetrics = observer(() => { timeLabelStep={5} showLegend={false} plugins={[ZebraStripes]} + className={styles.chart} /> ); }; return ( -
+
{renderMetrics()}
diff --git a/src/renderer/components/+cluster/cluster-overview.scss b/src/renderer/components/+cluster/cluster-overview.module.css similarity index 89% rename from src/renderer/components/+cluster/cluster-overview.scss rename to src/renderer/components/+cluster/cluster-overview.module.css index bba4d0fa41..7700ec038b 100644 --- a/src/renderer/components/+cluster/cluster-overview.scss +++ b/src/renderer/components/+cluster/cluster-overview.module.css @@ -20,13 +20,11 @@ */ .ClusterOverview { - $gridGap: $margin * 2; - position: relative; height: 100%; min-height: 650px; display: grid; - grid-gap: $gridGap; + grid-gap: calc(var(--margin) * 2); grid-template-areas: "barcharts piechars" "issues issues"; @@ -40,13 +38,4 @@ grid-template-rows: 1fr; grid-template-areas: none; } - - > *:not(.Spinner) { - padding: $gridGap; - background: $contentColor; - - > .SubHeader { - padding-top: 0; - } - } } diff --git a/src/renderer/components/+cluster/cluster-overview.tsx b/src/renderer/components/+cluster/cluster-overview.tsx index 248c7de427..d10908b417 100644 --- a/src/renderer/components/+cluster/cluster-overview.tsx +++ b/src/renderer/components/+cluster/cluster-overview.tsx @@ -19,7 +19,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import "./cluster-overview.scss"; +import styles from "./cluster-overview.module.css"; import React from "react"; import { reaction } from "mobx"; @@ -101,7 +101,7 @@ export class ClusterOverview extends React.Component { return ( -
+
{this.renderClusterOverview(isLoaded, isMetricHidden)}
diff --git a/src/renderer/components/+cluster/cluster-metric-switchers.scss b/src/renderer/components/+cluster/cluster-pie-charts.module.css similarity index 80% rename from src/renderer/components/+cluster/cluster-metric-switchers.scss rename to src/renderer/components/+cluster/cluster-pie-charts.module.css index ef8dab156f..1998c11989 100644 --- a/src/renderer/components/+cluster/cluster-metric-switchers.scss +++ b/src/renderer/components/+cluster/cluster-pie-charts.module.css @@ -19,10 +19,15 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -.ClusterMetricSwitchers { - margin-bottom: $margin * 2; +.empty { + background: var(--contentColor); + min-height: 280px; + text-align: center; + padding: calc(var(--padding) * 2) 0; +} - .metric-switch { - text-align: right; - } +.chart { + --flex-gap: calc(var(--padding) * 2); + background: var(--contentColor); + padding: calc(var(--padding) * 2) var(--padding); } \ No newline at end of file diff --git a/src/renderer/components/+cluster/cluster-pie-charts.scss b/src/renderer/components/+cluster/cluster-pie-charts.scss deleted file mode 100644 index 4f2c392bb7..0000000000 --- a/src/renderer/components/+cluster/cluster-pie-charts.scss +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2021 OpenLens Authors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -.ClusterPieCharts { - background: transparent!important; - padding: 0!important; - - .empty { - background: $contentColor; - min-height: 280px; - text-align: center; - padding: $padding * 2; - } - - .NodeCharts { - margin-bottom: 0; - } - - .chart { - --flex-gap: #{$padding * 2}; - background: $contentColor; - padding: $padding * 2 $padding; - - .chart-title { - margin-bottom: 0; - } - - .legend { - --flex-gap: #{$padding}; - } - } -} \ No newline at end of file diff --git a/src/renderer/components/+cluster/cluster-pie-charts.tsx b/src/renderer/components/+cluster/cluster-pie-charts.tsx index 76bb6967f6..5079866870 100644 --- a/src/renderer/components/+cluster/cluster-pie-charts.tsx +++ b/src/renderer/components/+cluster/cluster-pie-charts.tsx @@ -19,7 +19,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import "./cluster-pie-charts.scss"; +import styles from "./cluster-pie-charts.module.css"; import React from "react"; import { observer } from "mobx-react"; @@ -29,7 +29,7 @@ import { Icon } from "../icon"; import { nodesStore } from "../+nodes/nodes.store"; import { ChartData, PieChart } from "../chart"; import { ClusterNoMetrics } from "./cluster-no-metrics"; -import { bytesToUnits } from "../../utils"; +import { bytesToUnits, cssNames } from "../../utils"; import { ThemeStore } from "../../theme.store"; import { getMetricLastPoints } from "../../../common/k8s-api/endpoints/metrics.api"; @@ -173,8 +173,8 @@ export const ClusterPieCharts = observer(() => { }; return ( -
-
+
+
{ /> {cpuLimitsOverload && renderLimitWarning()}
-
+
{ /> {memoryLimitsOverload && renderLimitWarning()}
-
+
{ if (!nodes.length) { return ( -
+
No Nodes Available.
@@ -237,14 +237,14 @@ export const ClusterPieCharts = observer(() => { const { memoryCapacity, cpuCapacity, podCapacity } = getMetricLastPoints(clusterOverviewStore.metrics); if (!memoryCapacity || !cpuCapacity || !podCapacity) { - return ; + return ; } return renderCharts(); }; return ( -
+
{renderContent()}
);