Replace content CLI with Textual TUI
This commit is contained in:
1 parent
0d58ddd430
commit
737700a9a8
28 files changed
+2403
-167
No files matched your search
@@ -0,0 +1,30 @@
|
||||
from textual import on
|
||||
from textual.app import ComposeResult
|
||||
from textual.widgets import Select
|
||||
|
||||
import portfolio
|
||||
from tui.record_pane import RecordListPane
|
||||
|
||||
IMAGE_FOLDERS = {"hackathons": "hacks", "organizations": "organizations", "opensource": "projects"}
|
||||
|
||||
|
||||
class ProjectsPane(RecordListPane):
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(portfolio.PROJECT_COLLECTIONS[0], **kwargs)
|
||||
|
||||
def compose_header(self) -> ComposeResult:
|
||||
options = [(collection.title, collection.id) for collection in portfolio.PROJECT_COLLECTIONS]
|
||||
yield Select(options, value=self.collection.id, allow_blank=False, id="category-select")
|
||||
|
||||
@on(Select.Changed, "#category-select")
|
||||
def category_changed(self, event: Select.Changed):
|
||||
if event.value == self.collection.id:
|
||||
return
|
||||
self.collection = portfolio.find_collection(str(event.value))
|
||||
self.set_content_file(self.collection.file)
|
||||
self.build_columns()
|
||||
self.reload()
|
||||
self.table().focus()
|
||||
|
||||
def image_folder(self) -> str:
|
||||
return IMAGE_FOLDERS.get(self.collection.id, "")
|
||||
Reference in new issue
Block a user