Improve sidebar layout: center Projects title, fix padding, add method chips

- Center "Projects" label in sidebar headerbar via title-widget property
- Fix asymmetric request list margins (margin-start 12→6, add margin-end 6)
- Replace dim method labels with colored chips (GET/POST/PUT/PATCH/DELETE)
This commit is contained in:
Pavel Baksy 2026-05-20 00:07:59 +02:00
parent 728697711c
commit a6c389edd7
5 changed files with 33 additions and 13 deletions

View File

@ -43,22 +43,20 @@
<!-- Sidebar Header Bar -->
<child type="top">
<object class="AdwHeaderBar">
<property name="show-title">False</property>
<property name="show-end-title-buttons">False</property>
<property name="show-start-title-buttons">False</property>
<child type="start">
<object class="GtkWindowControls">
<property name="side">start</property>
</object>
</child>
<child type="start">
<property name="title-widget">
<object class="GtkLabel">
<property name="label">Projects</property>
<property name="margin-start">6</property>
<style>
<class name="title"/>
</style>
</object>
</property>
<child type="start">
<object class="GtkWindowControls">
<property name="side">start</property>
</object>
</child>
<child type="end">
<object class="GtkButton" id="add_project_button">

View File

@ -72,7 +72,8 @@
<child>
<object class="GtkListBox" id="requests_listbox">
<property name="margin-start">12</property>
<property name="margin-start">6</property>
<property name="margin-end">6</property>
<style>
<class name="navigation-sidebar"/>
</style>

View File

@ -11,10 +11,9 @@
<child>
<object class="GtkLabel" id="method_label">
<property name="width-chars">6</property>
<property name="xalign">0.5</property>
<style>
<class name="caption"/>
<class name="dim-label"/>
<class name="method-chip"/>
</style>
</object>
</child>

View File

@ -20,6 +20,14 @@
from gi.repository import Gtk, GObject
_METHOD_CSS = {
'GET': 'accent',
'POST': 'success',
'PUT': 'warning',
'PATCH': 'warning',
'DELETE': 'error',
}
@Gtk.Template(resource_path='/cz/bugsy/roster/widgets/request-item.ui')
class RequestItem(Gtk.Box):
@ -38,7 +46,9 @@ class RequestItem(Gtk.Box):
def __init__(self, saved_request):
super().__init__()
self.saved_request = saved_request
self.method_label.set_text(saved_request.request.method)
method = saved_request.request.method
self.method_label.set_text(method)
self.method_label.add_css_class(_METHOD_CSS.get(method, 'dim-label'))
self.name_label.set_text(saved_request.name)
# Add click gesture for loading

View File

@ -203,6 +203,18 @@ class RosterWindow(Adw.ApplicationWindow):
color: @accent_color;
font-weight: 600;
}
/* Method chips in sidebar request list */
.method-chip {
border-radius: 4px;
padding: 1px 5px;
font-size: 0.72em;
font-weight: 700;
}
.method-chip.accent { background-color: alpha(@accent_bg_color, 0.18); }
.method-chip.success { background-color: alpha(@success_bg_color, 0.18); }
.method-chip.warning { background-color: alpha(@warning_bg_color, 0.18); }
.method-chip.error { background-color: alpha(@error_bg_color, 0.18); }
""")
Gtk.StyleContext.add_provider_for_display(