Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 08fdde3

Browse files
Hubert KosterHubert Koster
authored andcommitted
chore: refactoring code
1 parent 8274f8d commit 08fdde3

File tree

8 files changed

+114
-74
lines changed

8 files changed

+114
-74
lines changed

docs/intro.md

Lines changed: 0 additions & 52 deletions
This file was deleted.

docs/intro.mdx

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
title: Introduction
3+
hide_title: false
4+
draft: false
5+
sidebar_label: Introduction
6+
sidebar_position: 0
7+
sidebar_class_name: hide-sidebar-item
8+
tags:
9+
- introduction
10+
- getting started
11+
- quick startup
12+
keywords:
13+
- deriv
14+
- api
15+
- getting started
16+
- quick startup
17+
description: Getting started with Deriv API
18+
---
19+
20+
import RenderOfficialContents from '@site/src/components/RenderOfficialContents';
21+
22+
Our Documentation is divided in several sections:
23+
24+
<RenderOfficialContents>
25+
<ul>
26+
<li><a href='category/core-concepts'>Core concepts</a></li>
27+
<li><a href='category/code-examples'>Code examples</a></li>
28+
<li><a href='category/languages'>Languages</a></li>
29+
<li><a href='category/guides'>Guides</a></li>
30+
<li><a href='setting-up-a-deriv-application'>Setting up a deriv app</a></li>
31+
</ul>
32+
<ul>
33+
<li><a href='category/code-examples'>Code examples</a></li>
34+
</ul>
35+
</RenderOfficialContents>
36+
37+
<h3>Quick Start</h3>
38+
39+
<RenderOfficialContents>
40+
<h4>Core Concepts</h4>
41+
</RenderOfficialContents>
42+
43+
<RenderOfficialContents>
44+
<p>Have a look at the <a href='/docs/category/core-concepts'>Core concepts</a> pages and take your time to read through it. These concepts will help you get familiar with our WebSocket server api and how to use it more efficiently. They are not related to any of our frameworks or libraries.</p>
45+
</RenderOfficialContents>
46+
47+
<RenderOfficialContents>
48+
<p>When you read through the <a href='/docs/category/core-concepts'>Core concepts</a> page, you can start choosing your implementation approach based on the language, framework or library you want to use in your application.</p>
49+
</RenderOfficialContents>
50+
51+
<h4>Code Examples</h4>
52+
53+
<p>If you want to know how you can implement our API within your code, then we suggest to have a look at our <a href='/docs/category/code-examples'>Code examples</a>. These code examples come in `CodeSandboxes`. This allows you to easily fork the code examples and experiment with them for personal use. For now we only have JavaScript code examples, but, we plan to add more examples that are created with different languages, frameworks and libraries in the near future.</p>
54+
55+
<RenderOfficialContents>
56+
<h4>Languages</h4>
57+
</RenderOfficialContents>
58+
59+
<RenderOfficialContents>
60+
<p>When using our code examples, we also suggest to have a look at our <a href='/docs/category/languages'>Languages</a> section. Here, we describe in detail how you can setup your personal project properly to make use of our API. This will surely come helpful when you try to integrate some of our code examples in your own project.</p>
61+
</RenderOfficialContents>
62+
63+
<RenderOfficialContents>
64+
<h4>Guides</h4>
65+
</RenderOfficialContents>
66+
67+
<RenderOfficialContents>
68+
<p>If you want to know for example how you can `monetize your application` or how to create a `secure way for users to log in` to your application, then we provide a handful of <a href='/docs/category/guides'>Guides</a> that can assist you with that.</p>
69+
</RenderOfficialContents>
70+
71+
<RenderOfficialContents>
72+
<h4>Setting up a Deriv application</h4>
73+
</RenderOfficialContents>
74+
75+
<RenderOfficialContents>
76+
<p>If you want to know more about the essentials that are needed to setup your own application, then have a look at the <a href='/docs/setting-up-a-deriv-application'>Setting up a Deriv application</a> section.</p>
77+
</RenderOfficialContents>

src/components/ApiTokenNavbarItem/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import TokenDropdown from '../CustomSelectDropdown/token-dropdown/TokenDropdown'
66
import useClickOutsideDropdown from '@site/src/hooks/useClickOutsideDropdown';
77
import useAppManager from '@site/src/hooks/useAppManager';
88
import styles from './api_token_switcher.module.scss';
9+
import RenderOfficialContents from '../RenderOfficialContents';
910

