Skip to content

Commit 002f620

Browse files
committed
Fixed missing components from base Docusaurus lab
1 parent 9383466 commit 002f620

File tree

5 files changed

+148
-0
lines changed

5 files changed

+148
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import "./main.css";
2+
import React from "react";
3+
4+
export default function BrowserWindow(props) {
5+
// Straight out of w3schools: https://www.w3schools.com/howto/howto_css_browser_window.asp
6+
7+
const url = props.url || "http://localhost:3000";
8+
9+
return (
10+
<div className="browser container">
11+
<div className="row">
12+
<div className="column left">
13+
<span className="dot" style={{background: "#ED594A"}}></span>
14+
<span className="dot" style={{background: "#FDD800"}}></span>
15+
<span className="dot" style={{background: "#5AC05A"}}></span>
16+
</div>
17+
<div className="column middle">
18+
<input type="text" value={url} />
19+
</div>
20+
<div className="column right">
21+
<div style={{float: "right"}}>
22+
<span className="bar"></span>
23+
<span className="bar"></span>
24+
<span className="bar"></span>
25+
</div>
26+
</div>
27+
</div>
28+
29+
<div className="content">
30+
{props.children}
31+
</div>
32+
</div>
33+
)
34+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
* {
2+
box-sizing: border-box;
3+
}
4+
5+
/* The browser window */
6+
.browser.container {
7+
border: 3px solid #f1f1f1;
8+
border-top-left-radius: 4px;
9+
border-top-right-radius: 4px;
10+
margin-bottom: 10px;
11+
cursor: not-allowed;
12+
}
13+
14+
/* Container for columns and the top "toolbar" */
15+
.browser .row {
16+
padding: 10px;
17+
background: #f1f1f1;
18+
border-top-left-radius: 4px;
19+
border-top-right-radius: 4px;
20+
}
21+
22+
/* Create three unequal columns that floats next to each other */
23+
.browser .column {
24+
float: left;
25+
}
26+
27+
.browser .left {
28+
width: 15%;
29+
}
30+
31+
.browser .right {
32+
width: 10%;
33+
}
34+
35+
.browser .middle {
36+
width: 75%;
37+
}
38+
39+
/* Clear floats after the columns */
40+
.browser .row:after {
41+
content: "";
42+
display: table;
43+
clear: both;
44+
}
45+
46+
/* Three dots */
47+
.browser .dot {
48+
margin-top: 4px;
49+
height: 12px;
50+
width: 12px;
51+
background-color: #bbb;
52+
border-radius: 50%;
53+
display: inline-block;
54+
}
55+
56+
/* Style the input field */
57+
.browser input[type=text] {
58+
width: 100%;
59+
border-radius: 3px;
60+
border: none;
61+
background-color: white;
62+
margin-top: -8px;
63+
height: 25px;
64+
color: #666;
65+
padding: 5px;
66+
}
67+
68+
/* Three bars (hamburger menu) */
69+
.browser .bar {
70+
width: 17px;
71+
height: 3px;
72+
background-color: #aaa;
73+
margin: 3px 0;
74+
display: block;
75+
}
76+
77+
/* Page content */
78+
.browser .content {
79+
padding: 10px;
80+
text-align: center;
81+
}

src/components/Link.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from "react";
2+
import Link from '@docusaurus/Link';
3+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
4+
5+
export default function UTMLink(props) {
6+
const context = useDocusaurusContext();
7+
const utmParams = context?.siteConfig?.customFields?.utmParams || '';
8+
const to = `${props.to}?${utmParams}`;
9+
return <Link {...props} to={to} />;
10+
}

src/components/Screenshot.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from "react";
2+
import BrowserWindow from "@site/src/components/BrowserWindow";
3+
import useBaseUrl from '@docusaurus/useBaseUrl';
4+
5+
export default function Screenshot(props) {
6+
return (
7+
<BrowserWindow {...props}>
8+
<img src={useBaseUrl(props.src)} alt={props.alt} />
9+
</BrowserWindow>
10+
)
11+
};

src/theme/MDXComponents.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
// Import the original mapper
3+
import MDXComponents from '@theme-original/MDXComponents';
4+
import Link from "@site/src/components/Link";
5+
import Screenshot from "@site/src/components/Screenshot";
6+
7+
export default {
8+
// Re-use the default mapping
9+
...MDXComponents,
10+
Link,
11+
Screenshot
12+
};

0 commit comments

Comments
 (0)