Skip to content

Commit

Permalink
Fix index completion count badge
Browse files Browse the repository at this point in the history
  • Loading branch information
daya0576 committed Jan 31, 2025
1 parent 776f7d9 commit 3b570a7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN apt-get update \
curl \
ca-certificates
WORKDIR $PYSETUP_PATH
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
COPY --from=ghcr.io/astral-sh/uv:0.5.26 /uv /uvx /bin/
ENV PATH="/root/.local/bin/:$PATH"

COPY uv.lock pyproject.toml ./
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.nobuildkit.arm32
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ENV OPENSSL_LIB_DIR=/usr/lib/arm-linux-gnueabihf
ENV OPENSSL_INCLUDE_DIR=/usr/include/arm-linux-gnueabihf/openssl

WORKDIR $PYSETUP_PATH
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
COPY --from=ghcr.io/astral-sh/uv:0.5.26 /uv /uvx /bin/
ENV PATH="/root/.local/bin/:$PATH"

COPY uv.lock pyproject.toml ./
Expand Down
19 changes: 11 additions & 8 deletions beaverhabits/frontend/index_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@

HABIT_LIST_RECORD_COUNT = settings.INDEX_DAYS_COUNT

LEFT_ITEM_CLASSES = "w-32 sm:w-36 truncate self-center"
LEFT_ITEM_CLASSES = "w-32 lg:w-36 truncate self-center"
RIGHT_ITEM_CLASSES = "w-10 self-center"


def week_headers(days: list[datetime.date]):
for day in days:
yield day.strftime("%a")
if settings.INDEX_SHOW_HABIT_COUNT:
yield "Sum"
for day in days:
yield day.strftime("%a")


def day_headers(days: list[datetime.date]):
for day in days:
yield day.strftime("%d")
if settings.INDEX_SHOW_HABIT_COUNT:
yield "#"
for day in days:
yield day.strftime("%d")


@contextmanager
Expand All @@ -52,7 +52,7 @@ def flex(height: int):
# Auto hide flex items when it overflows the flex parent
f.classes("flex flex-row-reverse w-full justify-evenly")
# Auto ajust gap with screen size
f.classes("gap-x-0.5 sm:gap-x-1.5")
f.classes("gap-x-0.5 lg:gap-x-1")
# Auto hide overflowed items
f.classes(f"overflow-hidden h-{height}")
yield f
Expand All @@ -77,6 +77,10 @@ def headers(labels: Iterable[str]):

def checkboxes(habit: Habit, days: list[datetime.date]):
with flex(10):
if settings.INDEX_SHOW_HABIT_COUNT:
with ui.element("div").classes("w-10 h-10 flex place-content-center"):
IndexBadge(habit)

ticked_days = set(habit.ticked_days)
for day in days:
checkbox = HabitCheckBox(habit, day, day in ticked_days)
Expand All @@ -103,10 +107,9 @@ def habit_list_ui(days: list[datetime.date], habit_list: HabitList):
# Habit List
for habit in active_habits:
with card():
# Truncated habit name
name(habit)
checkboxes(habit, days)
if settings.INDEX_SHOW_HABIT_COUNT:
IndexBadge(habit).classes(RIGHT_ITEM_CLASSES)


def index_page_ui(days: list[datetime.date], habits: HabitList):
Expand Down

0 comments on commit 3b570a7

Please sign in to comment.