Comments (6)
I just closed PR #2301, because we're no longer convinced that it is a good idea to add additional layers to ui.card
to fix a layout inconsistency between NiceGUI and Quasar. Instead, I propose the following:
-
Change
ui.card
to mimic QCard more closely. It won't add padding and gaps anymore, and requires to useui.card_section
where padding is required. This is like the oldui.card().tight()
. For convenience, we can add QCard's style props as parameters:ui.card(*, square: bool = False, flat: bool = False, bordered: bool = False)
-
Introduce a new
ui.box
element which behaves like the oldui.card
. But instead of using QCard, it is simply aui.column
with optional shadow, border and/or rounded corners. Like the oldui.column
andui.card
it adds padding and gaps. Replicating QCard's style props the signature might look like this:ui.box(*, square: bool = False, flat: bool = False, bordered: bool = False)
Or we use more independent and maybe more intuitive parameter names like this:
ui.box(*, rounded: bool = True, shadow: bool = True, border: bool = False)
Even though this requires all users to change ui.card
to ui.box
when migrating to NiceGUI 2.0.0, this is a much cleaner solution with less caveats compared to the old ui.card
, which almost behaves like QCard, but leads to strange results when nesting bordered elements.
from nicegui.
Hi @ghbm-itk, this is an unfortunate consequence of how NiceGUI adds default padding to ui.card
, which Quasar doesn't. It has been discussed in #726 and #1295 (comment) and is documented here.
from nicegui.
Since the problem is so easily fixed by simply wrapping the element in another element, it seems like something should be possible to fix. I don't understand the backend of NiceGui well enough yet, but I will look into it at some point.
Could a simple hotfix be something like: "If parent is a card wrap this element." ?
from nicegui.
@ghbm-itk I don't think it's a good idea to automatically change the element hierarchy, because it would break certain assumptions (see #2040 for a discussion about a similar case).
I tried once again to undo Quasar's CSS magic - without success. But I found a way to wrap the card content in a separate div, so that it isn't affected by the Quasar's CSS; see PR #2301. What do you think?
from nicegui.
@falkoschindler Isn't that just q-card-section reinvented? When looking at the examples on quasar.dev it seems that all content in cards is wrapped in card sections:
<q-card>
<q-card-section>
<div class="text-h6">Our Changing Planet</div>
<div class="text-subtitle2">by John Doe</div>
</q-card-section>
</q-card>
from nicegui.
@ghbm-itk Sorry for the late reply. I think it's a bit different:
-
QCards usually don't have any padding. But you can add padding with QCardSections:
with ui.element('q-card'): ui.label('No padding.').classes('border') with ui.element('q-card'): with ui.element('q-card-section'): ui.label('Padding.').classes('border')
-
ui.card
comes with padding by default. But in order for Quasar not removing borders of nested elements, adding another container layer helps:with ui.card(): ui.label('Padding.').classes('border') with ui.card(): with ui.element(): ui.label('Padding.').classes('border')
from nicegui.
Related Issues (20)
- May I ask if it's possible to apply for a CVE for this project if a security vulnerability is found? HOT 7
- Quasar CSS flexbox layout classes don't work HOT 7
- Intrinsic high CPU usage HOT 7
- [AG Grid] Setting column to sortable doesn't work in a callback function HOT 4
- emoji favicons depend on python string length in a weird way HOT 1
- Docs: "Input element with date picker" - menu is closed when clicking "<" or ">" HOT 1
- ui.date doesn't not close the menu after picking the day HOT 6
- Select & Radio not working with On Air HOT 2
- del Client.instances[self.id] Key error HOT 3
- 'Tailwind' object has no attribute 'value' HOT 1
- Plotly chart changes position after updating the chart. HOT 10
- ⚠️ `ui.upload` File upload stops at 99.9% HOT 4
- 3D visualization not reliable HOT 15
- From 188c81b on some pages load extremely slowly HOT 9
- I use pyinstaller to generate .exe file find question, how to solve it?
- Setting ui.number min/max property is failing after version nicegui-1.4.19 HOT 1
- When executing the run_method , a KeyError error occurs. HOT 6
- Native mode [Windows] : Stay on top option
- Firefox cannot establish the websocket connection but other browsers and firefox private browsing can. HOT 8
- app.storage.user in unit tests throws error. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nicegui.