Skip to content

Commit 3cf57f0

Browse files
add: adding new theme for the codeblock, searchbar, and general body
1 parent 3c4a0f0 commit 3cf57f0

33 files changed

+935
-27
lines changed

docs/tests.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# CodeBlock Tests
6+
7+
```cpp showLineNumbers
8+
#include <iostream>
9+
10+
int main()
11+
{
12+
std::cout << "Hello, World!" << std::endl;
13+
return 0;
14+
}
15+
```
16+
17+
With title
18+
19+
```cpp title="Matrix.hpp" showLineNumbers
20+
UCLASS()
21+
22+
class EXAMPLEPROJECT_API AExampleActor : public AActor
23+
{
24+
GENERATED_BODY()
25+
26+
public:
27+
// Sets default values for this actor's properties
28+
AExampleActor();
29+
30+
protected:
31+
32+
// Called when the game starts or when spawned
33+
virtual void BeginPlay() override;
34+
};
35+
```

docusaurus.config.ts

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { themes as prismThemes } from 'prism-react-renderer';
1+
import unrealTheme from './src/theme/prism-unreal-theme';
22
import type { Config } from '@docusaurus/types';
33
import type * as Preset from '@docusaurus/preset-classic';
44

@@ -74,12 +74,13 @@ const config: Config = {
7474
// Replace with your project's social card
7575
image: 'img/docusaurus-social-card.jpg',
7676
colorMode: {
77-
respectPrefersColorScheme: true
77+
defaultMode: 'dark',
78+
disableSwitch: true
7879
},
7980
navbar: {
80-
title: 'My Site',
81+
title: 'Graphical Playground',
8182
logo: {
82-
alt: 'My Site Logo',
83+
alt: 'GP Logo',
8384
src: 'img/logo.svg'
8485
},
8586
items: [
@@ -91,9 +92,13 @@ const config: Config = {
9192
},
9293
{ to: '/blog', label: 'Blog', position: 'left' },
9394
{
94-
href: 'https://github.com/facebook/docusaurus',
95+
href: 'https://github.com/GraphicalPlayground',
9596
label: 'GitHub',
9697
position: 'right'
98+
},
99+
{
100+
type: 'localeDropdown',
101+
position: 'right'
97102
}
98103
]
99104
},
@@ -111,20 +116,7 @@ const config: Config = {
111116
},
112117
{
113118
title: 'Community',
114-
items: [
115-
{
116-
label: 'Stack Overflow',
117-
href: 'https://stackoverflow.com/questions/tagged/docusaurus'
118-
},
119-
{
120-
label: 'Discord',
121-
href: 'https://discordapp.com/invite/docusaurus'
122-
},
123-
{
124-
label: 'X',
125-
href: 'https://x.com/docusaurus'
126-
}
127-
]
119+
items: []
128120
},
129121
{
130122
title: 'More',
@@ -135,16 +127,31 @@ const config: Config = {
135127
},
136128
{
137129
label: 'GitHub',
138-
href: 'https://github.com/facebook/docusaurus'
130+
href: 'https://github.com/GraphicalPlayground'
139131
}
140132
]
141133
}
142134
],
143-
copyright: `Copyright © ${new Date().getFullYear()} My Project, Inc. Built with Docusaurus.`
135+
copyright: `Copyright © ${new Date().getFullYear()} Graphical Playground, Inc.`
144136
},
145137
prism: {
146-
theme: prismThemes.github,
147-
darkTheme: prismThemes.dracula
138+
theme: unrealTheme,
139+
darkTheme: unrealTheme
140+
},
141+
algolia: {
142+
// The application ID provided by Algolia
143+
appId: 'F2NV537VZ4',
144+
145+
// Public API key: it is safe to commit it
146+
apiKey: '7c4933067d38c508bbff2b4e26c78fee',
147+
148+
indexName: 'Graphical Playground Documentation',
149+
150+
// Optional: see doc section below
151+
contextualSearch: true,
152+
153+
// Optional: whether the insights feature is enabled or not on Docsearch (`false` by default)
154+
insights: false
148155
}
149156
} satisfies Preset.ThemeConfig
150157
};

