Added CSS Classes on about_screen.py and new_diary_modal.py and created the classes on the pilgrim.css file

This commit is contained in:
Gustavo Henrique Santos Souza de Miranda 2025-06-20 20:58:15 -03:00
parent cb31ba5662
commit 5dd8ba398f
3 changed files with 190 additions and 33 deletions

View File

@ -17,12 +17,16 @@ class AboutScreen(Screen[bool]):
super().__init__() super().__init__()
self.header = Header() self.header = Header()
self.footer = Footer() self.footer = Footer()
self.app_title = Label("Pilgrim", id="AboutScreen_AboutTitle") self.app_title = Label("Pilgrim", id="AboutScreen_AboutTitle",classes="AboutScreen_AboutTitle")
self.content = Label("A TUI Based Travel Diary Application", id="AboutScreen_AboutContent") self.content = Label("A TUI Based Travel Diary Application", id="AboutScreen_AboutContent",
self.version = Label("Version: 0.0.1", id="AboutScreen_AboutVersion") 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.developer = Label("Developed By: Gustavo Henrique Miranda ", id="AboutScreen_AboutAuthor")
self.contact = Label("git.gustavomiranda.xyz", id="AboutScreen_AboutContact") self.contact = Label("git.gustavomiranda.xyz", id="AboutScreen_AboutContact",
self.license = TextArea(id="AboutScreen_AboutLicense") classes="AboutScreen_AboutContact")
self.license = TextArea(id="AboutScreen_AboutLicense",
classes="AboutScreen_AboutLicense")
self.license.text = """Copyright (c) 2025 GHMiranda. 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: 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.""" 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.license.read_only = True
self.about_container = Container(self.app_title, self.content, self.version, self.developer, self.contact, self.about_container = Container(self.app_title, self.content, self.version, self.developer,
id="AboutScreen_SubContainer") self.contact, id="AboutScreen_SubContainer",
self.container = Container(self.about_container, self.license, id="AboutScreen_AboutContainer") classes="AboutScreen_SubContainer")
self.container = Container(self.about_container, self.license, id="AboutScreen_AboutContainer",
classes="AboutScreen_AboutContainer")
def compose(self) -> ComposeResult: def compose(self) -> ComposeResult:
yield self.header 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: elif "about-info-button" in event.button.classes:
self.notify("Mais informações seriam exibidas aqui!", title="Info") self.notify("Mais informações seriam exibidas aqui!", title="Info")
def action_dismiss(self) -> None: def action_dismiss(self, **kwargs) -> None:
"""Fecha o about box usando dismiss.""" """Fecha o about box usando dismiss.
:param **kwargs:
"""
self.dismiss(False) self.dismiss(False)
def on_key(self, event) -> None: def on_key(self, event) -> None:

View File

@ -5,21 +5,23 @@ from textual.widgets import Label, Input, Button
class NewDiaryModal(ModalScreen[str]): class NewDiaryModal(ModalScreen[str]):
BINDINGS = [ BINDINGS = [
("escape", "cancel", "Cancelar"), ("escape", "cancel", "Cancel"),
] ]
def __init__(self): def __init__(self):
super().__init__() 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: 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 with Vertical(id="new_diary_dialog",classes="NewDiaryModal-Dialog"):
yield Label("Create a new diary", classes="dialog-title") yield Label("Create a new diary", classes="NewDiaryModal-Title")
yield Label("Diary Name:") yield Label("Diary Name:")
yield self.name_input yield self.name_input
with Horizontal(classes="dialog-buttons"): with Horizontal(classes="NewDiaryModal-ButtonsContainer"):
yield Button("Create", variant="primary", id="create_diary_button") yield Button("Create", variant="primary", id="create_diary_button",
yield Button("Cancel", variant="default", id="cancel_button") classes="NewDiaryModal-CreateDiaryButton")
yield Button("Cancel", variant="default", id="cancel_button",
classes="NewDiaryModal-CancelButton")
def on_mount(self): def on_mount(self):
self.name_input.focus() self.name_input.focus()

View File

@ -1,25 +1,172 @@
Screen {
.dialog-container{ layout: vertical;
content-align: center top; 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{ /* A lista de diários - área principal como no wireframe */
dock: top; .DiaryListScreen-DiaryListOptions {
height: 3; border: round $primary-lighten-2;
content-align: center middle; background: $surface;
text-style: bold; width: 75%; /* Largura generosa como no wireframe */
color: $accent; 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; 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; align: center middle;
} }
.tips{ .AboutScreen_AboutContainer {
dock: bottom; align: center middle;
height: 4; width: 85%;
content-align: center middle; 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; 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;
} }