Skip to content

Commit 18ac94d

Browse files
Improve documentation sidesheet (#9724)
* Improve styles for table, links, code blocks. Remove html comments * Fix img url * Edit build.gradle * Fix type * Fix url images
1 parent f0546ed commit 18ac94d

File tree

8 files changed

+199
-7
lines changed

8 files changed

+199
-7
lines changed

airbyte-webapp/build.gradle

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ task copyDocs(type: Copy) {
5959
duplicatesStrategy DuplicatesStrategy.INCLUDE
6060
}
6161

62+
// Copy images that are used in .md integration documentation docs
63+
task copyAssets(type: Copy) {
64+
dependsOn copyDocker
65+
66+
from "${project.rootProject.projectDir}/docs/.gitbook"
67+
into "build/docker/bin/docs/.gitbook"
68+
duplicatesStrategy DuplicatesStrategy.INCLUDE
69+
}
70+
6271
task copyNginx(type: Copy) {
6372
dependsOn copyDocker
6473

@@ -69,11 +78,13 @@ task copyNginx(type: Copy) {
6978
copyBuild.dependsOn npm_run_build
7079
copyNginx.dependsOn npm_run_build
7180
copyDocs.dependsOn npm_run_build
81+
copyAssets.dependsOn npm_run_build
7282
assemble.dependsOn copyDocs
7383
copyDocker.dependsOn(npm_run_build)
7484

7585
Task dockerBuildTask = getDockerBuildTask("webapp", "$project.projectDir")
7686
dockerBuildTask.dependsOn(copyBuild)
7787
dockerBuildTask.dependsOn(copyNginx)
7888
dockerBuildTask.dependsOn(copyDocs)
79-
assemble.dependsOn(dockerBuildTask)
89+
dockerBuildTask.dependsOn(copyAssets)
90+
assemble.dependsOn(dockerBuildTask)

airbyte-webapp/package-lock.json

Lines changed: 107 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

airbyte-webapp/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"react-use-intercom": "^1.4.0",
4747
"react-widgets": "^4.6.1",
4848
"recharts": "^2.1.3",
49+
"rehype-urls": "^1.1.1",
4950
"remark-gfm": "^3.0.0",
5051
"rest-hooks": "^5.0.20",
5152
"sanitize-html": "^2.3.3",

airbyte-webapp/src/components/Markdown/Markdown.tsx

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,100 @@ import React from "react";
22
import ReactMarkdown from "react-markdown";
33
import remarkGfm from "remark-gfm";
44
import styled from "styled-components";
5+
import type { PluggableList } from "react-markdown/lib/react-markdown";
56

67
type Props = {
78
content?: string;
89
className?: string;
10+
rehypePlugins?: PluggableList;
911
};
1012

11-
const Markdown: React.FC<Props> = ({ content, className }) => {
13+
const Markdown: React.FC<Props> = ({ content, className, rehypePlugins }) => {
1214
return (
1315
<ReactMarkdown
1416
linkTarget="_blank"
1517
className={className}
18+
skipHtml
1619
remarkPlugins={[remarkGfm]}
20+
rehypePlugins={rehypePlugins}
1721
children={content || ""}
1822
/>
1923
);
2024
};
2125

2226
const StyledMarkdown = styled(Markdown)`
2327
* {
24-
color: rgba(59, 69, 78, 1);
25-
line-height: 20px;
28+
color: ${({ theme }) => theme.textColor};
29+
line-height: 24px;
30+
font-size: 16px;
2631
font-weight: 400;
2732
}
2833
2934
h1 {
3035
font-size: 48px;
3136
line-height: 56px;
37+
font-weight: bold;
38+
}
39+
40+
h2 {
41+
font-size: 24px;
42+
line-height: 36px;
43+
font-weight: bold;
44+
}
45+
46+
h3 {
47+
font-weight: bold;
3248
}
3349
3450
a {
35-
color: rgb(26, 25, 117);
51+
color: ${({ theme }) => theme.primaryColor};
3652
text-decoration: none;
3753
line-height: 24px;
3854
3955
&:hover {
4056
text-decoration: underline;
4157
}
4258
}
59+
60+
table {
61+
border-collapse: collapse;
62+
}
63+
64+
th,
65+
td {
66+
border: 1px solid ${({ theme }) => theme.borderTableColor};
67+
margin: 0;
68+
padding: 8px 16px;
69+
}
70+
71+
th {
72+
background: ${({ theme }) => theme.lightTableColor};
73+
}
74+
75+
blockquote {
76+
border-left: 4px solid ${({ theme }) => theme.borderTableColor};
77+
padding-left: 16px;
78+
margin-left: 25px;
79+
}
80+
81+
strong {
82+
font-weight: bold;
83+
}
84+
85+
code {
86+
background: ${({ theme }) => theme.lightTableColor};
87+
88+
&.language-sql,
89+
&.language-text {
90+
display: block;
91+
padding: 15px;
92+
overflow: auto;
93+
}
94+
}
95+
96+
img {
97+
max-width: 100%;
98+
}
4399
`;
44100

45101
export default StyledMarkdown;

airbyte-webapp/src/components/SideView/styled.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const Actions = styled.div`
2020
export const Body = styled.div`
2121
display: flex;
2222
flex-direction: column;
23-
padding: 70px 25px 0;
23+
padding: 70px 35px 20px;
2424
`;
2525

2626
export const Close = styled.div`

airbyte-webapp/src/theme.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export const theme = {
3838
whiteColor: "#FFFFFF",
3939
beigeColor: "#FEF9F4",
4040
darkBeigeColor: "#FFEBD7",
41+
borderTableColor: "#D3DCE4",
42+
lightTableColor: "#F5F7F9",
4143
darkGreyColor: "#8B8BA0",
4244
redColor: "#FF6A4D",
4345
lightRedColor: "#FF8870",
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference types="react-scripts" />
2+
declare module "rehype-urls";

airbyte-webapp/src/views/Connector/ServiceForm/components/Controls/Instruction.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ import React from "react";
22
import { FormattedMessage } from "react-intl";
33
import styled from "styled-components";
44
import { useToggle } from "react-use";
5+
import urls from "rehype-urls";
6+
import type { PluggableList } from "react-markdown/lib/react-markdown";
57

68
import useDocumentation from "hooks/services/useDocumentation";
79
import { LoadingPage } from "components";
810
import { SideView } from "components/SideView";
911
import { Markdown } from "components/Markdown";
1012
import { DestinationDefinition, SourceDefinition } from "core/domain/connector";
13+
import { useConfig } from "config";
1114

1215
type IProps = {
1316
selectedService: SourceDefinition | DestinationDefinition;
@@ -47,8 +50,18 @@ const Instruction: React.FC<IProps> = ({
4750
documentationUrl,
4851
}) => {
4952
const [isSideViewOpen, setIsSideViewOpen] = useToggle(false);
53+
const config = useConfig();
5054
const { data: docs, isLoading } = useDocumentation(documentationUrl);
5155

56+
const removeBaseUrl = (url: { path: string }) => {
57+
if (url.path.startsWith("../../")) {
58+
return url.path.replace("../../", `${config.integrationUrl}/`);
59+
}
60+
return url.path;
61+
};
62+
63+
const urlReplacerPlugin: PluggableList = [[urls, removeBaseUrl]];
64+
5265
return (
5366
<>
5467
{isSideViewOpen && (
@@ -70,7 +83,7 @@ const Instruction: React.FC<IProps> = ({
7083
{isLoading ? (
7184
<LoadingPage />
7285
) : docs ? (
73-
<Markdown content={docs} />
86+
<Markdown content={docs} rehypePlugins={urlReplacerPlugin} />
7487
) : (
7588
<FormattedMessage id="docs.notFoundError" />
7689
)}

0 commit comments

Comments
 (0)