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

feat: add land #139

Merged
merged 55 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
6fa1668
feat: add land to profile page
irisdv Aug 14, 2023
f15913f
fix: build error
irisdv Aug 14, 2023
c2f5444
fix: build error
irisdv Aug 14, 2023
cc9c085
fix: mobile version
irisdv Aug 14, 2023
8af079a
feat: update zoom on land on mobile
irisdv Aug 14, 2023
733172e
fix: reverse zoom slider
irisdv Aug 15, 2023
6cc0890
feat: add building tooltip
irisdv Aug 15, 2023
850cc67
feat: add tooltip img + add new component Map to use raycaster
irisdv Aug 15, 2023
badeae6
feat: add member since date
irisdv Aug 15, 2023
cafeca3
feat: add raycaster
irisdv Aug 15, 2023
1c2af00
feat: update constants solo nfts
irisdv Aug 29, 2023
abc3860
ref: refactor nft sorting & typing + fix raycaster
irisdv Aug 29, 2023
d57da53
fix: raycaster & update tooltip position on hover
irisdv Aug 30, 2023
354f110
fix: merge conflicts with branch testnet
irisdv Aug 30, 2023
8cde5ed
fix: build error
irisdv Aug 30, 2023
54aee7d
feat: add minitatures imgs
irisdv Aug 30, 2023
4ad3168
fix: do not show socials if theres none
irisdv Aug 30, 2023
053d8e7
fix: miniature size
irisdv Aug 30, 2023
413820e
fix: background & remove unused files
irisdv Aug 30, 2023
da780a3
fix: front details
irisdv Aug 31, 2023
9a72788
doc: add comments
irisdv Aug 31, 2023
8671d22
fix: refactor Camera
irisdv Aug 31, 2023
dca46f5
refactor: component names
irisdv Aug 31, 2023
955ba68
fix: change filenames
irisdv Aug 31, 2023
f4bd4ba
fix: renaming component files
irisdv Aug 31, 2023
991785c
fix: cleanup
irisdv Aug 31, 2023
6a10037
fix: build error
irisdv Aug 31, 2023
f7b4d7d
doc: add more comments
irisdv Sep 1, 2023
9905e03
fix: implement changes from review
irisdv Sep 1, 2023
c03f5db
fix: remove img_url in buildingsInfo type
irisdv Sep 1, 2023
60d6aa5
ref: update copy icons
irisdv Sep 1, 2023
01f2241
Merge branch 'testnet' into feat/add_land
irisdv Sep 1, 2023
cf344ef
fix: remove logs
irisdv Sep 1, 2023
b9019fe
fix: merge conflicts with branch testnet
irisdv Sep 8, 2023
f83946d
fix: typings
irisdv Sep 8, 2023
13048cc
fix: build error
irisdv Sep 8, 2023
9c43493
test: add tests for utils
irisdv Sep 8, 2023
c49127a
fix: remove logs
irisdv Sep 8, 2023
a675f9b
fix: typing
irisdv Sep 8, 2023
2e9ccf6
test: add missing test
irisdv Sep 8, 2023
e808cc5
ref: enums in tiles
irisdv Sep 8, 2023
257a84a
fix: build error
irisdv Sep 11, 2023
714eda7
feat: add footer
irisdv Sep 11, 2023
e8d1f8b
fix: build error
irisdv Sep 11, 2023
815f41a
feat: add achievement skeleton
irisdv Sep 12, 2023
08ee6ad
fix: lands
irisdv Sep 12, 2023
ae59b50
fix: bg profile
irisdv Sep 12, 2023
e6535b7
fix: footer mobile
irisdv Sep 12, 2023
2255d73
fix: bg on all profile page
irisdv Sep 12, 2023
486ffbb
ref: add bg sky on profile page
irisdv Sep 13, 2023
d4d6653
fix: remove footer on profile page
irisdv Sep 13, 2023
45f9d80
fix: starkfighter building not showing
irisdv Sep 13, 2023
1ab9307
fix: typing
irisdv Sep 14, 2023
dd905bb
fix: typing + functions as components
irisdv Sep 14, 2023
94fc33e
fix: starkfighter buildings
irisdv Sep 14, 2023
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
7 changes: 7 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
"rules": {
"no-undef": "off"
}
},
{
"files": ["components/lands/*.tsx"],
"rules": {
"react/prop-types": "off",
"react/no-unknown-property": "off"
}
}
],
"root": true
Expand Down
2 changes: 1 addition & 1 deletion components/UI/actions/clickable/clickableGithubIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const ClickableGithubIcon: FunctionComponent<ClickableGithubIconProps> = ({
<div className={styles.verifiedIcon}>
<VerifiedIcon width={"18"} color={theme.palette.primary.main} />
</div>
<GithubIcon width={width} color="white" />
<GithubIcon width={width} color="#101012" />
</div>
</Tooltip>
) : null;
Expand Down
8 changes: 4 additions & 4 deletions components/UI/actions/socialmediaActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ const SocialMediaActions: FunctionComponent<SocialMediaActionsProps> = ({
}, [identity]);

return (
<div className="flex flex-row gap-1">
<div className="flex flex-row gap-3 w-full justify-evenly">
<ClickableTwitterIcon
width="25"
width="16"
domain={identity?.domain}
twitterId={apiIdentity?.twitter ?? apiIdentity?.old_twitter}
/>
<ClickableDiscordIcon
width="25"
width="16"
domain={identity?.domain}
discordId={apiIdentity?.discord ?? apiIdentity?.old_discord}
/>
<ClickableGithubIcon
width="25"
width="16"
domain={identity?.domain}
githubId={apiIdentity?.github ?? apiIdentity?.old_github}
/>
Expand Down
24 changes: 24 additions & 0 deletions components/UI/iconsComponents/icons/copyIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React, { FunctionComponent } from "react";

const CopyIcon: FunctionComponent<IconProps> = ({ width, color }) => {
return (
<svg
width={width}
height={width}
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M16 12.9V17.1C16 20.6 14.6 22 11.1 22H6.9C3.4 22 2 20.6 2 17.1V12.9C2 9.4 3.4 8 6.9 8H11.1C14.6 8 16 9.4 16 12.9Z"
fill={color}
/>
<path
d="M17.0998 2H12.8998C9.81668 2 8.37074 3.09409 8.06951 5.73901C8.00649 6.29235 8.46476 6.75 9.02167 6.75H11.0998C15.2998 6.75 17.2498 8.7 17.2498 12.9V14.9781C17.2498 15.535 17.7074 15.9933 18.2608 15.9303C20.9057 15.629 21.9998 14.1831 21.9998 11.1V6.9C21.9998 3.4 20.5998 2 17.0998 2Z"
fill={color}
/>
</svg>
);
};

export default CopyIcon;
20 changes: 20 additions & 0 deletions components/UI/iconsComponents/icons/trophyIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React, { FunctionComponent } from "react";

const TrophyIcon: FunctionComponent<IconProps> = ({ width, color }) => {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width={width}
height={width}
viewBox="0 0 18 18"
fill="none"
>
<path
d="M5.05246 15.4284V13.9999H7.9096V11.7856C7.32627 11.6546 6.80531 11.4075 6.34674 11.0441C5.88817 10.6808 5.55198 10.2256 5.33817 9.67843C4.44531 9.57129 3.69817 9.18153 3.09674 8.50915C2.49531 7.83676 2.19484 7.04796 2.19531 6.14272V5.42843C2.19531 5.03557 2.33531 4.69915 2.61531 4.41915C2.89531 4.13915 3.2315 3.99938 3.62388 3.99986H5.05246V2.57129H12.1953V3.99986H13.6239C14.0167 3.99986 14.3532 4.13986 14.6332 4.41986C14.9132 4.69986 15.0529 5.03605 15.0525 5.42843V6.14272C15.0525 7.04748 14.7517 7.83629 14.1503 8.50915C13.5489 9.182 12.802 9.57176 11.9096 9.67843C11.6953 10.2261 11.3589 10.6815 10.9003 11.0449C10.4417 11.4082 9.92103 11.6551 9.33817 11.7856V13.9999H12.1953V15.4284H5.05246ZM5.05246 8.14272V5.42843H3.62388V6.14272C3.62388 6.5951 3.75484 7.00296 4.01674 7.36629C4.27865 7.72962 4.62388 7.98843 5.05246 8.14272ZM12.1953 8.14272C12.6239 7.98796 12.9691 7.72891 13.231 7.36557C13.4929 7.00224 13.6239 6.59462 13.6239 6.14272V5.42843H12.1953V8.14272Z"
fill={color}
/>
</svg>
);
};

export default TrophyIcon;
31 changes: 6 additions & 25 deletions components/UI/iconsComponents/icons/verifiedIcon.tsx

Large diffs are not rendered by default.

31 changes: 0 additions & 31 deletions components/UI/nftCard.tsx

This file was deleted.

88 changes: 0 additions & 88 deletions components/UI/pieChart.tsx

This file was deleted.

20 changes: 20 additions & 0 deletions components/UI/profileCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React, { FunctionComponent } from "react";
import styles from "../../styles/profile.module.css";

const ProfileCard: FunctionComponent<ProfileCard> = ({
title,
content,
isUppercase = false,
fricoben marked this conversation as resolved.
Show resolved Hide resolved
}) => {
return (
<div className={styles.profileCard}>
<h2 className={`${styles.title} ${isUppercase ? "uppercase" : ""}`}>
{title}
</h2>
<div className={styles.divider} />
{content}
</div>
);
};

export default ProfileCard;
70 changes: 70 additions & 0 deletions components/lands/buildingItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { TileRect, Tileset } from "../../types/ldtk";
import React, { ReactElement } from "react";
import { memo, useMemo } from "react";
import { PlaneGeometry, Texture } from "three";

type IElem = {
irisdv marked this conversation as resolved.
Show resolved Hide resolved
tileset: Tileset;
pos: { posX: number; posY: number };
tileData: TileRect;
textureLoader: Texture;
isNFT: boolean;
};

const BuildingItem = memo<IElem>(
({ tileset, tileData, pos, textureLoader, isNFT }): ReactElement => {
const elemTexture = useMemo(() => {
if (tileset && textureLoader) {
const localT = textureLoader.clone();
localT.needsUpdate = true;

const spritesPerRow = tileset.pxWid / tileset.tileGridSize; // 80 sprites per row : 1280/16
const spritesPerColumn = tileset.pxHei / tileset.tileGridSize; // 80 sprites per column: 1280/16
const xIndex = tileData.x / tileset.tileGridSize;
const yIndex = tileData.y / tileset.tileGridSize;
const xOffset = xIndex / spritesPerRow;
const yOffset = 1 - (yIndex + tileData.h / 16) / spritesPerColumn; // Add 1 to yIndex because the y-axis starts from the bottom, not from the top

localT.offset.set(xOffset, yOffset);
localT.repeat.set(
1 / (spritesPerRow / (tileData.w / tileset.tileGridSize)),
1 / (spritesPerColumn / (tileData.h / tileset.tileGridSize))
);
return localT;
}
}, [textureLoader, tileset, tileData]);

const plane = useMemo(() => {
return new PlaneGeometry(tileData.w / 16, tileData.h / 16, 1, 1);
}, [tileData.w, tileData.h]);

return (
<>
<mesh
position={[
pos.posX + tileData.w / 32,
0.22 + pos.posY * 0.02,
pos.posY - tileData.h / 32,
]}
name={`${tileData.tilesetUid}_building${
isNFT ? "_isNFT" : ""
}`.toString()}
rotation={[-Math.PI * 0.5, 0, 0]}
geometry={plane}
>
<meshPhongMaterial
attach="material"
map={elemTexture}
name={`${tileData.tilesetUid}_building`.toString() + "_mat"}
transparent={true}
depthWrite={false}
depthTest={true}
/>
</mesh>
</>
);
}
);

BuildingItem.displayName = "BuildingItem";
fricoben marked this conversation as resolved.
Show resolved Hide resolved
export default BuildingItem;
23 changes: 23 additions & 0 deletions components/lands/buildingTooltip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React, { FunctionComponent } from "react";
import styles from "../../styles/components/tooltip.module.css";

type BuildingTooltipProps = {
building?: BuildingsInfo | null;
irisdv marked this conversation as resolved.
Show resolved Hide resolved
pos: { x: number; y: number };
irisdv marked this conversation as resolved.
Show resolved Hide resolved
};

const BuildingTooltip: FunctionComponent<BuildingTooltipProps> = ({
building,
pos,
}) => {
if (!building) return null;
return (
<div className={styles.tooltip} style={{ left: pos.x, top: pos.y }}>
<div className={styles.level}>Level {building.level}</div>
<div className={styles.name}>{building.name}</div>
<div className={styles.description}>{building.description}</div>
</div>
);
};

export default BuildingTooltip;
63 changes: 63 additions & 0 deletions components/lands/buildings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import React, { ReactElement, useMemo } from "react";
import { TextureLoader, RepeatWrapping, NearestFilter, Vector2 } from "three";
import { BuildingTileProps } from "../../types/land";
import BuildingItem from "./buildingItem";
import { Tileset } from "../../types/ldtk";
import { useLoader } from "@react-three/fiber";

type IBuildings = {
irisdv marked this conversation as resolved.
Show resolved Hide resolved
tilesets: Tileset[];
buildingData: Array<Array<BuildingTileProps | null>>;
irisdv marked this conversation as resolved.
Show resolved Hide resolved
};

export default function Buildings({
irisdv marked this conversation as resolved.
Show resolved Hide resolved
tilesets,
buildingData,
}: IBuildings): ReactElement | null {
const buildingTexture = useMemo(() => {
const texture = useLoader(
TextureLoader,
"/land/textures/SID_BuildingSheet.png"
);
const tileset = tilesets[2];
texture.repeat = new Vector2(1 / tileset.__cHei, 1 / tileset.__cWid);
texture.magFilter = NearestFilter;
texture.wrapS = texture.wrapT = RepeatWrapping;
return texture;
}, [tilesets]);

return (
<>
{buildingTexture &&
buildingData.map(
(tileX: Array<BuildingTileProps | null>, iY: number) => {
irisdv marked this conversation as resolved.
Show resolved Hide resolved
return tileX.map(
(tileData: BuildingTileProps | null, iX: number) => {
if (
tileData === null ||
tileData.tile === undefined ||
tileData.tile === null
) {
return null;
}
return (
<BuildingItem
key={`building-${iX}-${iY}`}
tileset={
tilesets.filter(
(tileset) => tileset.uid === tileData.tile.tilesetUid
)[0]
}
textureLoader={buildingTexture}
tileData={tileData.tile}
pos={{ posX: iX, posY: iY }}
isNFT={tileData.isNFT}
/>
);
}
);
}
)}
</>
);
}
Loading