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

title: forces margins inconsistanly #349

Open
hipitihop opened this issue Nov 5, 2024 · 3 comments
Open

title: forces margins inconsistanly #349

hipitihop opened this issue Nov 5, 2024 · 3 comments
Assignees
Labels

Comments

@hipitihop
Copy link
Contributor

The title component forces top-margin and bottom-margin by default, not sure why, but it is also difficult/impossible to override as it uses !important

Default:
image

[[rc/title
   :level :level2
   :label "My Title"]

If I use :parts :wrapper to set top bottom margin, it is ignored.
If I use :style {:margin-bottom "0px" :margin-top "0px"} only the top takes.

I find 9/10 I give up on using title because the defaults don't suit the container and the overrides are as much effort as using normal rc/label and restyle with larger font etc.

@kimo-k
Copy link
Contributor

kimo-k commented Nov 6, 2024

I find this annoying too. It seems to throw off our fibonacci-based layout convention.

@dbarabashh
Copy link

Hey @kimo-k and @hipitihop !

I've been looking into the issue with title margins and I think I found solution that might work well. Idea is to move margin control from the span element to the wrapper component and make margins optional by default.

  1. Updated default margins to "0":
:or {margin-top "0" margin-bottom "0"}
  1. Moved margin styles to the wrapper component:
wrapper-style (merge
               (get-in parts [:wrapper :style])
               {:margin-top margin-top
                :margin-bottom margin-bottom})

This gives us three flexible ways to control margins:

  1. Direct props (simplest):
[title
 :level :level2
 :margin-top "1em"
 :margin-bottom "0.5em"
 :label "My Title"]
  1. Using :parts (more control):
[title
 :level :level2
 :parts {:wrapper {:style {:margin "2em 0"}}}
 :label "My Title"]
  1. No margins (clean):
[title
 :level :level2
 :label "My Title"]

What do you think? Is this the kind of flexibility we're looking for? Let me know if you'd like to see more examples or if you have any suggestions for improvement. Cheers

@kimo-k
Copy link
Contributor

kimo-k commented Jan 5, 2025

Sounds like a good direction. What are the implications of declaring a margin on the wrapper instead of the child?

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

No branches or pull requests

4 participants