File size: 4,843 Bytes
918f10e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<!DOCTYPE html>
<html>
<head>
    {%if is_space %}
        <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
    {% endif %}
    <style>
        /* Reset some default styles */
        body, h1, h2, h3, p, ul {
            margin: 0;
            padding: 0;
        }

        body {
            font-family: 'Arial', sans-serif;
            overflow-y: hidden;
        }

        /* Sidebar styling */
        .sidebar {
            position: fixed;
            top: 0;
            left: 0;
            width: 300px;
            height: 100vh;
            max-height: calc(100vh - 50px);
            overflow-y: scroll;
            overflow-x: hidden;
            font-size: 0.875rem;
            line-height: 1.25rem;
            transition: all 0.3s ease;
            background: #f8f9fa;
            box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
            padding-top: 50px; /* Add padding for the button */
        }

        /* Customize scrollbar */
        .sidebar::-webkit-scrollbar {
            width: 6px;
        }

        .sidebar::-webkit-scrollbar-track {
            background: #f1f1f1;
        }

        .sidebar::-webkit-scrollbar-thumb {
            background: #888;
            border-radius: 3px;
        }

        .sidebar.collapsed {
            width: 0;
            box-shadow: none;
        }

        .sidebar a {
            display: block;
            margin: 8px 12px;
            padding: 12px 16px;
            text-decoration: none;
            color: #424242;
            background: white;
            border-radius: 8px;
            transition: all 0.2s ease;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
        }

        .sidebar a:hover {
            color: #1a73e8;
            transform: translateY(-1px);
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        .sidebar a.active {
            background: #1a73e8;
            color: white;
            font-weight: 500;
            box-shadow: 0 4px 8px rgba(26, 115, 232, 0.2);
        }

        /* Error state for demos that don't work */
        .sidebar a:has(span) {
            border-left: 3px solid #dc3545;
        }

        /* Content area styling */
        .content {
            margin-left: 300px;
            padding: 20px;
            height: 100vh;
            transition: margin-left 0.3s ease;
            overflow-y: auto;
        }

        .content.collapsed {
            margin-left: 0;
        }

        .content iframe {
            width: 100%;
            height: 80%;
            border: 0;
        }

        /* Toggle button styling */
        .close-btn {
            position: fixed;
            top: 0;
            left: 0;
            z-index: 101;
            cursor: pointer;
            border: none;
            background: #f8f9fa;
            width: 300px;
            height: 50px;
            border-radius: 0;
            display: flex;
            align-items: center;
            padding: 0 20px;
            justify-content: flex-end;
            transition: all 0.3s ease;
        }

        .close-btn.collapsed {
            width: 50px;
            justify-content: center;
        }

        @media only screen and (max-width: 600px) {
            .close-btn {
                top: 20px;
                left: 20px;
                background: white;
                z-index: 102; /* Ensure it's above the sidebar */
            }

            .sidebar {
                width: 100%;
                z-index: 100;
            }

            .content {
                margin-left: 0;
                padding: 10px;
                height: calc(100vh - 70px);
                margin-top: 70px;
            }

            .sidebar.collapsed {
                transform: translateX(-100%);
            }

            .content.collapsed {
                margin-top: 70px;
            }
        }
    </style>
    <script src="//unpkg.com/alpinejs" defer></script>
</head>
<body x-data="{ current_demo: '{{ initial_demo }}', is_collapsed: false }">
    <div style="display: flex; flex-direction: column;">
        <button @click="is_collapsed = !is_collapsed" 
                class="close-btn"
                :class="{ 'collapsed': is_collapsed }">
            <span x-text="is_collapsed ? '➡️' : '⬅️'"></span>
        </button>
        <div :class="{ 'sidebar': true, 'collapsed': is_collapsed }">
            {% for name in names %}
                <a @click="current_demo = '{{ name[0] }}'" :class="current_demo == '{{ name[0] }}' ? 'active' : ''">{{ name[0] }} {% if name[1] %}❌{% endif %}</a>
            {% endfor %}
        </div>
    </div>
    <div :class="{ 'content': true, 'collapsed': is_collapsed }">
        <iframe :src="`/demo/${current_demo}${document.location.search}`"></iframe>
    </div>
</body>
</html>