ui: add initial Profile hover previews

The idea with these is that on notedeck you can just hover your cursor
over a profile link to see the profile. I just have a stub for now, but
full design coming soon after.

Also simplify the preview system even further with a macro. In the
future I imagine we can grep every preview in the codebase, and then
include this as a string inside this macro. This is some kind of
template metaprogramming insanity but in theory it could work.

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2024-04-19 22:00:19 -07:00
parent 2d566cc637
commit 05fe164a49
13 changed files with 148 additions and 28 deletions

View File

@@ -1,4 +1,5 @@
use enostr::RelayPool;
use nostrdb::ProfileRecord;
#[allow(unused_must_use)]
pub fn sample_pool() -> RelayPool {
@@ -17,3 +18,34 @@ pub fn sample_pool() -> RelayPool {
pool
}
const TEST_PROFILE_DATA: [u8; 384] = [
0x04, 0x00, 0x00, 0x00, 0x94, 0xfe, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x19, 0xef, 0x9c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x57, 0x26, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x66, 0x69, 0x78, 0x6d,
0x65, 0x00, 0x00, 0x00, 0x38, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff,
0xd8, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00,
0x60, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x20, 0x00,
0x1c, 0x00, 0x08, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x10, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6a, 0x62, 0x35, 0x35,
0x00, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x64, 0x61, 0x6d, 0x75, 0x73, 0x2e, 0x69, 0x6f,
0x20, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x2e, 0x20, 0x62, 0x69, 0x74, 0x63, 0x6f, 0x69, 0x6e,
0x20, 0x61, 0x6e, 0x64, 0x20, 0x6e, 0x6f, 0x73, 0x74, 0x72, 0x20, 0x64, 0x65, 0x76, 0x00, 0x00,
0x1e, 0x00, 0x00, 0x00, 0x57, 0x69, 0x6c, 0x6c, 0x69, 0x61, 0x6d, 0x20, 0x43, 0x61, 0x73, 0x61,
0x72, 0x69, 0x6e, 0x20, 0xf0, 0x9f, 0x87, 0xa8, 0xf0, 0x9f, 0x87, 0xa6, 0xe2, 0x9a, 0xa1, 0xef,
0xb8, 0x8f, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f,
0x63, 0x64, 0x6e, 0x2e, 0x6a, 0x62, 0x35, 0x35, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x6d, 0x67,
0x2f, 0x72, 0x65, 0x64, 0x2d, 0x6d, 0x65, 0x2e, 0x6a, 0x70, 0x67, 0x00, 0x0d, 0x00, 0x00, 0x00,
0x6a, 0x62, 0x35, 0x35, 0x40, 0x6a, 0x62, 0x35, 0x35, 0x2e, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x75, 0x72,
0x6c, 0x31, 0x64, 0x70, 0x36, 0x38, 0x67, 0x75, 0x72, 0x6e, 0x38, 0x67, 0x68, 0x6a, 0x37, 0x75,
0x6d, 0x39, 0x64, 0x65, 0x6a, 0x38, 0x78, 0x63, 0x74, 0x35, 0x77, 0x76, 0x68, 0x78, 0x63, 0x6d,
0x6d, 0x76, 0x39, 0x75, 0x68, 0x38, 0x77, 0x65, 0x74, 0x76, 0x64, 0x73, 0x6b, 0x6b, 0x6b, 0x6d,
0x6e, 0x30, 0x77, 0x61, 0x68, 0x7a, 0x37, 0x6d, 0x72, 0x77, 0x77, 0x34, 0x65, 0x78, 0x63, 0x75,
0x70, 0x30, 0x64, 0x66, 0x33, 0x72, 0x32, 0x64, 0x67, 0x33, 0x6d, 0x6a, 0x34, 0x34, 0x34, 0x00,
0x0c, 0x00, 0x24, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x1c, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00,
];
pub fn test_profile_record() -> ProfileRecord<'static> {
ProfileRecord::new_owned(&TEST_PROFILE_DATA).unwrap()
}