Skip to content

Commit

Permalink
Merge pull request #1 from iskysun96/gallery
Browse files Browse the repository at this point in the history
Navbar & Gallery
  • Loading branch information
sunwavesun authored Jan 14, 2024
2 parents 74fff01 + 5082ae4 commit faa170a
Show file tree
Hide file tree
Showing 7 changed files with 268 additions and 17 deletions.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AlgoKit React Template</title>
<title>Blockchain Photo Diary</title>
</head>
<body>
<div id="root"></div>
Expand Down
124 changes: 124 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,32 @@
"@types/node": "18.17.14",
"@types/react": "18.2.11",
"@types/react-dom": "18.2.4",
"@typescript-eslint/eslint-plugin": "6.5.0",
"@typescript-eslint/parser": "6.5.0",
"@vitejs/plugin-react-swc": "3.3.2",
"autoprefixer": "10.4.14",
"eslint": "8.42.0",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-prettier": "5.0.0",
"@typescript-eslint/eslint-plugin": "6.5.0",
"@typescript-eslint/parser": "6.5.0",
"postcss": "^8.4.24",
"tailwindcss": "3.3.2",
"ts-node": "10.9.1",
"typescript": "5.1.6",
"vite": "4.4.9"
},
"dependencies": {
"@walletconnect/modal-sign-html": "^2.6.1",
"@algorandfoundation/algokit-utils": "^4.1.0",
"@blockshake/defly-connect": "^1.1.6",
"@daffiwallet/connect": "^1.0.3",
"@perawallet/connect": "^1.3.1",
"@txnlab/use-wallet": "^2.1.1",
"@walletconnect/modal-sign-html": "^2.6.1",
"algosdk": "^2.5.0",
"daisyui": "^3.1.0",
"notistack": "^3.0.1",
"react": "^18.2.0",
"react-dom": "18.2.0",
"styled-components": "^6.1.8",
"tslib": "^2.6.2"
},
"scripts": {
Expand Down
12 changes: 6 additions & 6 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { SnackbarProvider } from 'notistack'
import { useState } from 'react'
import Gallery from './components/Gallery'
import Hero from './components/Hero'
import { Navbar } from './components/Navbar'
import { getAlgodConfigFromViteEnvironment, getKmdConfigFromViteEnvironment } from './utils/network/getAlgoClientConfigs'

let providersArray: ProvidersArray
Expand Down Expand Up @@ -38,6 +39,8 @@ if (import.meta.env.VITE_ALGOD_NETWORK === '') {
export default function App() {
const [openWalletModal, setOpenWalletModal] = useState<boolean>(false)
const [openDemoModal, setOpenDemoModal] = useState<boolean>(false)
const [activeTab, setActiveTab] = useState(0) // 0 = Mint; 1 = Gallery

const { activeAddress } = useWallet()

Check warning on line 44 in src/App.tsx

View workflow job for this annotation

GitHub Actions / checks

'activeAddress' is assigned a value but never used

Check warning on line 44 in src/App.tsx

View workflow job for this annotation

GitHub Actions / CI dApp / checks

'activeAddress' is assigned a value but never used

const toggleWalletModal = () => {

Check warning on line 46 in src/App.tsx

View workflow job for this annotation

GitHub Actions / checks

'toggleWalletModal' is assigned a value but never used

Check warning on line 46 in src/App.tsx

View workflow job for this annotation

GitHub Actions / CI dApp / checks

'toggleWalletModal' is assigned a value but never used
Expand All @@ -64,13 +67,10 @@ export default function App() {
return (
<SnackbarProvider maxSnack={3}>
<WalletProvider value={walletProviders}>
<Navbar activeTab={activeTab} setActiveTab={setActiveTab} />
<div className="flex justify-center items-center flex-col">
<Hero />
{activeAddress && (
<div>
<Gallery />
</div>
)}
{activeTab === 0 && <Hero />}
{activeTab === 1 && <Gallery />}
</div>
</WalletProvider>
</SnackbarProvider>
Expand Down
60 changes: 55 additions & 5 deletions src/components/Gallery.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,62 @@
/*
Gallery Component
TODO
- query all nfts with unitName that starts with "dia" from the connected account
- display the nfts in a grid with Create Date showing at the bottom of the image
*/

import { Asset, useWallet } from '@txnlab/use-wallet'
import { useEffect } from 'react'

const DIA = 'dia'

const Gallery = () => {
return <div>Gallery</div>
const wallet = useWallet()

// TODO: placeholder
const fetchContent = () => {
return [
{
imageUrl:
'https://upload.wikimedia.org/wikipedia/commons/thumb/0/0a/The_Great_Wave_off_Kanagawa.jpg/1280px-The_Great_Wave_off_Kanagawa.jpg',
date: 'happy 2024-01-13',
},
]
}
const galleryContents = fetchContent()

let diaAssets: Asset[] = []

Check warning on line 25 in src/components/Gallery.tsx

View workflow job for this annotation

GitHub Actions / checks

'diaAssets' is assigned a value but never used

Check warning on line 25 in src/components/Gallery.tsx

View workflow job for this annotation

GitHub Actions / CI dApp / checks

'diaAssets' is assigned a value but never used
useEffect(() => {
const fetchData = async () => {
if (wallet && wallet.activeAddress) {
try {
const assets = await wallet.getAssets()
diaAssets = assets.filter((asset) => asset['unit-name'].startsWith(DIA))
} catch (error) {
console.error('Error fetching assets:', error)

Check warning on line 33 in src/components/Gallery.tsx

View workflow job for this annotation

GitHub Actions / checks

Unexpected console statement

Check warning on line 33 in src/components/Gallery.tsx

View workflow job for this annotation

GitHub Actions / CI dApp / checks

Unexpected console statement
}
}
}

fetchData()
}, [wallet])

return (
wallet.activeAddress && (
<div className="grid grid-cols-4 gap-4 mt-8">
{galleryContents.map((item, index) => (
<div key={index} className="bg-white p-2 rounded-lg" style={{ border: '2px solid #b2d8d8' }}>
<img src={item.imageUrl} className="w-full h-48 object-cover rounded-lg" />
<p className="text-center text-sm mt-2">{item.date}</p>
</div>
))}
{/* {diaAssets.map((item, index) => (
<div key={index} className="bg-white p-2 rounded-lg" style={{ border: '2px solid #b2d8d8' }}>
<img src={// TODO: get image url from IPFS} className="w-full h-48 object-cover rounded-lg" />
<p className="text-center text-sm mt-2">{item.name}</p>
//{' '}
</div>
))} */}
</div>
)
)
}

export default Gallery
2 changes: 1 addition & 1 deletion src/components/MintNft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Wallet Connect
Minting
- Create drag and drop component for uploading images
- Create input field for NFT name (one word to describe my emotion of the day)
- create button to mint NFT
- Create button to mint NFT
- Integrate with Pinata to upload image to IPFS
- Minting should:
= upload image to IPFS
Expand Down
Loading

0 comments on commit faa170a

Please sign in to comment.