Skip to content

Commit

Permalink
Improve CSS styles for responsiveness (#87)
Browse files Browse the repository at this point in the history
* Update logging functionality and improve CSS styles for responsiveness

1. **logger.py**:
   - **Issue**: Redundant file handling when logging messages.
   - **Old Code**:
     ```python
     if not path.exists(log_file):
         with open(log_file, mode="w", encoding="utf-8") as file:
             file.close()
     with open(log_file, mode="a", encoding="utf-8") as file:
         file.write(f"{log_msg}\n")
         file.close()

        **When checking if the log file exists, you opened it in write mode (mode="w"), which would create the file if it didn’t exist.**
        **However, immediately after that, you closed the file without writing anything to it.**
	**This is redundant because you don't need to create the file in write mode if you plan to open it again in append mode.**
     ```
   - **New Code**:
     ```python
     # Open in append mode; this will create the file if it doesn't exist
     with open(log_file, mode="a", encoding="utf-8") as file:
         file.write(f"{log_msg}\n")  # This handles both file creation and writing

      The **with** statement opens the file and ensures it’s properly closed when the block of code is exited, **eliminating the need for the explicit file.close() statement.**

     ```
   - **Solution**: Removed unnecessary file close after opening the log file in write mode, utilizing append mode to handle file creation and writing efficiently.

2. **style.css**:
   - **Issue**:
     (1)- Inconsistent use of units for margin and padding, affecting responsiveness.
     (2)- Deprecated property value `white-space: nowrap;` in `#noticeText`, which can lead to text overflow issues if the text exceeds the container's width.
   - **Solution**:
     - Replaced percentage values for margins and paddings with `rem` units for better scalability and consistency across devices.
     - Removed `white-space: nowrap;` from `#noticeText` and replaced it with `white-space: normal`, allowing text to wrap within the container for improved readability and responsiveness.

These changes enhance the logging functionality and improve the CSS styles for better responsiveness and usability across different devices.

* change in the auto css generating function

* [pre-commit.ci] auto fixes from pre-commit.com hooks

* some neccesary changes as per your request

* [pre-commit.ci] auto fixes from pre-commit.com hooks

* Fix merge conflict

* Regenerate generated files

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: CoolCat467 <[email protected]>
  • Loading branch information
3 people authored Oct 5, 2024
1 parent 866fd7a commit 316ce01
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/sanescansrv/generate_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ def generate_style_css() -> str:
"#noticeText",
font_size="10px",
display="inline-block",
white_space="nowrap",
white_space="normal",
),
htmlgen.css(
'input[type="submit"]',
border=("1.5px", "solid", "black"),
border_radius="4px",
padding="0.5%",
margin_left="0.5%",
margin_right="0.5%",
padding="0.5rem",
margin_left="0.5rem",
margin_right="0.5rem",
min_width="min-content",
),
),
Expand Down
7 changes: 2 additions & 5 deletions src/sanescansrv/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,9 @@ def log(message: str, level: int = 1, log_dir: str | None = None) -> None:

log_msg = f"[{PROGRAM_TITLE}] [{log_time}] [{log_level}] {log_message_text}"

if not path.exists(log_file):
with open(log_file, mode="w", encoding="utf-8") as file:
file.close()
# Open in append mode; this will create the file if it doesn't exist
with open(log_file, mode="a", encoding="utf-8") as file:
file.write(f"{log_msg}\n")
file.close()
file.write(f"{log_msg}\n") # This handles both file creation and writing
print(log_msg)


Expand Down
8 changes: 4 additions & 4 deletions src/sanescansrv/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ code {
#noticeText {
font-size: 10px;
display: inline-block;
white-space: nowrap;
white-space: normal;
}
input[type="submit"] {
border: 1.5px solid black;
border-radius: 4px;
padding: 0.5%;
margin-left: 0.5%;
margin-right: 0.5%;
padding: 0.5rem;
margin-left: 0.5rem;
margin-right: 0.5rem;
min-width: min-content;
}

0 comments on commit 316ce01

Please sign in to comment.