diff --git a/packages/ui/src/lib/components/header-description.svelte b/packages/ui/src/lib/components/header-description.svelte deleted file mode 100644 index 59d1f56..0000000 --- a/packages/ui/src/lib/components/header-description.svelte +++ /dev/null @@ -1,42 +0,0 @@ - - -
-
Public timeline
-
- - diff --git a/packages/ui/src/lib/components/header-top.svelte b/packages/ui/src/lib/components/header-top.svelte index 96a1f3a..921cad7 100644 --- a/packages/ui/src/lib/components/header-top.svelte +++ b/packages/ui/src/lib/components/header-top.svelte @@ -1,21 +1,28 @@ @@ -25,26 +32,25 @@
-
-
- 0 ? 'subtitle' : 'header-title'} ${cls}`}> - {y > 0 ? 'Public Timeline' : 'The Outlet'} - + Kurate
-
+ {#if address}
- -
-
+ {:else} +
@@ -122,13 +128,7 @@ flex-direction: row; align-items: center; gap: var(--spacing-12); - margin-left: -56px; transition: margin 0.2s ease-in-out; - - .top-button { - opacity: 0; - transition: opacity 0.2s ease-in-out; - } } &.scrolled { diff --git a/packages/ui/src/lib/components/header.svelte b/packages/ui/src/lib/components/header.svelte deleted file mode 100644 index 066d2f9..0000000 --- a/packages/ui/src/lib/components/header.svelte +++ /dev/null @@ -1,228 +0,0 @@ - - - - -
0 ? 'scrolled' : ''} ${cls}`}> -
-
-
-
-
- 0 ? 'subtitle' : 'header-title'} ${cls}`}> - {y > 0 ? 'Public Timeline' : 'The Outlet'} - -
- -
-
-
- -
-
-
-
- {#if y === 0} -
- Milestone 1 shaman pitchfork typewriter single-origin coffee beard flannel, actually - chillwave. -
-
0 ? 'hide' : ''} ${cls}`}>Public timeline
- {/if} -
-
- - diff --git a/packages/ui/src/lib/components/icons/add.svelte b/packages/ui/src/lib/components/icons/add.svelte new file mode 100644 index 0000000..476322d --- /dev/null +++ b/packages/ui/src/lib/components/icons/add.svelte @@ -0,0 +1,13 @@ + + + + + diff --git a/packages/ui/src/lib/components/icons/search.svelte b/packages/ui/src/lib/components/icons/search.svelte new file mode 100644 index 0000000..135368f --- /dev/null +++ b/packages/ui/src/lib/components/icons/search.svelte @@ -0,0 +1,15 @@ + + + + + diff --git a/packages/ui/src/lib/components/icons/send-alt-filled copy.svelte b/packages/ui/src/lib/components/icons/send-alt-filled copy.svelte new file mode 100644 index 0000000..2a911e9 --- /dev/null +++ b/packages/ui/src/lib/components/icons/send-alt-filled copy.svelte @@ -0,0 +1,15 @@ + + + + + diff --git a/packages/ui/src/lib/components/icons/settings-view.svelte b/packages/ui/src/lib/components/icons/settings-view.svelte new file mode 100644 index 0000000..7733270 --- /dev/null +++ b/packages/ui/src/lib/components/icons/settings-view.svelte @@ -0,0 +1,20 @@ + + + + + + + + diff --git a/packages/ui/src/lib/components/icons/user-multiple.svelte b/packages/ui/src/lib/components/icons/user-multiple.svelte new file mode 100644 index 0000000..9b11ff8 --- /dev/null +++ b/packages/ui/src/lib/components/icons/user-multiple.svelte @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/packages/ui/src/lib/components/persona.svelte b/packages/ui/src/lib/components/persona.svelte new file mode 100644 index 0000000..b2346b8 --- /dev/null +++ b/packages/ui/src/lib/components/persona.svelte @@ -0,0 +1,57 @@ + + + +
+
persona
+
+
{name}
+
{description}
+
{postsCount}
+
+
+ + diff --git a/packages/ui/src/lib/components/wallet-connect.svelte b/packages/ui/src/lib/components/wallet-connect.svelte deleted file mode 100644 index 22db7c6..0000000 --- a/packages/ui/src/lib/components/wallet-connect.svelte +++ /dev/null @@ -1,59 +0,0 @@ - - - -
0 ? 'scrolled' : ''} ${cls}`}> -
- - diff --git a/packages/ui/src/lib/routes.ts b/packages/ui/src/lib/routes.ts index 3fa052d..8b8d84f 100644 --- a/packages/ui/src/lib/routes.ts +++ b/packages/ui/src/lib/routes.ts @@ -1,5 +1,7 @@ export const ROUTES = { HOME: '/', PROFILE: '/profile', - POST_NEW: '/post/new', + PERSONA: (slug: string) => `/persona/${slug}`, + PERSONA_NEW: '/persona/new', + POST_NEW: (slug: string) => `/persona/${slug}/post/new`, } diff --git a/packages/ui/src/lib/stores/chat.ts b/packages/ui/src/lib/stores/chat.ts new file mode 100644 index 0000000..5ac7bd4 --- /dev/null +++ b/packages/ui/src/lib/stores/chat.ts @@ -0,0 +1,15 @@ +import { writable, type Writable } from 'svelte/store' + +interface ChatData { + unread: number +} + +export type ChatStore = Writable + +function createChatStore(): ChatStore { + const store = writable({ unread: 3 }) + + return store +} + +export const chats = createChatStore() diff --git a/packages/ui/src/lib/stores/persona.ts b/packages/ui/src/lib/stores/persona.ts new file mode 100644 index 0000000..feaf415 --- /dev/null +++ b/packages/ui/src/lib/stores/persona.ts @@ -0,0 +1,86 @@ +import { writable, type Writable } from 'svelte/store' +import type { Identity } from '@semaphore-protocol/identity' + +interface Persona { + identity?: Identity + picture?: string + name: string + pitch: string + description: string + postsCount: number +} + +export type PersonaStore = Writable<{ + draft: Persona[] + favorite: Map + all: Map + loading: boolean +}> + +function createPersonaStore(): PersonaStore { + const store = writable({ all: new Map(), draft: [], favorite: new Map(), loading: true }) + + setTimeout(() => { + const chitChat = { + identity: undefined, + name: 'Chit Chat', + pitch: 'We pretty much just say gm all the time.', + description: 'We pretty much just say gm all the time.', + postsCount: 125, + picture: + 'https://upload.wikimedia.org/wikipedia/commons/4/42/Chit_chat_%28256889331%29.jpg?20191121211426', + } + const expats = { + identity: undefined, + name: 'Expats', + pitch: 'Different countries, same work...', + description: 'Different countries, same work...', + postsCount: 4, + picture: 'https://upload.wikimedia.org/wikipedia/commons/8/88/British_expats_countrymap.svg', + } + const cats = { + identity: undefined, + name: 'Cats', + pitch: "Yeah it's the internet, what did you expect?", + description: "Yeah it's the internet, what did you expect?", + postsCount: 5128, + picture: + 'https://upload.wikimedia.org/wikipedia/commons/thumb/3/38/Adorable-animal-cat-20787.jpg/1599px-Adorable-animal-cat-20787.jpg?20180518085718', + } + const geoPolitics = { + identity: undefined, + name: 'Geo Politics', + pitch: `Group full of "seen it all's"`, + description: `Group full of "seen it all's"`, + postsCount: 53, + picture: + 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/f9/World_geopolitical_chess.png/1600px-World_geopolitical_chess.png?20200226194321', + } + const controversy = { + identity: undefined, + name: 'Controversy', + pitch: '...', + description: '...', + postsCount: 9999, + picture: + 'https://upload.wikimedia.org/wikipedia/en/e/ea/Controversy_legend.gif?20060220215816', + } + + const all = new Map() + const favorite = new Map() + all.set('1', chitChat) + all.set('2', expats) + all.set('3', cats) + all.set('4', geoPolitics) + all.set('5', controversy) + + favorite.set('3', cats) + favorite.set('4', controversy) + + store.set({ draft: [], all, favorite, loading: false }) + }, 1000) + + return store +} + +export const personas = createPersonaStore() diff --git a/packages/ui/src/lib/stores/post.ts b/packages/ui/src/lib/stores/post.ts index 7a27136..c342130 100644 --- a/packages/ui/src/lib/stores/post.ts +++ b/packages/ui/src/lib/stores/post.ts @@ -5,7 +5,6 @@ import { subscribeToPosts } from '$lib/services/posts' export interface Post { timestamp: number text: string - tx: string } interface PostData { @@ -29,7 +28,6 @@ async function fetchPosts() { posts.add({ text: post.text, timestamp: Date.now(), - tx: '', }) }, undefined, diff --git a/packages/ui/src/lib/stores/profile.ts b/packages/ui/src/lib/stores/profile.ts index 886d347..a0e2c55 100644 --- a/packages/ui/src/lib/stores/profile.ts +++ b/packages/ui/src/lib/stores/profile.ts @@ -1,16 +1,15 @@ import { writable, type Writable } from 'svelte/store' import type { Signer } from 'ethers' -import type { Identity } from '@semaphore-protocol/identity' export interface Profile { signer?: Signer - identities: Record + address?: string } export type ProfileStore = Writable function createProfileStore(): ProfileStore { - return writable({ identities: {} }) + return writable({}) } export const profile = createProfileStore() diff --git a/packages/ui/src/routes/+page.svelte b/packages/ui/src/routes/+page.svelte index 8911476..c03a89e 100644 --- a/packages/ui/src/routes/+page.svelte +++ b/packages/ui/src/routes/+page.svelte @@ -1,115 +1,104 @@ - -
- - - - +
{#if $profile.signer !== undefined} -
goto('/post/new')}> - Share freely... -
diff --git a/packages/ui/src/routes/persona/[id]/+page.svelte b/packages/ui/src/routes/persona/[id]/+page.svelte new file mode 100644 index 0000000..ba8a452 --- /dev/null +++ b/packages/ui/src/routes/persona/[id]/+page.svelte @@ -0,0 +1,98 @@ + + + + +
+ + +
+ {/if} + + {#if $posts.loading} +

Loading posts...

+ {:else if $posts.posts.length == 0} +

There are no posts yet

+ {:else} + + {#each $posts.posts as post} + + {/each} + + {/if} +
+ + + diff --git a/packages/ui/src/routes/post/new/+page.svelte b/packages/ui/src/routes/persona/[id]/post/new/+page.svelte similarity index 87% rename from packages/ui/src/routes/post/new/+page.svelte rename to packages/ui/src/routes/persona/[id]/post/new/+page.svelte index fd1bd4d..f5611bf 100644 --- a/packages/ui/src/routes/post/new/+page.svelte +++ b/packages/ui/src/routes/persona/[id]/post/new/+page.svelte @@ -7,10 +7,13 @@ import { goto } from '$app/navigation' import { ROUTES } from '$lib/routes' import { + createIdentity, generateGroupProof, getContractGroup, getGlobalAnonymousFeed, getRandomExternalNullifier, + joinGroupOffChain, + joinGroupOnChain, } from '$lib/services/index' import { posts } from '$lib/stores/post' import { hashPost, createPost } from '$lib/services/posts' @@ -27,12 +30,21 @@ const signer = $profile.signer if (!signer) throw new Error('no signer') - const identity = $profile.identities.anonymous - if (!identity) throw new Error('no identity') + const defaultIdentity = 'anonymous' + + const identity = await createIdentity(signer, defaultIdentity) const globalAnonymousFeed = getGlobalAnonymousFeed(signer) const group = await getContractGroup(globalAnonymousFeed) + const commitment = identity.commitment + + if (!group.members.includes(commitment)) { + joinGroupOffChain(group, commitment) + const txres = await joinGroupOnChain(globalAnonymousFeed, commitment) + console.log(txres) + } + const post = { text: postText } const signal = hashPost(post) @@ -45,7 +57,6 @@ posts.add({ timestamp: Date.now(), text: postText, - tx: '', }) goto(ROUTES.HOME) } catch (error) { diff --git a/packages/ui/src/routes/persona/new/+page.svelte b/packages/ui/src/routes/persona/new/+page.svelte new file mode 100644 index 0000000..70940b3 --- /dev/null +++ b/packages/ui/src/routes/persona/new/+page.svelte @@ -0,0 +1,35 @@ + + +