UI: Tabs, full color resources, omit modals
This commit is contained in:
parent
01cc1d78ef
commit
87ac3c373b
@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { IResourceAccount, IConversionPair, IGameConfig } from "typings";
|
import { IResourceAccount, IConversionPair, IGameConfig } from "typings";
|
||||||
import { resourceToFc } from "../../../utils/helpers";
|
import { resourceToFc, resourceToBg } from "../../../utils/helpers";
|
||||||
import ResourceModal from "./ResourceModal";
|
import ResourceModal from "./ResourceModal";
|
||||||
|
|
||||||
const ResourceAccount = (props: {
|
const ResourceAccount = (props: {
|
||||||
@ -101,8 +101,14 @@ const ResourceAccount = (props: {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="flex-1 md:mb-0 mb-2 bg-gradient-to-tr from-purple-600 via-blue-600 to-indigo-700 h-auto p-1 rounded-xl">
|
<div className="flex-1 md:mb-0 mb-2 h-auto p-1 rounded-xl">
|
||||||
<div className="relative bg-slate-900 text-white px-8 py-4 rounded-xl">
|
<div
|
||||||
|
className={
|
||||||
|
"bg-gradient-to-br hover:bg-gradient-to-tr " +
|
||||||
|
resourceToBg(props.account.resourceType) +
|
||||||
|
" relative text-white px-8 py-4 rounded-xl"
|
||||||
|
}
|
||||||
|
>
|
||||||
<span
|
<span
|
||||||
className={resourceToFc(props.account.resourceType) + " font-bold"}
|
className={resourceToFc(props.account.resourceType) + " font-bold"}
|
||||||
>
|
>
|
||||||
@ -115,16 +121,21 @@ const ResourceAccount = (props: {
|
|||||||
})}{" "}
|
})}{" "}
|
||||||
kg
|
kg
|
||||||
</h3>
|
</h3>
|
||||||
|
<div className="absolute right-0 top-0 mt-4 mr-4 hover:cursor-pointer">
|
||||||
|
<div
|
||||||
|
className="flex"
|
||||||
|
onClick={() => {
|
||||||
|
setShowModal(!showModal);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span className="mr-2">Sell</span>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
fill="none"
|
fill="none"
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
strokeWidth={1.5}
|
strokeWidth={1.5}
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
className="w-6 h-6 absolute right-0 top-0 mt-4 mr-4 hover:cursor-pointer"
|
className="w-6 h-6"
|
||||||
onClick={() => {
|
|
||||||
setShowModal(!showModal);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
strokeLinecap="round"
|
strokeLinecap="round"
|
||||||
@ -134,6 +145,8 @@ const ResourceAccount = (props: {
|
|||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -23,14 +23,14 @@ const NavbarVertical: React.FC<NavbarProps> = ({
|
|||||||
return (
|
return (
|
||||||
<div className="w-full col-span-5 md:col-span-1">
|
<div className="w-full col-span-5 md:col-span-1">
|
||||||
<nav className="bg-gradient-to-tr from-purple-600 via-blue-600 to-indigo-700 h-auto p-1 rounded-xl">
|
<nav className="bg-gradient-to-tr from-purple-600 via-blue-600 to-indigo-700 h-auto p-1 rounded-xl">
|
||||||
<ul className="bg-slate-900 p-8 rounded-xl">
|
<ul className="bg-slate-900 rounded-xl p-2">
|
||||||
{menuItems.map((item) => (
|
{menuItems.map((item) => (
|
||||||
<li
|
<li
|
||||||
key={item.componentKey}
|
key={item.componentKey}
|
||||||
className={`text-white cursor-pointer mb-1 ${
|
className={`cursor-pointer mb-1 px-4 ${
|
||||||
item.componentKey === activeItem
|
item.componentKey === activeItem
|
||||||
? "text-3xl font-bold"
|
? "text-white bg-gradient-to-tr from-purple-600 via-blue-600 to-indigo-700 text-3xl font-bold rounded-xl py-2 "
|
||||||
: "text-2xl"
|
: "text-white text-2xl"
|
||||||
}`}
|
}`}
|
||||||
onClick={() => onMenuItemClick(item.componentKey)}
|
onClick={() => onMenuItemClick(item.componentKey)}
|
||||||
>
|
>
|
||||||
|
@ -119,50 +119,28 @@ const StakingSource = (props: {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex justify-center items-center">
|
<div className="flex">
|
||||||
<div className="relative group">
|
|
||||||
<Image
|
<Image
|
||||||
src={"/assets/moons/" + props.stakingSource.image}
|
src={"/assets/moons/" + props.stakingSource.image}
|
||||||
alt="Moon"
|
alt="Moon"
|
||||||
width={props.stakingSource.size}
|
width={300}
|
||||||
height={props.stakingSource.size}
|
height={300}
|
||||||
onClick={() => setShowInfo(!showInfo)}
|
style={{ objectFit: "contain" }}
|
||||||
className="hover:cursor-pointer"
|
className="mr-4"
|
||||||
/>
|
/>
|
||||||
{showInfo && (
|
<div className="max-w-md text-white bg-gradient-to-tr from-purple-600 via-blue-600 to-indigo-700 md:rounded-xl p-1">
|
||||||
<div className="z-10 fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center">
|
<div className="bg-slate-900 md:rounded-xl p-4">
|
||||||
<div className="w-full h-full md:h-auto max-w-md max-h-full overflow-y-auto">
|
<div className="">
|
||||||
<div className="relative h-full md:h-auto text-white bg-gradient-to-tr from-purple-600 via-blue-600 to-indigo-700 h-auto md:rounded-xl h-auto p-1">
|
|
||||||
<div className="h-full md:h-auto bg-slate-900 md:rounded-xl p-4">
|
|
||||||
<button
|
|
||||||
onClick={() => {
|
|
||||||
setShowInfo(!showInfo);
|
|
||||||
}}
|
|
||||||
className="text-white absolute -right-0 mr-4"
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
fill="none"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
strokeWidth={2}
|
|
||||||
stroke="currentColor"
|
|
||||||
className="w-6 h-6"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
d="M6 18L18 6M6 6l12 12"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
<h3 className="text-3xl font-bold mb-2">
|
<h3 className="text-3xl font-bold mb-2">
|
||||||
{props.stakingSource.name}
|
{props.stakingSource.name}
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-sm">{props.stakingSource.description}</p>
|
<p className="text-sm">{props.stakingSource.description}</p>
|
||||||
<div className="flex-1">
|
</div>
|
||||||
|
<div className="flex">
|
||||||
|
{activeStakes.length > 0 && (
|
||||||
|
<div className="">
|
||||||
<p className="font-bold mt-4 mb-2">Active Drills</p>
|
<p className="font-bold mt-4 mb-2">Active Drills</p>
|
||||||
{activeStakes &&
|
{activeStakes.map((stake, id) => (
|
||||||
activeStakes.map((stake, id) => (
|
|
||||||
<div
|
<div
|
||||||
key={id}
|
key={id}
|
||||||
className="border border-white rounded-xl p-3 mb-2 bg-black/20"
|
className="border border-white rounded-xl p-3 mb-2 bg-black/20"
|
||||||
@ -188,9 +166,11 @@ const StakingSource = (props: {
|
|||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
{props.inventoryItems && (
|
||||||
|
<div className="">
|
||||||
<p className="font-bold mt-4 mb-2">Inactive Drills</p>
|
<p className="font-bold mt-4 mb-2">Inactive Drills</p>
|
||||||
{props.inventoryItems &&
|
{props.inventoryItems.map(
|
||||||
props.inventoryItems.map(
|
|
||||||
(item, id) =>
|
(item, id) =>
|
||||||
!isActive(item) && (
|
!isActive(item) && (
|
||||||
<div
|
<div
|
||||||
@ -231,12 +211,11 @@ const StakingSource = (props: {
|
|||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,41 +3,6 @@ import React from "react";
|
|||||||
import { IInventoryItem, IStakingSource } from "typings";
|
import { IInventoryItem, IStakingSource } from "typings";
|
||||||
import StakingSource from "./StakingSource";
|
import StakingSource from "./StakingSource";
|
||||||
|
|
||||||
interface RowProps {
|
|
||||||
stakingSources: IStakingSource[];
|
|
||||||
inventoryItems: IInventoryItem[] | undefined | null;
|
|
||||||
claimStake: (stakingEventId: number) => void;
|
|
||||||
startStake: (
|
|
||||||
inventoryItemId: string,
|
|
||||||
storeItemId: number,
|
|
||||||
wellId: string
|
|
||||||
) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Row: React.FC<RowProps> = ({
|
|
||||||
stakingSources,
|
|
||||||
inventoryItems,
|
|
||||||
claimStake,
|
|
||||||
startStake,
|
|
||||||
}) => {
|
|
||||||
return (
|
|
||||||
<div className="md:flex md:justify-between md:items-center w-full mb-8 mt-8">
|
|
||||||
{stakingSources.map((stakingSource, index) => (
|
|
||||||
<div key={index} className="w-full">
|
|
||||||
<StakingSource
|
|
||||||
stakingSource={stakingSource}
|
|
||||||
inventoryItems={inventoryItems}
|
|
||||||
claimStake={claimStake}
|
|
||||||
startStake={startStake}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const moonSizes = [250, 375, 300, 225, 175, 300, 200, 150, 300, 225];
|
|
||||||
|
|
||||||
const StakingSourcesView = (props: {
|
const StakingSourcesView = (props: {
|
||||||
stakingSources: IStakingSource[] | null;
|
stakingSources: IStakingSource[] | null;
|
||||||
inventoryItems: IInventoryItem[] | null | undefined;
|
inventoryItems: IInventoryItem[] | null | undefined;
|
||||||
@ -49,34 +14,6 @@ const StakingSourcesView = (props: {
|
|||||||
) => void;
|
) => void;
|
||||||
createStakingSource: () => void;
|
createStakingSource: () => void;
|
||||||
}) => {
|
}) => {
|
||||||
// Generate rows of stakingSources
|
|
||||||
const handleRows = () => {
|
|
||||||
let rows = [];
|
|
||||||
let currentRow: IStakingSource[] = [];
|
|
||||||
let rowSize = 3;
|
|
||||||
if (props.stakingSources) {
|
|
||||||
props.stakingSources.forEach((stakingSource, index) => {
|
|
||||||
currentRow.push({ ...stakingSource, size: moonSizes[index] });
|
|
||||||
|
|
||||||
if (currentRow.length === rowSize) {
|
|
||||||
rows.push(currentRow);
|
|
||||||
currentRow = [];
|
|
||||||
rowSize = rowSize === 3 ? 4 : 3;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (currentRow.length) {
|
|
||||||
rows.push(currentRow);
|
|
||||||
}
|
|
||||||
|
|
||||||
return rows;
|
|
||||||
} else {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const rows = handleRows();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-gradient-to-tr from-purple-600 via-blue-600 to-indigo-700 h-auto p-1 rounded-xl h-auto p-1 rounded-xl col-span-5">
|
<div className="bg-gradient-to-tr from-purple-600 via-blue-600 to-indigo-700 h-auto p-1 rounded-xl h-auto p-1 rounded-xl col-span-5">
|
||||||
<div className="bg-slate-900 p-8 rounded-xl h-full">
|
<div className="bg-slate-900 p-8 rounded-xl h-full">
|
||||||
@ -102,21 +39,24 @@ const StakingSourcesView = (props: {
|
|||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{rows.length > 0 ? (
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-8">
|
||||||
rows.map((stakingSources, index) => (
|
{props.stakingSources ? (
|
||||||
<Row
|
props.stakingSources.map((stakingSource, index) => (
|
||||||
key={index}
|
<div key={index} className="mb-4">
|
||||||
stakingSources={stakingSources}
|
<StakingSource
|
||||||
|
stakingSource={stakingSource}
|
||||||
inventoryItems={props.inventoryItems}
|
inventoryItems={props.inventoryItems}
|
||||||
claimStake={props.claimStake}
|
claimStake={props.claimStake}
|
||||||
startStake={props.startStake}
|
startStake={props.startStake}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
<p className="text-white text-2xl">You don't have any moons</p>
|
<p className="text-white text-2xl">You don't have any moons</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user