Skip to content

Commit

Permalink
Refine responsive layout
Browse files Browse the repository at this point in the history
  • Loading branch information
daya0576 committed Feb 1, 2025
1 parent 1fa84cd commit 428a77f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions Dockerfile.nobuildkit.arm32
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ RUN rm -rf "$NICEGUI_LIB_PATH/vanilla-jsoneditor/"


FROM python-base AS production
EXPOSE 8080
COPY --from=builder-base $PYSETUP_PATH $PYSETUP_PATH
WORKDIR /app
COPY start.sh .
Expand Down
2 changes: 1 addition & 1 deletion beaverhabits/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Settings(BaseSettings):
ENABLE_DESKTOP_ALGIN_CENTER: bool = True
INDEX_SHOW_HABIT_COUNT: bool = False

INDEX_DAYS_COUNT: int = 8
INDEX_DAYS_COUNT: int = 10

def is_dev(self):
return self.ENV == "dev"
Expand Down
2 changes: 1 addition & 1 deletion beaverhabits/frontend/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async def note_tick(habit: Habit, day: datetime.date):
return

await habit.tick(day, yes, text)
logger.info(f"Habit ticked: {day} True, note: {text}")
logger.info(f"Habit ticked: {day} {yes}, note: {text}")


async def habit_tick(habit: Habit, day: datetime.date, value: bool):
Expand Down
1 change: 1 addition & 0 deletions beaverhabits/frontend/css.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Solve the problem of the checkbox hover effect hide by other checkboxes
# https://github.com/zauberzeug/nicegui/blob/b4bc24bae3d965e0b58e21d9026ec66ba28ae64d/nicegui/static/quasar.css#L1087

CHECK_BOX_CSS = """
body.desktop .q-checkbox--dense:not(.disabled):hover {
z-index: 10;
Expand Down
21 changes: 17 additions & 4 deletions beaverhabits/frontend/index_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

HABIT_LIST_RECORD_COUNT = settings.INDEX_DAYS_COUNT

LEFT_ITEM_CLASSES = "w-32 lg:w-36 truncate self-center"
LEFT_ITEM_CLASSES = "min-w-[110px] truncate self-center"
RIGHT_ITEM_CLASSES = "w-10 self-center"


Expand All @@ -34,7 +34,7 @@ def day_headers(days: list[datetime.date]):

@contextmanager
def row():
with ui.row().classes("pl-4 pr-0 py-0").classes(f"no-wrap gap-0"):
with ui.row().classes("pl-4 pr-1 py-0").classes("no-wrap gap-0"):
yield


Expand All @@ -50,9 +50,22 @@ def flex(height: int):
# Responsive flex container
with ui.element("div") as f:
# Auto hide flex items when it overflows the flex parent
f.classes("flex flex-row-reverse w-full justify-evenly")
f.classes("flex flex-row-reverse justify-evenly")
# Auto ajust gap with screen size
f.classes("gap-x-0.5 lg:gap-x-1")
f.classes(
"gap-x-0"
"md:gap-x-[6px] "
"lg:gap-x-[8px] "
# "xl:gap-x-[8px] "
# ...
)
f.classes(
f"max-w-[{40*6-1}px] "
f"md:max-w-[{40*7 + (7-1)*6}px] "
f"lg:max-w-[{40*10 + (10-1)*8}px] "
# f"xl:max-w-[{40*14 + 10*(14-1)*8}px] "
# ...
)
# Auto hide overflowed items
f.classes(f"overflow-hidden h-{height}")
yield f
Expand Down

0 comments on commit 428a77f

Please sign in to comment.