Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const config = {
plugins: [
[require.resolve("./src/plugins/blogGlobalData/index.js"), {}],
"docusaurus-plugin-sass",
"plugin-image-zoom",
"docusaurus-plugin-image-zoom",
[
"docusaurus-lunr-search",
{
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
"@docusaurus/plugin-content-blog": "^3.7.0",
"@docusaurus/plugin-google-gtag": "^3.7.0",
"@docusaurus/preset-classic": "3.7.0",
"@iconify/react": "^6.0.2",
"@mdx-js/react": "^3.0.0",
"@node-rs/jieba": "^2.0.1",
"clsx": "^2.0.0",
"docusaurus-lunr-search": "^3.6.0",
"docusaurus-plugin-image-zoom": "^3.0.1",
"docusaurus-plugin-sass": "^0.2.6",
"plugin-image-zoom": "flexanalytics/plugin-image-zoom",
"prism-react-renderer": "^2.3.0",
Expand Down
12 changes: 11 additions & 1 deletion src/components/Why/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import React from "react";
import SectionContainer from "../sectionContainer";
import Translate from "@docusaurus/Translate";
import { Icon } from '@iconify/react';
import "./index.scss";

const SKY_BLUE = "#4FC3F7";

const reasons = [
{
title: <Translate>Smooth compatibility</Translate>,
Expand All @@ -15,6 +18,7 @@ const reasons = [
</Translate>
</>
),
icon: <Icon icon="mdi:connection" color={SKY_BLUE} width="24" height="24" />,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The color, width, and height props on the Icon component are redundant and potentially misleading, as these styles are already defined (and in the case of size, overridden) in the corresponding SCSS file (src/components/Why/index.scss). The SCSS sets the width and height to 30px (conflicting with the 24 here) and the fill color. To improve maintainability and have a single source of truth for styling, it's best to remove these props and let CSS handle the presentation entirely. This change should be applied to all <Icon> components in this file (lines 32, 41, 52, 65, 70).

Suggested change
icon: <Icon icon="mdi:connection" color={SKY_BLUE} width="24" height="24" />,
icon: <Icon icon="mdi:connection" />,

},
{
title: <Translate>High performance</Translate>,
Expand All @@ -25,6 +29,7 @@ const reasons = [
<Translate>Service startup performance 40%↑</Translate>
</>
),
icon: <Icon icon="mdi:rocket" color={SKY_BLUE} width="24" height="24" />,
},
{
title: <Translate>Low overhead</Translate>,
Expand All @@ -33,6 +38,7 @@ const reasons = [
<Translate>ServiceMesh data plane overhead 70%↓</Translate>
</>
),
icon: <Icon icon="mdi:arrow-down-bold" color={SKY_BLUE} width="24" height="24" />,
},
{
title: <Translate>Security Isolation</Translate>,
Expand All @@ -43,6 +49,7 @@ const reasons = [
<Translate>Cgroup-level Orchestration Isolation</Translate>
</>
),
icon: <Icon icon="mdi:shield-lock" color={SKY_BLUE} width="24" height="24" />,
},
{
title: <Translate>Full Stack Visualization*</Translate>,
Expand All @@ -55,10 +62,12 @@ const reasons = [
</Translate>
</>
),
icon: <Icon icon="mdi:chart-line" color={SKY_BLUE} width="24" height="24" />,
},
{
title: <Translate>Open Ecosystem</Translate>,
content: <Translate>Support for XDS Protocol Standards</Translate>,
icon: <Icon icon="mdi:earth" color={SKY_BLUE} width="24" height="24" />,
},
];

Expand All @@ -71,11 +80,12 @@ export default function Why() {
<div className="reasonBoxContainer">
{reasons.map((item, index) => (
<div key={index} className="reasonBox">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using the array index as a key is not recommended in React, as it can lead to performance issues and bugs with dynamic lists. Although this list is static, it's a good practice to use a unique and stable identifier from the data itself. The text content of the title is a good candidate for a key.

Suggested change
<div key={index} className="reasonBox">
<div key={item.title.props.children} className="reasonBox">

<div className="reasonIcon">{item.icon}</div>
<p className="reasonTitle">{item.title}</p>
<div className="reasonContent">{item.content}</div>
</div>
))}
</div>
</SectionContainer>
);
}
}
26 changes: 26 additions & 0 deletions src/components/Why/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,32 @@
flex-basis: 33.333%;
padding: 0 15px;
margin-bottom: 2rem;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
}

.reasonIcon {
margin-bottom: 12px;
display: flex;
justify-content: center;
align-items: center;
width: 60px;
height: 60px;
background: rgba(79, 195, 247, 0.1);
border-radius: 50%;
transition: transform 0.2s ease;

svg {
width: 30px;
height: 30px;
fill: #4FC3F7;
}

&:hover {
transform: scale(1.1);
}
}
Comment on lines +23 to 43

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The color #4FC3F7 (and its RGB equivalent) is used in multiple places. To improve maintainability and avoid magic values, it's a good practice to define it as a SCSS variable at the top of this class scope and reuse it. This makes it easier to update the theme color in the future.

.reasonIcon {
  $sky-blue: #4FC3F7;

  margin-bottom: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 60px;
  height: 60px;
  background: rgba($sky-blue, 0.1);
  border-radius: 50%;
  transition: transform 0.2s ease;

  svg {
    width: 30px;
    height: 30px;
    fill: $sky-blue;
  }

  &:hover {
    transform: scale(1.1);
  }
}


.reasonTitle {
Expand Down
Loading