package-lock.json

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"dependencies": {
1818
"@docusaurus/core": "3.9.2",
1919
"@docusaurus/preset-classic": "3.9.2",
20+
"@docusaurus/theme-search-algolia": "^3.9.2",
2021
"@mdx-js/react": "^3.0.0",
2122
"clsx": "^2.0.0",
2223
"prism-react-renderer": "^2.3.0",

src/css/custom.css

Lines changed: 140 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,57 @@
44
* work well for content-centric websites.
55
*/
66

7+
/* EDS Iconfont */
8+
@font-face {
9+
font-family: 'EDS Iconfont';
10+
src: url('/fonts/eds-iconfont.woff2') format('woff2');
11+
font-weight: normal;
12+
font-style: normal;
13+
font-display: swap;
14+
}
15+
16+
/* Inter Family */
17+
@font-face {
18+
font-family: 'Inter';
19+
src: url('/fonts/inter-regular.woff2') format('woff2');
20+
font-weight: 400;
21+
font-style: normal;
22+
font-display: swap;
23+
}
24+
25+
@font-face {
26+
font-family: 'Inter';
27+
src: url('/fonts/inter-medium.woff2') format('woff2');
28+
font-weight: 500;
29+
font-style: normal;
30+
font-display: swap;
31+
}
32+
33+
@font-face {
34+
font-family: 'Inter';
35+
src: url('/fonts/inter-bold.woff2') format('woff2');
36+
font-weight: 700;
37+
font-style: normal;
38+
font-display: swap;
39+
}
40+
41+
@font-face {
42+
font-family: 'Inter Tight';
43+
src: url('/fonts/inter-tight.woff2') format('woff2');
44+
font-weight: normal;
45+
font-style: normal;
46+
font-display: swap;
47+
}
48+
49+
/* Recursive Mono */
50+
@font-face {
51+
font-family: 'Recursive Mono';
52+
src: url('/fonts/recursive-mono-regular.woff2') format('woff2');
53+
font-weight: 400;
54+
font-style: normal;
55+
font-display: swap;
56+
}
57+
758
/* You can override the default Infima variables here. */
859
:root {
960
--ifm-color-primary: #2e8555;
@@ -13,8 +64,12 @@
1364
--ifm-color-primary-light: #33925d;
1465
--ifm-color-primary-lighter: #359962;
1566
--ifm-color-primary-lightest: #3cad6e;
16-
--ifm-code-font-size: 95%;
17-
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1);
67+
--ifm-code-font-size: 0.875em;
68+
--docusaurus-highlighted-code-line-bg: rgba(255, 255, 255, 0.08);
69+
--ifm-font-family-monospace: 'Recursive Mono', monospace;
70+
--ifm-pre-padding: 1rem;
71+
--ifm-code-border-radius: 16px;
72+
--ifm-background-color: #101014;
1873
}
1974

