Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rayan #21

Merged
merged 4 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
# npx lint-staged
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
},
"dependencies": {
"@mui/x-data-grid": "^5.0.1",
"antd": "^4.17.2",
"apexcharts": "^3.30.0",
"axios": "^0.24.0",
"next": "12.0.2",
"prop-types": "^15.7.2",
"react": "17.0.2",
"react-apexcharts": "^1.3.9",
"react-dom": "17.0.2"
Expand Down
2 changes: 1 addition & 1 deletion src/components/Chart/ChartsApex.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function ChartsApex() {
text: 'Transaction History - 24H',
align: 'left',
style: {
fontFamily: 'Lato',
fontFamily: 'inherit',
fontWeight: 'normal',
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/Footer/Footer.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
justify-content: center;
margin: 0 auto;
width: 100%;
background: var(--theme-page-background);
background: var(--theme-footer-bg);
box-shadow: 0 -0.25rem 0.25rem #0003;
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout/Layout.module.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.Main {
min-height: 100vh;
width: 100%;
height: 100%;
position: relative;
Expand All @@ -9,5 +8,6 @@
.container {
max-width: var(--screen-lg);
margin: 0 auto;
min-height: 100vh;
padding: 0 var(--space-xs);
}
5 changes: 2 additions & 3 deletions src/components/Navbar/Navbar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
flex-direction: column;
margin: 0 auto;
width: 100%;
background: var(--theme-layout-background);
padding-bottom: var(--space-xxs);
margin-bottom: var(--space-xs);
box-shadow: 0 0.25rem 0.25rem #0003;
box-shadow: 0 0.25rem 0.25rem #0002;
color: var(--theme-page-text);
background: var(--theme-page-background);
background: var(--theme-nav-bg);
}
.container .header {
width: 100%;
Expand Down
16 changes: 16 additions & 0 deletions src/components/atoms/DetailCard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ import Typeone from './TypeOne';
import TypeTwo from './TypeTwo';
import Image from 'next/image';

import PropTypes from 'prop-types';

DetailCard.propTypes = {
type: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
label: PropTypes.string,
sublabel: PropTypes.string,
delayTime: PropTypes.string,
text: PropTypes.string,
reserve: PropTypes.string,
reserveLabel: PropTypes.string,
reward: PropTypes.string,
rewardLabel: PropTypes.string,
footerLabel: PropTypes.string,
footerValue: PropTypes.string,
};

export default function DetailCard(props) {
return (
<div className={styles.detailcard}>
Expand Down
14 changes: 14 additions & 0 deletions src/components/atoms/RTTable/RTTRow.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import styles from './RTTRow.module.css';

import PropTypes from 'prop-types';

RTTRow.propTypes = {
fromId: PropTypes.string,
toId: PropTypes.string,
txnId: PropTypes.string,
operation: PropTypes.string,
txType: PropTypes.string,
amount: PropTypes.number,
amountUnit: PropTypes.string,
confirmations: PropTypes.number,
contracts: PropTypes.number,
};

function RTTRow(props) {
const {
fromId = '',
Expand Down
17 changes: 17 additions & 0 deletions src/components/atoms/RTTable/RTTRowBlock.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
import styles from './RTTRowBlock.module.css';

import PropTypes from 'prop-types';

RTTRowBlock.propTypes = {
block: PropTypes.string,
channel: PropTypes.string,
utc: PropTypes.string,
date: PropTypes.string,
mint: PropTypes.string,
mintUnit: PropTypes.string,
size: PropTypes.string,
sizeUnit: PropTypes.string,
txns: PropTypes.string,
txnsUnit: PropTypes.string,
type: PropTypes.string,
timeUnit: PropTypes.string,
};

function RTTRowBlock(props) {
const {
block = '00',
Expand Down
9 changes: 9 additions & 0 deletions src/components/atoms/RTTable/RTTable.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import styles from './RTTable.module.css';

import PropTypes from 'prop-types';

RTTable.propTypes = {
onClick: PropTypes.func,
children: PropTypes.any,
label: PropTypes.string,
buttonLabel: PropTypes.string,
};

function RTTable(props) {
const { label = 'Latest Blocks', buttonLabel: btnTxt = 'View All' } = props;
return (
Expand Down
37 changes: 25 additions & 12 deletions src/components/atoms/Rail/index.jsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,41 @@
import { useRef, useEffect } from 'react'
import { useRef, useEffect } from 'react';
import styles from './rail.module.css';
import PropTypes from 'prop-types';

const Rail = (props) => {
const railRef = useRef(null);
const scrollSpeed = typeof props.scrollSpeed === 'number' ? props.scrollSpeed : 1;
const scrollSpeed =
typeof props.scrollSpeed === 'number' ? props.scrollSpeed : 1;

useEffect(() => {
const el = railRef.current;
const onWheel = e => {
const onWheel = (e) => {
if (e.deltaY == 0) return;
e.preventDefault();
el.scrollTo({
left: el.scrollLeft + (e.deltaY * scrollSpeed),
behavior: "smooth" // "smooth" or "auto"
left: el.scrollLeft + e.deltaY * scrollSpeed,
behavior: 'smooth', // "smooth" or "auto"
});
};
if (el) {
el.addEventListener("wheel", onWheel);
el.addEventListener('wheel', onWheel);
}
return () => el && el.removeEventListener("wheel", onWheel);
return () => el && el.removeEventListener('wheel', onWheel);
}, []);

return (<main className={[props.className, styles.railContainer].join(' ')} ref={railRef}>
{props.children}
</main>);
}
export default Rail;
return (
<main
className={[props.className, styles.railContainer].join(' ')}
ref={railRef}>
{props.children}
</main>
);
};

Rail.propTypes = {
scrollSpeed: PropTypes.number,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scroll speed is optional
Don't give proptype as strictly required prop

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes i havent made it .isRequired

className: PropTypes.string,
children: PropTypes.any,
};

export default Rail;
11 changes: 6 additions & 5 deletions src/components/atoms/SearchBar/SearchBar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
color: var(--midnight-blue);
border: none;
border-radius: 0.125rem 0 0 0.125rem;
box-shadow: var(--card-shadow);
box-shadow: var(--card-shadow-subtle);
box-sizing: border-box;
outline: none;
font-size: var(--font-normal);
Expand Down Expand Up @@ -45,7 +45,7 @@
.searchBar button {
height: 2.125rem;
background: var(--theme-search);
box-shadow: 0 0 0.25rem #0003;
box-shadow: var(--card-shadow-subtle);
border-radius: 0 0.25rem 0.25rem 0;
border: none;
/* position: relative; */
Expand All @@ -69,7 +69,7 @@
}

.searchBarLong {
box-shadow: var(--card-shadow);
box-shadow: var(--card-shadow-subtle);
max-height: 3.25rem;
}
.searchBarLong:focus-within {
Expand All @@ -81,9 +81,10 @@
color: var(--midnight-blue);
border-radius: 0.125rem;
font-size: var(--font-normal);
font-family: inherit;
font-weight: normal;
width: 100%;
box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.25);
box-shadow: var(--card-shadow-subtle);
}
.searchBarLong input[type='search']:focus {
outline: solid 0.125rem var(--nexus-blue);
Expand All @@ -95,7 +96,7 @@
margin-left: 0.25rem;
border-radius: 0.125rem;
width: 2.625rem;
box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.25);
box-shadow: var(--card-shadow-subtle);
}
.searchBarLong .searchLongBtn:focus {
outline: solid 0.125rem var(--nexus-blue);
Expand Down
11 changes: 11 additions & 0 deletions src/components/atoms/SearchBar/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import SearchBar from './SearchBar';
import SearchBarLong from './SearchBarLong';

import PropTypes from 'prop-types';

SearchBar.propTypes = {
type: PropTypes.oneOf(['long']),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here also prop type and long are optional prop,

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do i do that

long: PropTypes.bool,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
onChange: PropTypes.func,
onKeyDown: PropTypes.func,
onSearch: PropTypes.func,
};

export default function Search(props) {
function handleOnKeyDown(e) {
if (e.key === 'Enter') {
Expand Down
8 changes: 8 additions & 0 deletions src/components/atoms/SmallCard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import styles from './SmallCard.module.css';
// import svgLogo from "assets/icons/icon.svg"
import pngLogo from 'assets/icons/nexusblue.png';
import Image from 'next/dist/client/image';
import PropTypes from 'prop-types';

SmallCard.propTypes = {
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
sublabel: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sublabel is optional prop

text: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
ticker: PropTypes.any,
};

export default function SmallCard(props) {
return (
Expand Down
6 changes: 6 additions & 0 deletions src/components/atoms/ThemeMode/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import lightBtn from 'assets/icons/light_mode_black_24dp.svg';
import darkBtn from 'assets/icons/dark_mode_black_24dp.svg';
import Image from 'next/image';
import { useState } from 'react';
import PropTypes from 'prop-types';

ThemeMode.propTypes = {
isDark: PropTypes.bool,
onClick: PropTypes.func,
};

export default function ThemeMode(props) {
const [toggle, setToggle] = useState(() => {
Expand Down
1 change: 1 addition & 0 deletions src/pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Layout from 'components/Layout/Layout';
import 'styles/globals.css';
import 'styles/antdCustom.css';
import { ContextWrapper } from 'contexts/AppContext';

function MyApp({ Component, pageProps }) {
Expand Down
54 changes: 51 additions & 3 deletions src/pages/blocks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,53 @@
function blocks() {
return <div>All blocks page</div>;
import { Table } from 'antd';

export default function Blocks(props) {
const { data } = props;

const columns = [
{
title: 'Block',
dataIndex: 'height',
key: 'height',
},
{
title: 'Date',
dataIndex: 'date',
key: 'date',
// render: (val) => new Date(val).toDateString,
},
{
title: 'Mint',
dataIndex: 'mint',
key: 'mint',
},
{
title: 'TXNs',
dataIndex: 'tx',
render: (tx) => tx.length,
},
{
title: 'Channel',
dataIndex: 'channel',
key: 'channel',
},
];

return (
<div>
<Table columns={columns} dataSource={data} />
</div>
);
}

export default blocks;
export async function getServerSideProps() {
const resp = await fetch(
`${process.env.NEXT_PUBLIC_NEXUS_BASE_URL}/ledger/list/blocks?limit=50`
);
const data = await resp.json();

return {
props: {
data: data.result,
},
};
}
29 changes: 27 additions & 2 deletions src/pages/richlist.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
import React from 'react';
// import Table from 'components/atoms/Table';
import { Table, Tag, Space } from 'antd';
import data from 'assets/data/richlist.json';

function richlist() {
return <h1>richlist tab</h1>;
const columns = [
{
title: 'Address',
dataIndex: 'address',
key: 'address',
},
{
title: 'Balance',
dataIndex: 'balance',
key: 'balance',
},
];
const newData = data.map((item, index) => ({
key: index,
address: item[0],
balance: `${parseInt(item[1]).toFixed(2)} NXS`,
}));

return (
<div style={{ overflow: 'scroll' }}>
{/* <pre className="themeText">{JSON.stringify(data.result, null, 2)}</pre> */}
<Table columns={columns} dataSource={newData} />
</div>
);
}

export default richlist;
Loading