Skip to content

Commit

Permalink
XPower UI: {home=>mine}
Browse files Browse the repository at this point in the history
  • Loading branch information
Kârūn The Rich committed May 23, 2024
1 parent feeec89 commit c878342
Show file tree
Hide file tree
Showing 30 changed files with 71 additions and 71 deletions.
File renamed without changes
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/* eslint @typescript-eslint/no-explicit-any: [off] */
import { env_of_home } from './env-of-home';
import { env_of_mine } from './env-of-mine';

describe('env_of_home', () => {
describe('env_of_mine', () => {
it('should return amounts_for request', () => {
const req = {
headers: { 'x-forwarded-host': 'localhost:3000' },
protocol: 'http'
};
expect(env_of_home(req as any)).toEqual({
expect(env_of_mine(req as any)).toEqual({
...{
HEADER_ABOUT: '',
HEADER_HOME: '',
HEADER_MINE: '',
HEADER_NFTS: '',
HEADER_PPTS: '',
HEADER_SWAP: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Tokenizer } from '../../source/token';
import { Request } from 'express';
import { env_of } from './env-of';

export const env_of_home = (req: Request): Record<string, any> => {
export const env_of_mine = (req: Request): Record<string, any> => {
const params = new URLSearchParams(req.query as any);
return {
...env_of(req),
Expand Down Expand Up @@ -41,4 +41,4 @@ const mining_speed = (
const speed = Parser.number(params.get('speed'), fallback);
return { UI_MINING_SPEED: speed };
};
export default env_of_home;
export default env_of_mine;
2 changes: 1 addition & 1 deletion routes/functions/env-of.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('env_of', () => {
expect(env_of(req as any)).toEqual({
...{
HEADER_ABOUT: '',
HEADER_HOME: '',
HEADER_MINE: '',
HEADER_NFTS: '',
HEADER_PPTS: '',
HEADER_SWAP: '',
Expand Down
8 changes: 4 additions & 4 deletions routes/functions/env-of.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ const cover_image = (
) => {
const page = Pager.parse(req.path);
switch (page) {
case Page.Home:
case Page.Mine:
return {
COVER_IMAGE: '/images/all/cover-home.a4960415.jpg',
COVER_IMAGE: '/images/all/cover-mine.a4960415.jpg',
};
case Page.Nfts:
return {
Expand Down Expand Up @@ -83,8 +83,8 @@ const header_page = (
) => {
const page = Pager.parse(req.path);
return {
HEADER_HOME:
page === Page.Home ? 'active' : '',
HEADER_MINE:
page === Page.Mine ? 'active' : '',
HEADER_NFTS:
page === Page.Nfts ? 'active' : '',
HEADER_PPTS:
Expand Down
2 changes: 1 addition & 1 deletion routes/functions/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './capitalize';
export * from './env-of-home';
export * from './env-of-mine';
export * from './env-of';
export * from './host';
export * from './urlify';
10 changes: 5 additions & 5 deletions routes/spa.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ describe('GET /', () => {
describe('GET /*/manifest.json', () => {
let get: request.Test;
beforeEach(() => {
get = request(app).get('/home/manifest.json');
get = request(app).get('/mine/manifest.json');
});
it('should return w/an HTTP code = 302 Found', async () => {
await get.expect(302);
});
});
describe('GET /home', () => {
describe('GET /mine', () => {
let get: request.Test;
beforeEach(() => {
get = request(app).get('/home');
get = request(app).get('/mine');
});
it('should return w/an HTTP code = 200 OK', async () => {
await get.expect(200);
Expand Down Expand Up @@ -55,10 +55,10 @@ describe('GET /nfts', () => {
});
});
});
describe('GET /staking', () => {
describe('GET /stake', () => {
let get: request.Test;
beforeEach(() => {
get = request(app).get('/staking');
get = request(app).get('/stake');
});
it('should return w/an HTTP code = 200 OK', async () => {
await get.expect(200);
Expand Down
16 changes: 8 additions & 8 deletions routes/spa.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { env_of_home } from './functions';
import { env_of_mine } from './functions';
import { env_of } from './functions';
import { Router } from 'express';
const router = Router();
Expand All @@ -15,13 +15,13 @@ function routes(
});
/** REDIRECT to home page. */
router.get('/', (req, res) => {
res.redirect('/home');
res.redirect('/mine');
});
/** GET home page. */
router.get('/home', (req, res) => {
res.render('home/home.pig', {
/** GET mine page. */
router.get('/mine', (req, res) => {
res.render('mine/mine.pig', {
DESCRIPTION: 'Mine & Mint Proof-of-Work XPower Tokens',
TITLE: 'XPower', ...env_of_home(req), ...spa_env,
TITLE: 'XPower', ...env_of_mine(req), ...spa_env,
});
});
/** GET nfts page. */
Expand All @@ -31,8 +31,8 @@ function routes(
TITLE: 'XPower: NFTs', ...env_of(req), ...spa_env
});
});
/** GET staking page. */
router.get('/staking', (req, res) => {
/** GET ppts page. */
router.get('/stake', (req, res) => {
res.render('ppts/ppts.pig', {
DESCRIPTION: 'Stake minted XPower NFTs',
TITLE: 'XPower: Staking', ...env_of(req), ...spa_env
Expand Down
10 changes: 5 additions & 5 deletions source/redux/reducers/page-reducer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { switchPage } from '../actions';
import { Page } from '../types';

describe('Store w/page-reducer', () => {
it('should switch to home page', () => {
const state_0 = Page.Home;
const state_1 = pageReducer(state_0, switchPage(Page.Home));
expect(state_1).toEqual(Page.Home);
it('should switch to mine page', () => {
const state_0 = Page.Mine;
const state_1 = pageReducer(state_0, switchPage(Page.Mine));
expect(state_1).toEqual(Page.Mine);
});
it('should switch to nfts page', () => {
const state_0 = Page.Home;
const state_0 = Page.Mine;
const state_1 = pageReducer(state_0, switchPage(Page.Nfts));
expect(state_1).toEqual(Page.Nfts);
});
Expand Down
10 changes: 5 additions & 5 deletions source/redux/types/page.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export enum Page {
None = 'none',
Home = 'home',
Mine = 'mine',
Nfts = 'nfts',
Ppts = 'staking',
Ppts = 'stake',
Swap = 'swap',
About = 'about',
}
Expand All @@ -22,11 +22,11 @@ export class Pager {
const suffix = path.length
? path[path.length - 1] : '';
switch (suffix.toLowerCase()) {
case 'home':
return Page.Home;
case 'mine':
return Page.Mine;
case 'nfts':
return Page.Nfts;
case 'staking':
case 'stake':
return Page.Ppts;
case 'swap':
return Page.Swap;
Expand Down
4 changes: 2 additions & 2 deletions source/services/location-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const LocationService = (
onPageSwitch(store, function syncLocationTitle(page) {
const titles: Record<Page, string> = {
[Page.None]: 'XPower',
[Page.Home]: 'XPower',
[Page.Mine]: 'XPower',
[Page.Nfts]: 'XPower: NFTs',
[Page.Ppts]: 'XPower: Staking',
[Page.Swap]: 'XPower: Swap',
Expand All @@ -35,7 +35,7 @@ export const LocationService = (
);
const descriptions: Record<Page, string> = {
[Page.None]: 'Mine & Mint Proof-of-Work XPower Tokens',
[Page.Home]: 'Mine & Mint Proof-of-Work XPower Tokens',
[Page.Mine]: 'Mine & Mint Proof-of-Work XPower Tokens',
[Page.Nfts]: 'Mint stakeable XPower NFTs',
[Page.Ppts]: 'Stake minted XPower NFTs',
[Page.Swap]: 'Swap XPOW & APOW Tokens',
Expand Down
8 changes: 4 additions & 4 deletions views/cover/cover-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import './cover-image.scss';
import React from 'react';
import { Page } from '../../source/redux/types';

import Home from '../../public/images/jpg/cover-home.jpg';
import Mine from '../../public/images/jpg/cover-mine.jpg';
import Nfts from '../../public/images/jpg/cover-nfts.jpg';
import Ppts from '../../public/images/jpg/cover-ppts.jpg';

Expand All @@ -29,8 +29,8 @@ function source(
page: Page
) {
switch (page) {
case Page.Home:
return Home;
case Page.Mine:
return Mine;
case Page.Nfts:
return Nfts;
case Page.Ppts:
Expand All @@ -42,7 +42,7 @@ function opacity(
page: Page
) {
switch (page) {
case Page.Home:
case Page.Mine:
return 1.0;
case Page.Nfts:
return 0.5;
Expand Down
2 changes: 1 addition & 1 deletion views/cover/cover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function UiCover(
{ controls, page, options, data }: Props
) {
switch (page) {
case Page.Home:
case Page.Mine:
return <div id='cover'>
<UiCoverImage
page={page}
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions views/header/header.pug
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
header
nav#menu.btn-group.nav.nav-pills.nav-justified.mb-3
a.btn.btn-outline-warning.flex-sm-fill.text-sm-center.nav-link.home(
class="{{HEADER_HOME}}" href="/home?token={{TOKEN}}"
a.btn.btn-outline-warning.flex-sm-fill.text-sm-center.nav-link.mine(
class="{{HEADER_MINE}}" href="/mine?token={{TOKEN}}"
)
i.bi-lightning-charge-fill.float-sm-start
span.d-none.d-sm-inline.text: | XPower
span.d-none.d-sm-inline.text: | Mine
a.btn.btn-outline-warning.flex-sm-fill.text-sm-center.nav-link.nfts(
class="{{HEADER_NFTS}}" href="/nfts?token={{TOKEN}}"
)
i.bi-image-fill.float-sm-start
span.d-none.d-sm-inline.text: | NFTs
a.btn.btn-outline-warning.flex-sm-fill.text-sm-center.nav-link.staking(
class="{{HEADER_PPTS}}" href="/staking?token={{TOKEN}}"
class="{{HEADER_PPTS}}" href="/stake?token={{TOKEN}}"
)
i.bi-cash-stack.float-sm-start
span.d-none.d-sm-inline.text: | Staking
span.d-none.d-sm-inline.text: | Stake
a.btn.btn-outline-warning.flex-sm-fill.text-sm-center.nav-link.swap(
class="{{HEADER_SWAP}}" href="/swao?token={{TOKEN}}"
class="{{HEADER_SWAP}}" href="/swap?token={{TOKEN}}"
)
i.bi-currency-exchange.float-sm-start
span.d-none.d-sm-inline.text: | Swap
Expand Down
8 changes: 4 additions & 4 deletions views/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function UiHeader(
<nav id='menu' className={
classes.join(' ')
}>
{$anchor(Page.Home, props)}
{$anchor(Page.Mine, props)}
{$anchor(Page.Nfts, props)}
{$anchor(Page.Ppts, props)}
{$anchor(Page.Swap, props)}
Expand Down Expand Up @@ -77,17 +77,17 @@ function $label(
</span>;
}
const icons: Record<Page, string> = {
[Page.Home]: 'bi-lightning-charge-fill',
[Page.Mine]: 'bi-lightning-charge-fill',
[Page.Nfts]: 'bi-image-fill',
[Page.Ppts]: 'bi-cash-stack',
[Page.Swap]: 'bi-currency-exchange',
[Page.About]: 'bi-lightbulb-fill',
[Page.None]: '',
}
const labels: Record<Page, string> = {
[Page.Home]: 'XPower',
[Page.Mine]: 'Mine',
[Page.Nfts]: 'NFTs',
[Page.Ppts]: 'Staking',
[Page.Ppts]: 'Stake',
[Page.Swap]: 'Swap',
[Page.About]: 'About',
[Page.None]: '',
Expand Down
4 changes: 2 additions & 2 deletions views/home/home.pug → views/mine/mine.pug
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ block content
include ../connector/connector.pug
include ../cover/cover.pug
include ../wallet/wallet.pug
include ../home/mining/mining.pug
include ../home/minting/minting.pug
include ./mining/mining.pug
include ./minting/minting.pug
File renamed without changes.
10 changes: 5 additions & 5 deletions views/home/home.tsx → views/mine/mine.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import './home.scss';
import './mine.scss';

import { Level, Mining, Minting } from '../../source/redux/types';

Expand All @@ -24,13 +24,13 @@ type Props = {
};
speed: number;
}
export function UiHome(
export function UiMine(
props: Props
) {
const { status, togglable } = props.mining;
const { speed, speedable } = props.mining;
const { rows } = props.minting;
return <React.Fragment>
return <>
<div id='mining'>
<UiMining
onToggle={props.mining.onToggle}
Expand All @@ -47,6 +47,6 @@ export function UiHome(
level={ROParams.level.min} rows={rows}
/>
</div>
</React.Fragment>;
</>;
}
export default UiHome;
export default UiMine;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion views/spa/spa.pug
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ block styles

block globals
include ../global/contracts.pug
include ../global/home.pug
include ../global/mine.pug
include ../global/urls.pug

block header
Expand Down
Loading

0 comments on commit c878342

Please sign in to comment.