initial global feed

This commit is contained in:
smolgrrr 2023-09-02 17:24:30 +10:00
parent 7889c2fc05
commit 78e6a0350c
12 changed files with 564 additions and 2055 deletions

2491
client/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -10,10 +10,11 @@
"@types/node": "^17.0.45",
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"nostr-tools": "^1.14.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.15.0",
"react-scripts": "5.0.1",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4",
"workbox-background-sync": "^6.6.0",
"workbox-broadcast-update": "^6.6.0",
@ -51,5 +52,8 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"typescript": "^5.2.2"
}
}

BIN
client/public/192_tao.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
client/public/512_tao.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -21,7 +21,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>TAO</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>

View File

@ -1,6 +1,6 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"short_name": "TAO",
"name": "The Anon Operation",
"icons": [
{
"src": "favicon.ico",
@ -8,12 +8,12 @@
"type": "image/x-icon"
},
{
"src": "logo192.png",
"src": "192_tao.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"src": "512_tao.png",
"type": "image/png",
"sizes": "512x512"
}

View File

@ -1,25 +1,18 @@
import React from 'react';
import logo from './logo.svg';
import './App.css';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import Home from './components/Home';
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
<Router>
<div>
<Routes>
<Route path="/" element={<Home />} />
</Routes>
</div>
</Router>
);
}

View File

@ -0,0 +1,52 @@
import React, { useEffect, useState } from 'react';
import { relayInit } from 'nostr-tools';
import PostCard from './PostCard/PostCard';
// Define the Event interface
interface Event {
id: string;
content: string;
created_at: number;
// Add other fields if necessary
}
const relay = relayInit('wss://powrelay.xyz');
const Home = () => {
// Define the type of the state variable
const [events, setEvents] = useState<Event[]>([]);
useEffect(() => {
relay.on('connect', async () => {
console.log(`connected to ${relay.url}`);
const eventList = await relay.list([
{
kinds: [1],
limit: 10,
},
]);
// Assuming eventList is of type Event[]
setEvents(eventList);
});
relay.on('error', () => {
console.log(`failed to connect to ${relay.url}`);
});
relay.connect();
}, []);
return (
<div className="bg-gray-900 text-white min-h-screen">
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 p-4">
{events.map((event, index) => (
<PostCard key={index} content={event.content} />
))}
</div>
</div>
);
};
export default Home;

View File

@ -0,0 +1,9 @@
import { PropsWithChildren } from 'react';
export default function CardContainer({ children }: PropsWithChildren) {
return (
<div className="card bg-gradient-to-r from-base-200 to-base-100 shadow-lg shadow-black">
<div className="card-body gap-4 p-4">{children}</div>
</div>
);
}

View File

@ -0,0 +1,19 @@
import CardContainer from './CardContainer';
const PostCard = ({ content }: { content: string }) => {
return (
<>
<CardContainer>
<div className="flex flex-col gap-4">
<div className="ml-16 mr-2 flex flex-col gap-4 break-words">
{content}
</div>
</div>
<hr className="-mx-4 mt-2 opacity-10" />
</CardContainer>
</>
);
};
export default PostCard;

View File

@ -0,0 +1,9 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
}