Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid shadows and borders of nested cards being removed #2301

Closed
wants to merge 3 commits into from

Conversation

falkoschindler
Copy link
Contributor

This PR tries to avoid the confusion discussed in #726, #1295, #2265, where child elements of ui.card loose shadow and borders. This happens due to Quasar's CSS definitions, which are optimized for "tight" cards. NiceGUI adds some padding and gap by default, so shadow and borders seem to be missing for no obvious reason.

Unfortunately we can't undo Quasar's CSS setting. But I found a way to make them ineffective by inserting another div layer, catching Quasar's CSS setting, while the actual card content isn't affected.

I tested with the following scenarios:

with ui.card().classes('bg-blue-100'):
    with ui.card().classes('bg-green-100'):
        ui.label('Hello world!')

with ui.card().classes('no-shadow border-[1px]'):
    ui.label('See, no shadow!')

with ui.card().tight():
    ui.image('https://picsum.photos/id/684/640/360')
    with ui.card_section():
        ui.label('Lorem ipsum dolor sit amet, consectetur adipiscing elit, ...')

with ui.card():
    ui.table(
        [{'name': 'age', 'label': 'Age', 'field': 'age'}],
        [{'age': '16'}, {'age': '18'}, {'age': '21'}],
    ).props('flat bordered')
Screenshot 2024-01-06 at 14 37 20

Only when working with "tight" cards, the result is suboptimal. But I guess it's more intuitive to remove unwanted borders in this case than to wonder why they magically disappear.

with ui.card().tight():
    with ui.card().classes('border'):
        ui.label('Hello world!')
    with ui.card().classes('border'):
        ui.label('Hello world!')
Screenshot 2024-01-06 at 14 37 37

@falkoschindler falkoschindler linked an issue Jan 6, 2024 that may be closed by this pull request
@falkoschindler
Copy link
Contributor Author

falkoschindler commented Jan 6, 2024

I wonder if we should wait for the next major release, because we change the card style in certain cases and might break custom CSS rules.

In order not to merge onto main before clarifying when to release, I created and targeted a new "v2.0" branch.

@falkoschindler falkoschindler added this to the 2.0.0 milestone Jan 6, 2024
@falkoschindler falkoschindler added the enhancement New feature or request label Jan 6, 2024
@falkoschindler falkoschindler changed the base branch from main to v2.0 January 6, 2024 13:49
@falkoschindler
Copy link
Contributor Author

I'll close this PR, because we don't think that this is a good solution. Making the DOM more complex just to fix a layout inconsistency between NiceGUI and Quasar... I have a better idea, which I'll outline over at #2265.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nesting cards merges the elements
2 participants