Skip to main content

max / makenotwork

6.0 KB · 117 lines History Blame Raw
1 {% extends "base.html" %}
2
3 {% block title %}Discover - Makenotwork{% endblock %}
4 {% block body_attrs %} class="padded-page"{% endblock %}
5
6 {% block content %}
7 {% include "partials/site_header.html" %}
8
9 <h1 class="page-title">Discover</h1>
10
11 <div class="discover-layout{% if mode == "projects" && sidebar.category_filters.is_empty() %} no-sidebar{% endif %}">
12 {% include "partials/discover_sidebar.html" %}
13
14 <button type="button" class="discover-filter-toggle" data-action="toggleDiscoverFilters" aria-expanded="false" aria-controls="discover-sidebar" aria-label="Toggle filters">
15 Filters{% if sidebar.active_filter_count > 0 %} <span class="filter-count">{{ sidebar.active_filter_count }}</span>{% endif %}
16 </button>
17
18 <main class="discover-main">
19 <div class="mode-toggle">
20 <button class="toggle-btn{% if mode == "items" %} is-selected{% endif %}"
21 hx-get="/discover"
22 hx-target="body"
23 hx-push-url="true"
24 hx-vals='{"mode": "items"}'>Items</button>
25 <button class="toggle-btn{% if mode == "projects" %} is-selected{% endif %}"
26 hx-get="/discover"
27 hx-target="body"
28 hx-push-url="true"
29 hx-vals='{"mode": "projects"}'>Projects</button>
30 <div class="view-controls">
31 <button type="button" class="view-btn" data-view="list" title="List view">|||</button>
32 <button type="button" class="view-btn is-selected" data-view="grid" title="Grid view">:::</button>
33 </div>
34 </div>
35
36 {# `tag-added` is fired by the typeahead once it appends a hidden
37 input, so picking a suggestion refreshes results through the same
38 path as every other filter control. #}
39 <form id="discover-form" action="/discover" method="get"
40 hx-get="/discover/results"
41 hx-target="#results-container"
42 hx-indicator="#search-spinner"
43 hx-include=".discover-filter"
44 hx-trigger="tag-added">
45 <input type="hidden" id="mode-input" name="mode" value="{{ mode }}" class="discover-filter">
46 <div class="table-controls">
47 <label for="search-input" class="sr-only">Search {% if mode == "projects" %}projects{% else %}items{% endif %}</label>
48 <div class="search-wrapper">
49 <input type="text"
50 id="search-input"
51 class="search-field discover-filter"
52 placeholder="Search {% if mode == "projects" %}projects{% else %}items{% endif %}..."
53 name="q"
54 value="{{ search_query }}"
55 autocomplete="off"
56 aria-label="Search {% if mode == "projects" %}projects{% else %}items{% endif %}"
57 hx-get="/discover/results"
58 hx-trigger="input changed delay:150ms, search"
59 hx-target="#results-container"
60 hx-indicator="#search-spinner"
61 hx-include=".discover-filter">
62 <div id="search-suggestions" class="search-suggestions"></div>
63 </div>
64 <span id="search-spinner" class="htmx-indicator" aria-live="polite">Searching...</span>
65 <span class="table-meta" id="total-count">{{ total_items }} {% if mode == "projects" %}projects{% else %}items{% endif %}</span>
66 <label for="sort-select" class="sr-only">Sort by</label>
67 <select class="sort-select discover-filter"
68 id="sort-select"
69 name="sort"
70 aria-label="Sort results by"
71 hx-get="/discover/results"
72 hx-trigger="change"
73 hx-target="#results-container"
74 hx-indicator="#search-spinner"
75 hx-include=".discover-filter">
76 {% if mode == "projects" %}
77 <option value="newest"{% if sort_by == "newest" || sort_by == "" %} selected{% endif %}>Newest</option>
78 <option value="most_sold"{% if sort_by == "most_sold" %} selected{% endif %}>Most items</option>
79 {% else %}
80 <option value="most_sold"{% if sort_by == "most_sold" %} selected{% endif %}>Most sold</option>
81 <option value="newest"{% if sort_by == "newest" || sort_by == "" %} selected{% endif %}>Newest</option>
82 <option value="price_asc"{% if sort_by == "price_asc" %} selected{% endif %}>Price asc</option>
83 <option value="price_desc"{% if sort_by == "price_desc" %} selected{% endif %}>Price desc</option>
84 {% endif %}
85 </select>
86 </div>
87 </form>
88
89 {% if mode == "projects" %}
90 <div class="table-header projects-header">
91 <span>Name</span>
92 <span>Category</span>
93 <span class="col-right">Items</span>
94 <span class="col-right">Added</span>
95 </div>
96 {% else %}
97 <div class="table-header">
98 <span>Type</span>
99 <span>Name</span>
100 <span>Tag</span>
101 <span class="col-right">Price</span>
102 <span class="col-right">Added</span>
103 </div>
104 {% endif %}
105
106 <div id="results-container">
107 {% include "partials/discover_results.html" %}
108 </div>
109 </main>
110 </div>
111 {% endblock %}
112
113 {% block scripts %}
114 <script src="/static/collections.js?v=0514"></script>
115 <script src="/static/page-discover.js?v=0623" defer></script>
116 {% endblock %}
117