-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DocumentationPage component (for Resources / Quickstart page) and…
… make header/sidebar fixed on scroll (#662) Co-authored-by: Serena Li <serena.li.usa@gmail.com>
- Loading branch information
1 parent
25247ae
commit 5a4e946
Showing
15 changed files
with
1,076 additions
and
26 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from "react"; | ||
import ReactMarkdown from "react-markdown"; | ||
import { Link } from "react-router-dom"; | ||
|
||
const isInternalLink = (to: string): boolean => { | ||
const url = new URL(to, window.location.origin); | ||
return url.hostname === window.location.hostname; | ||
}; | ||
|
||
interface DocumentationPageProps { | ||
text: string; | ||
} | ||
|
||
const DocumentationPage: React.FC<DocumentationPageProps> = ({ text }) => { | ||
return ( | ||
<div className="h-full w-full overflow-auto bg-white p-6"> | ||
<ReactMarkdown | ||
components={{ | ||
a: ({ href, ...props }) => { | ||
const target = href ?? ""; | ||
if (isInternalLink(target)) { | ||
return ( | ||
<Link | ||
className="text-cyan-600 hover:underline" | ||
to={target} | ||
{...props} | ||
/> | ||
); | ||
} else { | ||
return ( | ||
<a | ||
className="text-cyan-600 hover:underline" | ||
href={target} | ||
{...props} | ||
/> | ||
); | ||
} | ||
}, | ||
}} | ||
> | ||
{text} | ||
</ReactMarkdown> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DocumentationPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
export const BC23_QUICKSTART = `# Quick Start | ||
This is the Battlecode 2023 contest website, which will be your main hub for all Battlecode-related things for the duration of the contest. For a general overview of what Battlecode is, visit [our landing page](https://battlecode.org/). | ||
## Create an account and team | ||
To participate in Battlecode, you need an account and a team. Each team can consist of 1 to 4 people. | ||
[Create an account](/register) on this website, and then go to the [team section](/bc23/team) to either create or join a team. | ||
## Installation | ||
### Step 1: Install Java | ||
You'll need a Java Development Kit (JDK) version 8. Unfortunately, higher versions will not work. [Download it here](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html). You may need to create an Oracle account. | ||
- Alternatively, you can install a JDK yourself using your favorite package manager. Make sure it's an Oracle JDK — we don't support anything else — and is compatible with Java 8. | ||
If you're unsure how to install the JDK, you can find instructions for all operating systems [here](https://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html) (pay attention to \`PATH\` and \`CLASSPATH\`). | ||
### Step 2: Download Battlecode | ||
Next, you should download the [Battlecode 2023 scaffold](https://github.com/battlecode/battlecode23-scaffold). To get up and running quickly, you can click "Clone or download" and then "Download ZIP," and move on to the next step. | ||
TODO: the rest of the page | ||
`; | ||
|
||
export const BC23_RESOURCES = `# Markdown syntax guide | ||
# This is a Heading h1 | ||
## This is a Heading h2 | ||
###### This is a Heading h6 | ||
*This text will be italic* | ||
_This will also be italic_ | ||
**This text will be bold** | ||
__This will also be bold__ | ||
_You **can** combine them_ | ||
### Unordered List | ||
* Item 1 | ||
* Item 2 | ||
* Item 2a | ||
* Item 2b | ||
### Ordered List | ||
1. Item 1 | ||
1. Item 2 | ||
1. Item 3 | ||
1. Item 3a | ||
1. Item 3b | ||
![This is an alt text for an image.](/image/sample.png "This is a sample image.") | ||
[This links to example.com](https://example.com). | ||
\`\`\` | ||
let message = 'Hello world'; | ||
alert(message); | ||
\`\`\` | ||
this is \`an inline code block\` | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,37 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Josefin+Sans:wght@100;300;400;500;700&display=swap'); | ||
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Josefin+Sans:wght@100;300;400;500;700&display=swap"); | ||
|
||
@layer base { | ||
h1 { | ||
@apply pb-4 text-3xl font-medium text-gray-900; | ||
} | ||
h2 { | ||
@apply pb-4 pt-6 text-2xl font-medium text-gray-900; | ||
} | ||
h3 { | ||
@apply pb-4 text-xl font-medium text-gray-900; | ||
} | ||
h4 { | ||
@apply pb-4 text-lg font-medium text-gray-700; | ||
} | ||
p { | ||
@apply pb-4 text-gray-900; | ||
} | ||
code { | ||
@apply rounded bg-gray-100 px-1 py-0.5 text-sm text-cyan-900; | ||
} | ||
pre code { | ||
@apply p-0; | ||
} | ||
pre { | ||
@apply rounded bg-gray-100 px-4 py-3; | ||
} | ||
ul { | ||
@apply ml-6 list-outside list-disc pb-4; | ||
} | ||
ol { | ||
@apply ml-6 list-outside list-decimal pb-4; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import React from "react"; | ||
import DocumentationPage from "../components/DocumentationPage"; | ||
import { BC23_QUICKSTART } from "../content/bc23"; | ||
|
||
const QuickStart: React.FC = () => { | ||
return <p>quickstart page</p>; | ||
return <DocumentationPage text={BC23_QUICKSTART} />; | ||
}; | ||
|
||
export default QuickStart; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from "react"; | ||
import { BC23_RESOURCES } from "../content/bc23"; | ||
import DocumentationPage from "../components/DocumentationPage"; | ||
|
||
const Resources = (): JSX.Element => { | ||
return <DocumentationPage text={BC23_RESOURCES} />; | ||
}; | ||
|
||
export default Resources; |