From 5dd8ba398f696b5ab06c056e5d6aeb3ef606f507 Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Santos Souza de Miranda Date: Fri, 20 Jun 2025 20:58:15 -0300 Subject: [PATCH] Added CSS Classes on about_screen.py and new_diary_modal.py and created the classes on the pilgrim.css file --- src/pilgrim/ui/screens/about_screen.py | 28 ++-- src/pilgrim/ui/screens/new_diary_modal.py | 18 ++- src/pilgrim/ui/styles/pilgrim.css | 177 ++++++++++++++++++++-- 3 files changed, 190 insertions(+), 33 deletions(-) diff --git a/src/pilgrim/ui/screens/about_screen.py b/src/pilgrim/ui/screens/about_screen.py index 8d9c744..ebf7d48 100644 --- a/src/pilgrim/ui/screens/about_screen.py +++ b/src/pilgrim/ui/screens/about_screen.py @@ -17,12 +17,16 @@ class AboutScreen(Screen[bool]): super().__init__() self.header = Header() self.footer = Footer() - self.app_title = Label("Pilgrim", id="AboutScreen_AboutTitle") - self.content = Label("A TUI Based Travel Diary Application", id="AboutScreen_AboutContent") - self.version = Label("Version: 0.0.1", id="AboutScreen_AboutVersion") + self.app_title = Label("Pilgrim", id="AboutScreen_AboutTitle",classes="AboutScreen_AboutTitle") + self.content = Label("A TUI Based Travel Diary Application", id="AboutScreen_AboutContent", + classes="AboutScreen_AboutContent") + self.version = Label("Version: 0.0.1", id="AboutScreen_AboutVersion", + classes="AboutScreen_AboutVersion") self.developer = Label("Developed By: Gustavo Henrique Miranda ", id="AboutScreen_AboutAuthor") - self.contact = Label("git.gustavomiranda.xyz", id="AboutScreen_AboutContact") - self.license = TextArea(id="AboutScreen_AboutLicense") + self.contact = Label("git.gustavomiranda.xyz", id="AboutScreen_AboutContact", + classes="AboutScreen_AboutContact") + self.license = TextArea(id="AboutScreen_AboutLicense", + classes="AboutScreen_AboutLicense") self.license.text = """Copyright (c) 2025 GHMiranda. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -35,9 +39,11 @@ Redistribution and use in source and binary forms, with or without modification, THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.""" self.license.read_only = True - self.about_container = Container(self.app_title, self.content, self.version, self.developer, self.contact, - id="AboutScreen_SubContainer") - self.container = Container(self.about_container, self.license, id="AboutScreen_AboutContainer") + self.about_container = Container(self.app_title, self.content, self.version, self.developer, + self.contact, id="AboutScreen_SubContainer", + classes="AboutScreen_SubContainer") + self.container = Container(self.about_container, self.license, id="AboutScreen_AboutContainer", + classes="AboutScreen_AboutContainer") def compose(self) -> ComposeResult: yield self.header @@ -51,8 +57,10 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND elif "about-info-button" in event.button.classes: self.notify("Mais informações seriam exibidas aqui!", title="Info") - def action_dismiss(self) -> None: - """Fecha o about box usando dismiss.""" + def action_dismiss(self, **kwargs) -> None: + """Fecha o about box usando dismiss. + :param **kwargs: + """ self.dismiss(False) def on_key(self, event) -> None: diff --git a/src/pilgrim/ui/screens/new_diary_modal.py b/src/pilgrim/ui/screens/new_diary_modal.py index 310f843..26323ba 100644 --- a/src/pilgrim/ui/screens/new_diary_modal.py +++ b/src/pilgrim/ui/screens/new_diary_modal.py @@ -5,21 +5,23 @@ from textual.widgets import Label, Input, Button class NewDiaryModal(ModalScreen[str]): BINDINGS = [ - ("escape", "cancel", "Cancelar"), + ("escape", "cancel", "Cancel"), ] def __init__(self): super().__init__() - self.name_input = Input(id="NewDiaryModal-NameInput") # This ID is fine, it's specific to the input + self.name_input = Input(id="NewDiaryModal-NameInput",classes="NewDiaryModal-NameInput") # This ID is fine, it's specific to the input def compose(self) -> ComposeResult: - # CHANGE THIS LINE: Use the ID that matches your CSS - with Vertical(id="new_diary_dialog"): # <--- Changed ID here to match CSS - yield Label("Create a new diary", classes="dialog-title") + + with Vertical(id="new_diary_dialog",classes="NewDiaryModal-Dialog"): + yield Label("Create a new diary", classes="NewDiaryModal-Title") yield Label("Diary Name:") yield self.name_input - with Horizontal(classes="dialog-buttons"): - yield Button("Create", variant="primary", id="create_diary_button") - yield Button("Cancel", variant="default", id="cancel_button") + with Horizontal(classes="NewDiaryModal-ButtonsContainer"): + yield Button("Create", variant="primary", id="create_diary_button", + classes="NewDiaryModal-CreateDiaryButton") + yield Button("Cancel", variant="default", id="cancel_button", + classes="NewDiaryModal-CancelButton") def on_mount(self): self.name_input.focus() diff --git a/src/pilgrim/ui/styles/pilgrim.css b/src/pilgrim/ui/styles/pilgrim.css index b6f5f6a..6cc75cc 100644 --- a/src/pilgrim/ui/styles/pilgrim.css +++ b/src/pilgrim/ui/styles/pilgrim.css @@ -1,25 +1,172 @@ - -.dialog-container{ - content-align: center top; +Screen { + layout: vertical; + background: $surface-darken-1; + align: center middle; +} +.DiaryListScreen-DiaryListContainer { + height: 1fr; + width: 100%; + layout: vertical; + align: center top; /* Alinha no topo para seguir o wireframe */ + padding: 2 4; /* Mais espaço nas laterais */ + background: $surface; /* Removendo aquamarine para ficar mais limpo */ } -.app-title{ - dock: top; - height: 3; - content-align: center middle; - text-style: bold; - color: $accent; +/* A lista de diários - área principal como no wireframe */ +.DiaryListScreen-DiaryListOptions { + border: round $primary-lighten-2; + background: $surface; + width: 75%; /* Largura generosa como no wireframe */ + height: 72%; /* Ocupa o espaço disponível */ + margin: 2 0; /* Margem vertical para separar dos outros elementos */ } -.actions-buttons{ +.DiaryListScreen-DiaryListOptions:focus { + border: round $primary; +} + +/* O contêiner dos botões - logo abaixo da lista */ +.DiaryListScreen-ButtonsGrid { + layout: horizontal; + align: center middle; + width: 79%; /* Mesma largura da lista */ + height: 20%; /* Aumentando altura para caber o texto dos botões */ +} + +/* Botões individuais - garantindo espaço para o texto */ +.DiaryListScreen-NewDiaryButton, +.DiaryListScreen-EditDiaryButton, +.DiaryListScreen-OpenDiaryButton { + margin: 0 1 1 0; /* Espaço entre os botões */ + height: 1fr; + width: 1fr; + border: round grey; +} + +/* As dicas - usando a classe correta */ +.DiaryListScreen-DiaryListTips { + width: 100%; /* Largura total quando usando dock */ height: auto; - margin: 1 0; + text-style: italic; + text-align: center; /* Centraliza o texto dentro do elemento */ + color: $text-muted; + dock: bottom; /* Gruda no fundo da tela */ + margin: 0 1; +} + +/* Estilos genéricos que não mudaram */ +.option-list--option-highlighted { + background: $primary-darken-2; +} + +.option-list--option-selected { + text-style: bold; + background: $primary; +} + +Header { + background: $primary; + color: $text; +} + +Footer { + background: $primary; + color: $text; +} + +AboutScreen { align: center middle; } -.tips{ - dock: bottom; - height: 4; - content-align: center middle; +.AboutScreen_AboutContainer { + align: center middle; + width: 85%; + height: 95%; + border: thick $primary; + background: $surface; + margin: 1; +} + +.AboutScreen_AboutContainer TextArea { + align: center middle; + width: 100%; + height: 55%; + margin: 2; + padding: 1; +} + +.AboutScreen_SubContainer { + align: center middle; + height: 45%; + padding: 1 1; + margin: 1 1; +} + +.AboutScreen_AboutTitle { + color: $accent; + text-style: bold; + text-align: center; + margin-bottom: 1; +} + +.AboutScreen_AboutVersion { + color: $warning; + text-style: italic; + text-align: center; + margin-bottom: 1; +} + +.AboutScreen_AboutContent { + text-align: center; + margin-bottom: 1; +} + +.AboutScreen_AboutContact, +.AboutScreen_AboutAuthor { color: $text-muted; + text-align: center; + margin-bottom: 1; +} + +.AboutScreen_AboutLicense { + height: 60%; +} + +Screen.-modal { + background: rgba(0, 0, 0, 0.7); /* Escurece o fundo da tela por baixo */ + align: center middle; /* Centraliza o conteúdo (sua modal) que está nesta tela modal */ +} + +.NewDiaryModal-Dialog { + width: 60%; /* Largura do diálogo */ + height: auto; /* Altura automática */ + background: $surface; /* Fundo do diálogo */ + border: thick $accent; /* Borda chamativa */ + padding: 2 4; /* Espaçamento interno */ + align: center middle; /* Centraliza conteúdo dentro do diálogo */ + layout: vertical; +} + +.NewDiaryModal-Dialog .NewDiaryModal-Title{ + text-align: center; + text-style: bold; + color: $primary; + margin-bottom: 1; +} + +.NewDiaryModal-NameInput{ + width: 1fr; /* Ocupa a largura disponível */ + margin-bottom: 2; +} + +.NewDiaryModal-ButtonsContainer{ + width: 1fr; + height: auto; + align: center middle; + padding-top: 1; +} + +.NewDiaryModal-ButtonsContainer Button{ + margin: 0 1; + width: 1fr; } \ No newline at end of file