1011
const ApiTokenNavbarItem = () => {
1112
const { is_logged_in, is_authorized } = useAuthContext();
@@ -55,7 +56,9 @@ const ApiTokenNavbarItem = () => {
5556
<span>{currentToken.display_name}</span>
5657
</button>
5758
) : (
58-
<CreateToken />
59+
<RenderOfficialContents>
60+
<CreateToken />
61+
</RenderOfficialContents>
5962
)}
6063

6164
{is_toggle_dropdown && (
@@ -65,7 +68,9 @@ const ApiTokenNavbarItem = () => {
6568
<TokenDropdown />
6669
</div>
6770
)}
68-
<CreateToken />
71+
<RenderOfficialContents>
72+
<CreateToken />
73+
</RenderOfficialContents>
6974
</div>
7075
)}
7176
</div>

src/components/RenderOfficialContents/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ type TRenderOfficialContents = {
88
const RenderOfficialContents = ({ children }: TRenderOfficialContents) => {
99
const Alternative = () => (children[1] ? <React.Fragment>{children[1]}</React.Fragment> : <></>);
1010
const { is_official_domain } = useOfficialContentsContext();
11-
return is_official_domain ? <React.Fragment>{children}</React.Fragment> : <Alternative />;
11+
return is_official_domain ? (
12+
<React.Fragment>{children[0] ?? children}</React.Fragment>
13+
) : (
14+
<Alternative />
15+
);
1216
};
1317

1418
export default RenderOfficialContents;

src/contexts/official-contents/official-contents.context.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Dispatch, SetStateAction } from 'react';
1+
import React from 'react';
22

33
export interface IOfficialContents {
44
is_official_domain: boolean;

src/styles/index.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ div[class*='sidebarViewport'] {
174174
align-items: center;
175175
}
176176

177+
.main-wrapper {
178+
height: calc(100vh - rem(7.2));
179+
}
180+
177181
.navbar {
178182
padding: 0 5%;
179183
height: var(--nav-height);

src/theme/Navbar/Content/index.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ function useNavbarItems() {
1414
return useThemeConfig().navbar.items;
1515
}
1616
function NavbarItems({ items }) {
17-
let unofficial_domain_item;
17+
const unofficial_domain_items = [];
1818
const { is_official_domain } = useOfficialContentsContext();
1919

2020
for (const value of Object.values(items)) {
21-
if (value.label === 'Documentation') {
22-
unofficial_domain_item = value;
23-
break;
21+
console.log(value);
22+
if (value.label === 'Documentation' || value.position === 'right') {
23+
unofficial_domain_items.push(value);
2424
}
2525
}
2626

@@ -46,19 +46,21 @@ function NavbarItems({ items }) {
4646
</React.Fragment>
4747
) : (
4848
<React.Fragment>
49-
<ErrorCauseBoundary
50-
key={unofficial_domain_item?.label}
51-
onError={(error) =>
52-
new Error(
53-
`A theme navbar item failed to render.
54-
Please double-check the following navbar item (themeConfig.navbar.items) of your Docusaurus config:
55-
${JSON.stringify(unofficial_domain_item, null, 2)}`,
56-
{ cause: error },
57-
)
58-
}
59-
>
60-
<NavbarItem {...unofficial_domain_item} />
61-
</ErrorCauseBoundary>
49+
{unofficial_domain_items.map((unofficial_item, i) => (
50+
<ErrorCauseBoundary
51+
key={i}
52+
onError={(error) =>
53+
new Error(
54+
`A theme navbar item failed to render.
55+
Please double-check the following navbar item (themeConfig.navbar.items) of your Docusaurus config:
56+
${JSON.stringify(unofficial_item, null, 2)}`,
57+
{ cause: error },
58+
)
59+
}
60+
>
61+
<NavbarItem {...unofficial_item} />
62+
</ErrorCauseBoundary>
63+
))}
6264
</React.Fragment>
6365
)}
6466
</>

src/utils/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const domains = [
3434
'staging.deriv.be',
3535
'staging.deriv.me',
3636
'staging.deriv.com',
37-
'localhost',
37+
// 'localhost',
3838
'deriv-com-git-fork',
3939
'deriv-developers-portal-git-fork',
4040
'deriv-api-docs-git-fork',

0 commit comments

Comments
 (0)