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

Remove margin top on the input component if no label is provided in core_components.ex #5832

Open
NTurchi opened this issue Jun 4, 2024 · 0 comments

Comments

@NTurchi
Copy link

NTurchi commented Jun 4, 2024

Environment

  • Elixir version (elixir -v):
Erlang/OTP 25 [erts-13.2.2.6] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1]

Elixir 1.16.1 (compiled with Erlang/OTP 25)
  • Phoenix version (mix deps): 1.7.12
  • Operating system: MacOS

Actual behavior

Hello Phoenix Team 👋
This is a minor issue with the input component from the core_components.ex file (used in phx.gen.live)
A margin top is added by default for the spacing between the label and the input.

class={[
"mt-2 block w-full rounded-lg text-zinc-900 focus:ring-0 sm:text-sm sm:leading-6 min-h-[6rem]",
@errors == [] && "border-zinc-300 focus:border-zinc-400",
@errors != [] && "border-rose-400 focus:border-rose-400"
]}

However it is not removed if a label is not provided. Which causes alignment issue when combining the input component with other elements on our UI.

mt-2-top-screen

Of course this can be fixed easily by modifying the core_component in my project but I guess this can be a quick win improvement to update the core_components.ex directly in Phoenix. I can propose a PR if you think it's worth making a small update 🙏

Expected behavior

Avoid adding a margin to the input if a label is not provided to the input component.

Fix: one idea could be to put the mt-2 class behind a condition, e.g:

class={[ 
    "block w-full rounded-lg text-zinc-900 focus:ring-0 sm:text-sm sm:leading-6 min-h-[6rem]", 
    @errors == [] && "border-zinc-300 focus:border-zinc-400", 
    @errors != [] && "border-rose-400 focus:border-rose-400",
    # new condition
    label != nil && "mt-2",
]} 
@NTurchi NTurchi closed this as completed Jun 4, 2024
@NTurchi NTurchi reopened this Jun 4, 2024
@NTurchi NTurchi changed the title Remove margin top on the input component if no label is provided in core_component.ex Remove margin top on the input component if no label is provided in core_components.ex Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant