Skip to content

Commit 1993248

Browse files
authored
feat(nav): mark TiDB for AI as beta (#708)
1 parent bd5cbc0 commit 1993248

6 files changed

Lines changed: 106 additions & 52 deletions

File tree

locale/en/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"ai": "AI",
2525
"tidbForAI": "TiDB for AI",
2626
"developer": "Developer",
27+
"developerGuide": "Developer Guide",
2728
"bestPractices": "Best Practices",
2829
"api": "API",
2930
"releases": "Releases",
@@ -41,7 +42,8 @@
4142
"tidbOperatorReleases": "TiDB Operator Releases",
4243
"tiupReleases": "TiUP Releases",
4344
"badge": {
44-
"preview": "Preview"
45+
"preview": "Preview",
46+
"beta": "Beta"
4547
},
4648
"appdev": "App Dev",
4749
"asktug": "Forum",

locale/ja/translation.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"product": "製品",
2424
"ai": "AI",
2525
"tidbForAI": "TiDB for AI",
26-
"developer": "開発者向け",
26+
"developer": "開発者",
27+
"developerGuide": "開発者ガイド",
2728
"bestPractices": "ベストプラクティス",
2829
"api": "API",
2930
"releases": "リリース",
@@ -41,7 +42,8 @@
4142
"tidbOperatorReleases": "TiDB Operator リリース",
4243
"tiupReleases": "TiUP リリース",
4344
"badge": {
44-
"preview": "Preview"
45+
"preview": "Preview",
46+
"beta": "Beta"
4547
},
4648
"appdev": "アプリ開発",
4749
"asktug": "Forum",

locale/zh/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"ai": "AI",
2323
"tidbForAI": "TiDB for AI",
2424
"developer": "应用开发",
25+
"developerGuide": "应用开发",
2526
"bestPractices": "最佳实践",
2627
"api": "API",
2728
"releases": "发布记录",
@@ -39,7 +40,8 @@
3940
"tidbOperatorReleases": "TiDB Operator 版本发布记录",
4041
"tiupReleases": "TiUP 版本发布记录",
4142
"badge": {
42-
"preview": "Preview"
43+
"preview": "Preview",
44+
"beta": "Beta"
4345
},
4446
"appdev": "开发指南",
4547
"asktug": "社区",

src/components/Layout/Header/HeaderNavConfigData.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,24 @@ const PreviewBadge = (props: { label: string }) => {
3232
);
3333
};
3434

35+
const BetaTagBadge = (props: { label: string }) => (
36+
<Chip
37+
label={props.label}
38+
variant="outlined"
39+
size="small"
40+
sx={{
41+
flexShrink: 0,
42+
textTransform: "uppercase",
43+
pointerEvents: "none",
44+
fontSize: "10px",
45+
height: "20px",
46+
borderColor: "#c0e1f1",
47+
color: "#2d9cd2",
48+
fontWeight: 500,
49+
}}
50+
/>
51+
);
52+
3553
/**
3654
* Default navigation configuration
3755
*/
@@ -134,13 +152,19 @@ const getDefaultNavConfig = (
134152
{
135153
type: "item",
136154
label: t("navbar.ai"),
137-
leftNavLabel: t("navbar.tidbForAI"),
155+
leftNavLabel: (
156+
<>
157+
{t("navbar.tidbForAI")}
158+
<BetaTagBadge label={t("navbar.badge.beta")} />
159+
</>
160+
),
138161
to: "/ai",
139162
selected: (namespace) => namespace === TOCNamespace.AI,
140163
},
141164
{
142165
type: "item",
143166
label: t("navbar.developer"),
167+
leftNavLabel: t("navbar.developerGuide"),
144168
to: "/developer",
145169
selected: (namespace) => namespace === TOCNamespace.Develop,
146170
},

src/components/Layout/LeftNav/LeftNav.tsx

Lines changed: 69 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,59 @@ function shouldShowVersionSelect(
5656
);
5757
}
5858

