Skip to content

Commit 2d28203

Browse files
authored
feat: add ai lab banner (#591)
* feat: ai lab banner * fix: left nav styles * tweak: ja banner * tweak: banner styles * fix: use ja lab url * chore: typo
1 parent 59682aa commit 2d28203

File tree

11 files changed

+57
-44
lines changed

11 files changed

+57
-44
lines changed

gatsby/create-pages.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export const createDocs = async ({
124124
buildType: (process.env.WEBSITE_BUILD_TYPE ??
125125
DEFAULT_BUILD_TYPE) as BuildType, // prod | archive, default is prod; archive is for archive site
126126
feature: {
127-
banner: false,
127+
banner: true,
128128
feedback: true,
129129
},
130130
},
@@ -273,7 +273,7 @@ export const createDocHome = async ({
273273
buildType: (process.env.WEBSITE_BUILD_TYPE ??
274274
DEFAULT_BUILD_TYPE) as BuildType,
275275
feature: {
276-
banner: false,
276+
banner: true,
277277
feedback: true,
278278
globalHome: true,
279279
},

locale/en/translation.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,10 @@
165165
"success": "Thank you! You will be notified when a new TiDB LTS release comes out."
166166
},
167167
"banner": {
168-
"docDash2024": {
169-
"link": "https://www.pingcap.com/event/tidb-docs-dash/",
170-
"title": "TiDB Docs Dash 2024",
171-
"date": "Jan 9 - Jan 12 (UTC)",
172-
"intro": "Join us to improve docs and win a prize!"
173-
}
168+
"link": "https://labs.tidb.io/",
169+
"title": "Explore the new TiDB Labs, learn distributed SQL database and build RAG apps directly from your browser.",
170+
"date": "",
171+
"intro": ""
174172
},
175173
"campaign": {
176174
"docSurvey": {

locale/ja/translation.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@
148148
"scrollToTop": "トップへ戻る",
149149
"goToFeedback": "このページは役に立ちましたか?"
150150
},
151+
"banner": {
152+
"link": "https://labs.tidb.io/ja",
153+
"title": "新しい TiDB Labs を探索し、ブラウザから直接分散型 SQL データベースを学び、RAG アプリを構築しましょう。",
154+
"date": "",
155+
"intro": ""
156+
},
151157
"campaign": {
152158
"docSurvey": {
153159
"link": "https://forms.gle/LbWEygumJkc4jAPD7",

locale/zh/translation.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,10 @@
162162
"success": "感谢订阅!当新的 LTS 版本发布时,我们会通过邮件通知您。"
163163
},
164164
"banner": {
165-
"docDash2024": {
166-
"link": "https://asktug.com/t/topic/1019364",
167-
"title": "2024 TiDB 文档挑战赛",
168-
"date": "1/9 - 1/12",
169-
"intro": "提 PR 或 Issue 来赢取 Bose 耳机、机械键盘等奖品吧!"
170-
}
165+
"link": "https://labs.pingcap.com/",
166+
"title": "探索全新的 TiDB Labs,直接在浏览器中学习分布式 SQL 数据库并构建 RAG 应用。",
167+
"date": "",
168+
"intro": ""
171169
},
172170
"campaign": {
173171
"docSurvey": {

src/components/Layout/Banner/Banner.tsx

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,18 @@ const useBannerEvents = (
1515
const urlKey = prefix ? `${prefix}.${linkKey}` : linkKey;
1616
const url = t(urlKey);
1717
const textList = validTextKeys.map((k) => t(k));
18-
const logo = (
19-
<Box
20-
component="img"
21-
alt="TiDB"
22-
src={require("media/logo/tidb-logo.svg")?.default}
23-
sx={{
24-
width: "1.25rem",
25-
height: "1.25rem",
26-
}}
27-
/>
28-
);
18+
const logo = "🚀";
19+
// const logo = (
20+
// <Box
21+
// component="img"
22+
// alt="TiDB"
23+
// src={require("media/logo/tidb-logo.svg")?.default}
24+
// sx={{
25+
// width: "1.25rem",
26+
// height: "1.25rem",
27+
// }}
28+
// />
29+
// );
2930
const bgImgSrc =
3031
"https://static.pingcap.com/files/2023/11/15190759/20231116-105219.png";
3132

@@ -38,22 +39,25 @@ const useBannerEvents = (
3839
};
3940

4041
export function Banner() {
41-
const { bgImgSrc, url, logo, textList } = useBannerEvents(
42-
["title", "date", "intro"],
42+
const { url, logo, textList } = useBannerEvents(
43+
// ["title", "date", "intro"],
44+
["title"],
4345
"link",
44-
"banner.docDash2024"
46+
"banner"
4547
);
4648

4749
return (
4850
<Box
4951
sx={{
5052
flexShrink: 0,
51-
height: "2rem",
52-
backgroundColor: "#15005B",
53-
backgroundImage: `url(${bgImgSrc})`,
53+
minHeight: "1.5rem",
54+
backgroundColor: "var(--tiui-palette-peacock-100)",
55+
// backgroundImage: `url(${bgImgSrc})`,
5456
backgroundPosition: "bottom left",
5557
backgroundSize: "400px auto",
5658
backgroundRepeat: "no-repeat",
59+
paddingTop: "0.5rem",
60+
paddingBottom: "0.5rem",
5761
}}
5862
>
5963
<Stack
@@ -84,19 +88,22 @@ export function Banner() {
8488
}
8589
sx={(theme) => ({
8690
textDecoration: "none",
87-
color: "website.m1",
91+
color: "text.primary",
8892
height: "100%",
8993
px: 2,
9094
[theme.breakpoints.down("md")]: {
9195
px: 1,
9296
},
97+
":hover span": {
98+
textDecoration: "underline",
99+
},
93100
})}
94101
>
95102
{textList.map((text, index) => (
96103
<Fragment key={index}>
97104
{!index ? (
98-
<Stack direction="row" alignItems="center" spacing={2}>
99-
{logo}
105+
<Stack direction="row" alignItems="center" spacing={1}>
106+
<Box>{logo}</Box>
100107
<Typography component="span" variant="body2" color="inherit">
101108
{text}
102109
</Typography>

src/components/Layout/Header.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,15 @@ export default function Header(props: {
3636
zIndex: 9,
3737
backgroundColor: "carbon.50",
3838
boxShadow: "none",
39-
height: props.bannerEnabled ? "7rem" : "5rem",
40-
borderBottom: `1px solid ${theme.palette.carbon[400]}`,
39+
height: props.bannerEnabled ? "7.5rem" : "5rem",
4140
}}
4241
>
43-
{props.bannerEnabled && <Banner />}
4442
<Toolbar
4543
sx={{
4644
height: "100%",
4745
paddingLeft: "24px",
4846
paddingRight: "24px",
47+
borderBottom: `1px solid ${theme.palette.carbon[400]}`,
4948
}}
5049
>
5150
{props.menu}
@@ -78,6 +77,7 @@ export default function Header(props: {
7877
buildType={props.buildType}
7978
/>
8079
</Toolbar>
80+
{props.bannerEnabled && <Banner />}
8181
</AppBar>
8282
);
8383
}

src/components/Navigation/LeftNav.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ interface LeftNavProps {
2424
pathConfig: PathConfig;
2525
availIn: string[];
2626
buildType?: BuildType;
27+
bannerEnabled?: boolean;
2728
}
2829

2930
export function LeftNavDesktop(props: LeftNavProps) {
@@ -44,9 +45,9 @@ export function LeftNavDesktop(props: LeftNavProps) {
4445
<Box
4546
sx={{
4647
position: "sticky",
47-
top: "80px",
48+
top: props.bannerEnabled ? "7.5rem" : "5rem",
4849
height: "100%",
49-
maxHeight: "calc(100vh - 80px)",
50+
maxHeight: `calc(100vh - ${props.bannerEnabled ? "7.5rem" : "5rem"})`,
5051
boxSizing: "border-box",
5152
overflowY: "auto",
5253
padding: "20px 14px",

src/templates/404Template.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default function PageNotFoundTemplate({
8282
<Seo lang={language as Locale} title="404 Not Found" noindex />
8383
<Container
8484
sx={{
85-
marginTop: bannerVisible ? "7rem" : "5rem",
85+
marginTop: bannerVisible ? "7.5rem" : "5rem",
8686
minHeight: "calc(100vh - 30rem)",
8787
display: "flex",
8888
alignItems: "center",

src/templates/CloudAPIReferenceTemplate.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ export default function APIReferenceTemplate({
132132
},
133133
]}
134134
/>
135-
<Box sx={{ marginTop: bannerVisible ? "7rem" : "5rem", width: "100%" }}>
135+
<Box
136+
sx={{ marginTop: bannerVisible ? "7.5rem" : "5rem", width: "100%" }}
137+
>
136138
<Box id="redoc-container" data-testid="redoc-container" />
137139
</Box>
138140
</Layout>

src/templates/DocSearchTemplate.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export default function DocSearchTemplate({
207207
<Layout bannerEnabled={bannerVisible}>
208208
<Container
209209
sx={{
210-
marginTop: bannerVisible ? "7rem" : "5rem",
210+
marginTop: bannerVisible ? "7.5rem" : "5rem",
211211
minHeight: "calc(100vh - 30rem)",
212212
position: "relative",
213213
}}

src/templates/DocTemplate.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default function DocTemplate({
8686
const stableBranch = getStable(pathConfig.repo);
8787

8888
const { language } = useI18next();
89-
const bannerVisible = feature?.banner && language !== Locale.ja;
89+
const bannerVisible = feature?.banner;
9090
const isGlobalHome = !!feature?.globalHome;
9191

9292
return (
@@ -146,7 +146,7 @@ export default function DocTemplate({
146146
archived={buildType === "archive"}
147147
/>
148148
<Box
149-
sx={{ marginTop: bannerVisible ? "7rem" : "5rem", display: "flex" }}
149+
sx={{ marginTop: bannerVisible ? "7.5rem" : "5rem", display: "flex" }}
150150
className={clsx("PingCAP-Doc")}
151151
>
152152
<Box sx={{ display: "flex", width: "100%" }}>
@@ -158,6 +158,7 @@ export default function DocTemplate({
158158
pathConfig={pathConfig}
159159
availIn={availIn.version}
160160
buildType={buildType}
161+
bannerEnabled={bannerVisible}
161162
/>
162163
)}
163164
<Box

0 commit comments

Comments
 (0)