1- import IFramely from '@/islands/Iframely.tsx' ;
1+ import Button from '@/islands/Button.tsx' ;
2+ import Iframely from '@/islands/Iframely.tsx' ;
23import type { FeedList , FeedListItem } from '@/shared/api.ts' ;
34import axios from 'axios-web' ;
45import { useCallback , useEffect , useRef , useState } from 'preact/hooks' ;
@@ -103,43 +104,30 @@ export default function ListView(props: {
103104 ) ;
104105
105106 return (
106- < div class = 'w-full' >
107- < div class = 'flex flex-col pb-4 gap-4' >
108- < div class = 'flex flex-row items-center gap-2' >
109- < div
110- class = { `inline-block h-2 w-2 ${ busy ? 'bg-yellow-600' : 'bg-primary' } ` }
111- style = { { borderRadius : '50%' } }
112- >
113- </ div >
114- < span class = 'text-sm opacity-50' >
115- Share this page to collaborate with others.
116- </ span >
117- </ div >
118- < div class = 'flex' >
119- < input
120- class = 'w-full px-3 py-2 mr-4 border rounded'
121- placeholder = 'Paste a link to post and expand'
122- ref = { addTodoInput }
123- />
124- < div class = 'p-px rounded-lg bg-gradient-to-tr from-secondary to-primary' >
125- < button
126- onClick = { addTodo }
127- disabled = { adding }
128- class = 'text-center text-white rounded-[7px] transition duration-300 px-4 py-2 block hover:bg-white hover:text-black hover:dark:bg-gray-900 hover:dark:!text-white'
129- >
130- Add
131- </ button >
132- </ div >
133- </ div >
107+ < div class = 'w-full p-4' >
108+ < div class = 'flex' >
109+ < input
110+ class = 'w-full px-3 py-2 mr-4 border rounded'
111+ placeholder = 'Paste a link to post and expand'
112+ ref = { addTodoInput }
113+ />
114+ < Button
115+ onClick = { addTodo }
116+ disabled = { adding }
117+ >
118+ Add
119+ </ Button >
134120 </ div >
135121 < div class = 'my-4' >
136- { data . items . map ( ( item ) => (
137- < ListItem
138- key = { item . id ! + ':' + item . versionstamp ! }
139- item = { item }
140- save = { saveTodo }
141- />
142- ) ) }
122+ < ol class = 'relative border-s border-gray-200 dark:border-gray-700' >
123+ { data . items . map ( ( item ) => (
124+ < ListItem
125+ key = { item . id ! + ':' + item . versionstamp ! }
126+ item = { item }
127+ save = { saveTodo }
128+ />
129+ ) ) }
130+ </ ol >
143131 </ div >
144132 < div class = 'py-2 text-sm border-t border-gray-300 opacity-50' >
145133 < p > Initial data fetched in { props . latency } ms</ p >
@@ -175,8 +163,11 @@ function ListItem({
175163 save ( item , null , null ) ;
176164 } , [ item ] ) ;
177165
166+ const postCreatedTimestamp = new globalThis . Date ( item . createdAt ! ) ;
167+ const timestamp = `${ postCreatedTimestamp . toLocaleDateString ( ) } • ${ postCreatedTimestamp . toLocaleTimeString ( ) } ` ;
168+
178169 return (
179- < div class = 'flex items-center ' { ...{ 'data-item-id' : item . id ! } } >
170+ < li class = 'mb-10 ms-4 ' { ...{ 'data-item-id' : item . id ! } } key = { item . id ! } >
180171 { editing && (
181172 < >
182173 < input
@@ -185,15 +176,13 @@ function ListItem({
185176 defaultValue = { item . url }
186177 />
187178 < button
188- class = 'p-2 mr-2 rounded disabled:opacity-50'
189179 title = 'Save'
190180 onClick = { doSave }
191181 disabled = { busy }
192182 >
193183 💾
194184 </ button >
195185 < button
196- class = 'p-2 rounded disabled:opacity-50'
197186 title = 'Cancel'
198187 onClick = { cancelEdit }
199188 disabled = { busy }
@@ -204,23 +193,14 @@ function ListItem({
204193 ) }
205194 { ! editing && (
206195 < >
207- < div class = 'flex flex-col w-full font-mono' >
208- < IFramely url = { String ( item . url || item . text ) } />
209- < p class = 'text-xs leading-loose opacity-50' >
210- { new Date ( item . createdAt ) . toISOString ( ) } | **updated on { new Date ( item . updatedAt ) . toISOString ( ) } **
211- </ p >
212- </ div >
213- < button
214- class = 'p-2 disabled:opacity-50'
215- title = 'Delete'
216- onClick = { doDelete }
217- disabled = { busy }
218- >
219- 🗑️
220- </ button >
196+ < div class = 'absolute w-3 h-3 bg-gray-200 rounded-full mt-1.5 -start-1.5 border border-white dark:border-gray-900 dark:bg-gray-700' />
197+ < time class = 'text-sm font-normal leading-none text-gray-400 dark:text-gray-500' > { timestamp } </ time >
198+ < div class = 'mt-2' />
199+ < Iframely url = { String ( item . url || item . text ) } />
200+ < Button onClick = { doDelete } class = 'mt-4' > delete</ Button >
221201 </ >
222202 ) }
223- </ div >
203+ </ li >
224204 ) ;
225205}
226206
0 commit comments