59+
function LeftNavTitle({ selectedNavItem }: { selectedNavItem: NavItemConfig }) {
60+
const theme = useTheme();
61+
const hasEndIcon =
62+
selectedNavItem.endIcon !== null && selectedNavItem.endIcon !== undefined;
63+
64+
return (
65+
<Box
66+
sx={{
67+
borderRadius: "4px",
68+
"&:hover": {
69+
backgroundColor: theme.palette.carbon[200],
70+
},
71+
}}
72+
>
73+
<LinkComponent
74+
isI18n={selectedNavItem.isI18n ?? true}
75+
to={selectedNavItem.to}
76+
style={{ textDecoration: "none", display: "block" }}
77+
onClick={() => {
78+
clearAllNavStates();
79+
}}
80+
>
81+
<Typography
82+
variant="h6"
83+
component="div"
84+
sx={{
85+
fontSize: "18px",
86+
fontWeight: 700,
87+
color: theme.palette.carbon[900],
88+
padding: "8px",
89+
display: "inline-flex",
90+
alignItems: "center",
91+
gap: 1,
92+
}}
93+
>
94+
{selectedNavItem.leftNavLabel ?? selectedNavItem.label}
95+
{hasEndIcon && (
96+
<Box
97+
component="span"
98+
sx={{
99+
display: "inline-flex",
100+
alignItems: "center",
101+
}}
102+
>
103+
{selectedNavItem.endIcon}
104+
</Box>
105+
)}
106+
</Typography>
107+
</LinkComponent>
108+
</Box>
109+
);
110+
}
111+
59112
export function LeftNavDesktop(props: LeftNavProps) {
60113
const {
61114
data,
@@ -67,7 +120,6 @@ export function LeftNavDesktop(props: LeftNavProps) {
67120
selectedNavItem,
68121
namespace,
69122
} = props;
70-
const theme = useTheme();
71123

72124
return (
73125
<Box
@@ -96,50 +148,7 @@ export function LeftNavDesktop(props: LeftNavProps) {
96148
>
97149
<LeftNavStickyContainer top={0} paddingTop="20px">
98150
{selectedNavItem && (
99-
<Box
100-
sx={{
101-
borderRadius: "4px",
102-
"&:hover": {
103-
backgroundColor: theme.palette.carbon[200],
104-
},
105-
}}
106-
>
107-
<LinkComponent
108-
isI18n={selectedNavItem.isI18n ?? true}
109-
to={selectedNavItem.to}
110-
style={{ textDecoration: "none", display: "block" }}
111-
onClick={() => {
112-
clearAllNavStates();
113-
}}
114-
>
115-
<Typography
116-
variant="h6"
117-
component="div"
118-
sx={{
119-
fontSize: "18px",
120-
fontWeight: 700,
121-
color: theme.palette.carbon[900],
122-
padding: "8px",
123-
display: "inline-flex",
124-
alignItems: "center",
125-
gap: 1,
126-
}}
127-
>
128-
{selectedNavItem.leftNavLabel ?? selectedNavItem.label}
129-
{selectedNavItem.endIcon && (
130-
<Box
131-
component="span"
132-
sx={{
133-
display: "inline-flex",
134-
alignItems: "center",
135-
}}
136-
>
137-
{selectedNavItem.endIcon}
138-
</Box>
139-
)}
140-
</Typography>
141-
</LinkComponent>
142-
</Box>
151+
<LeftNavTitle selectedNavItem={selectedNavItem} />
143152
)}
144153

145154
{shouldShowVersionSelect(namespace, pathConfig.repo, buildType) && (
@@ -162,8 +171,16 @@ export function LeftNavDesktop(props: LeftNavProps) {
162171
}
163172

164173
export function LeftNavMobile(props: LeftNavProps) {
165-
const { data, current, name, pathConfig, availIn, buildType, namespace } =
166-
props;
174+
const {
175+
data,
176+
current,
177+
name,
178+
pathConfig,
179+
availIn,
180+
buildType,
181+
namespace,
182+
selectedNavItem,
183+
} = props;
167184

168185
const [open, setOpen] = React.useState(false);
169186

@@ -224,6 +241,11 @@ export function LeftNavMobile(props: LeftNavProps) {
224241

225242
<Divider />
226243
<Box sx={{ width: "17.125rem", padding: "1rem" }}>
244+
{selectedNavItem && (
245+
<Box sx={{ marginBottom: 1 }}>
246+
<LeftNavTitle selectedNavItem={selectedNavItem} />
247+
</Box>
248+
)}
227249
<LeftNavTree data={data} current={current} />
228250
</Box>
229251
</Drawer>

src/templates/DocTemplate.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ function DocTemplate({
215215
pathConfig={pathConfig}
216216
availIn={availIn.version}
217217
availablePlans={availablePlans}
218+
buildType={buildType}
219+
selectedNavItem={selectedNavItem}
218220
namespace={namespace}
219221
/>
220222
)

0 commit comments

Comments
 (0)