2075
/* For readability concerns, you should choose a lighter palette in dark mode. */
@@ -26,5 +81,87 @@
2681
--ifm-color-primary-light: #29d5b0;
2782
--ifm-color-primary-lighter: #32d8b4;
2883
--ifm-color-primary-lightest: #4fddbf;
29-
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3);
84+
--docusaurus-highlighted-code-line-bg: rgba(255, 255, 255, 0.12);
85+
--ifm-background-color: #101014;
86+
}
87+
88+
/* Page background */
89+
body {
90+
background-color: #101014;
91+
font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
92+
margin: 0;
93+
font-size: 1rem;
94+
font-weight: 400;
95+
line-height: 1.65;
96+
color: #ffffff;
97+
-webkit-text-size-adjust: 100%;
98+
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
99+
-webkit-font-smoothing: antialiased;
100+
-moz-osx-font-smoothing: grayscale;
101+
}
102+
103+
/* Code block specific styles */
104+
pre {
105+
display: block;
106+
margin-top: 0;
107+
margin-bottom: 1rem;
108+
overflow: auto;
109+
font-size: 0.875em;
110+
color: #abb2bf;
111+
background: #282c34;
112+
padding: 1rem;
113+
border-radius: 16px;
114+
font-family: 'Recursive Mono', monospace;
115+
}
116+
117+
pre, code, kbd, samp {
118+
font-family: 'Recursive Mono', monospace;
119+
font-size: 1em;
120+
}
121+
122+
code {
123+
font-size: .875em;
124+
word-wrap: break-word;
125+
}
126+
127+
/* Inline code */
128+
:not(pre) > code {
129+
background-color: rgba(40, 44, 52, 0.8);
130+
color: #abb2bf;
131+
border: 0.5px solid rgba(255, 255, 255, 0.08);
132+
padding: 0.1rem 0.3rem;
133+
border-radius: 4px;
134+
}
135+
136+
/* Responsive adjustments */
137+
@media screen and (max-width: 768px) {
138+
:root {
139+
--ifm-code-border-radius: 12px;
140+
--ifm-pre-padding: 0.75rem;
141+
}
142+
143+
pre {
144+
border-radius: 12px;
145+
padding: 0.75rem;
146+
font-size: 0.8125em;
147+
}
148+
}
149+
150+
@media screen and (max-width: 480px) {
151+
pre {
152+
border-radius: 8px;
153+
padding: 0.5rem;
154+
font-size: 0.75em;
155+
}
156+
}
157+
158+
mark, .mark, :not(.prism-code) > code:not(.prism-code) {
159+
border-radius: 6px;
160+
}
161+
162+
mark, :not(.prism-code) > code:not(.prism-code), .mark {
163+
border: .0625rem solid #404044;
164+
background: #202024;
165+
padding: .125rem .4375rem;
166+
color: #fff;
30167
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import React, { type ReactNode } from 'react';
2+
import clsx from 'clsx';
3+
import type { Props } from '@theme/CodeBlock/Buttons/Button';
4+
5+
export default function CodeBlockButton({ className, ...props }: Props): ReactNode {
6+
return <button type='button' {...props} className={clsx('clean-btn', className)} />;
7+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import React, { useCallback, useState, useRef, useEffect, type ReactNode } from 'react';
2+
import clsx from 'clsx';
3+
import { translate } from '@docusaurus/Translate';
4+
import { useCodeBlockContext } from '@docusaurus/theme-common/internal';
5+
import Button from '@theme/CodeBlock/Buttons/Button';
6+
import type { Props } from '@theme/CodeBlock/Buttons/CopyButton';
7+
import IconCopy from '@theme/Icon/Copy';
8+
import IconSuccess from '@theme/Icon/Success';
9+
10+
import styles from './styles.module.css';
11+
12+
function title() {
13+
return translate({
14+
id: 'theme.CodeBlock.copy',
15+
message: 'Copy',
16+
description: 'The copy button label on code blocks'
17+
});
18+
}
19+
20+
function ariaLabel(isCopied: boolean) {
21+
return isCopied
22+
? translate({
23+
id: 'theme.CodeBlock.copied',
24+
message: 'Copied',
25+
description: 'The copied button label on code blocks'
26+
})
27+
: translate({
28+
id: 'theme.CodeBlock.copyButtonAriaLabel',
29+
message: 'Copy code to clipboard',
30+
description: 'The ARIA label for copy code blocks button'
31+
});
32+
}
33+
34+
function useCopyButton() {
35+
const {
36+
metadata: { code }
37+
} = useCodeBlockContext();
38+
const [isCopied, setIsCopied] = useState(false);
39+
const copyTimeout = useRef<number | undefined>(undefined);
40+
41+
const copyCode = useCallback(() => {
42+
navigator.clipboard.writeText(code).then(() => {
43+
setIsCopied(true);
44+
copyTimeout.current = window.setTimeout(() => {
45+
setIsCopied(false);
46+
}, 1000);
47+
});
48+
}, [code]);
49+
50+
useEffect(() => () => window.clearTimeout(copyTimeout.current), []);
51+
52+
return { copyCode, isCopied };
53+
}
54+
55+
export default function CopyButton({ className }: Props): ReactNode {
56+
const { copyCode, isCopied } = useCopyButton();
57+
58+
return (
59+
<Button
60+
aria-label={ariaLabel(isCopied)}
61+
title={title()}
62+
className={clsx(className, styles.copyButton, isCopied && styles.copyButtonCopied)}
63+
onClick={copyCode}
64+
>
65+
<span className={styles.copyButtonIcons} aria-hidden='true'>
66+
<IconCopy className={styles.copyButtonIcon} />
67+
<IconSuccess className={styles.copyButtonSuccessIcon} />
68+
</span>
69+
</Button>
70+
);
71+
}

0 commit comments

Comments
 (0)