File size: 2,711 Bytes
c8c7c5f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
document.addEventListener('DOMContentLoaded', function() {
    // Sample data - in a real app, this would come from your backend API
    const samplePosts = [
        {
            id: 1,
            username: 'traveler123',
            userImage: 'http://static.photos/travel/200x200/1',
            image: 'http://static.photos/travel/1024x576/1',
            caption: 'Exploring the beautiful mountains! πŸ”οΈ #adventure #travel',
            likes: 1243,
            comments: 42,
            timeAgo: '2h ago',
            isLiked: false
        },
        {
            id: 2,
            username: 'foodlover',
            userImage: 'http://static.photos/food/200x200/1',
            image: 'http://static.photos/food/1024x576/1',
            caption: 'Delicious homemade pasta for dinner tonight! 🍝 #foodie #homecooking',
            likes: 892,
            comments: 31,
            timeAgo: '5h ago',
            isLiked: true
        }
    ];

    const postsContainer = document.getElementById('posts-container');
    
    // Render sample posts
    samplePosts.forEach(post => {
        const postElement = document.createElement('custom-post-card');
        postElement.setAttribute('post-id', post.id);
        postElement.setAttribute('username', post.username);
        postElement.setAttribute('user-image', post.userImage);
        postElement.setAttribute('image', post.image);
        postElement.setAttribute('caption', post.caption);
        postElement.setAttribute('likes', post.likes);
        postElement.setAttribute('comments', post.comments);
        postElement.setAttribute('time-ago', post.timeAgo);
        postElement.setAttribute('is-liked', post.isLiked);
        postsContainer.appendChild(postElement);
    });

    // Toggle auth modal
    const authModal = document.querySelector('custom-auth-modal');
    const authButtons = document.querySelectorAll('[data-auth-toggle]');
    
    authButtons.forEach(button => {
        button.addEventListener('click', () => {
            const action = button.getAttribute('data-auth-toggle');
            authModal.setAttribute('visible', 'true');
            authModal.setAttribute('mode', action);
        });
    });

    // Mock authentication state
    let isAuthenticated = false;
    
    function updateAuthUI() {
        const authElements = document.querySelectorAll('[data-auth-state]');
        authElements.forEach(el => {
            const showWhen = el.getAttribute('data-auth-state');
            el.style.display = (showWhen === 'logged-in') === isAuthenticated ? '' : 'none';
        });
    }
    
    // For demo purposes - in a real app, this would be handled by your auth system
    updateAuthUI();
});