frontend icon indicating copy to clipboard operation
frontend copied to clipboard

Fix button card font size on mobile

Open Nezz opened this issue 2 years ago • 5 comments

Proposed change

The button card defines its own font size in rem, which results in style inconsistencies. While it might look correct on desktop:

image

The font size is too large on mobile. For example on iOS:

image

By dropping the font size override, the element will use the font size that fits on all platforms and is already used by other elements:

image

Type of change

  • [ ] Dependency upgrade
  • [x] Bugfix (non-breaking change which fixes an issue)
  • [ ] New feature (thank you!)
  • [ ] Breaking change (fix/feature causing existing functionality to break)
  • [ ] Code quality improvements to existing code or addition of tests

Example configuration

square: true
columns: 5
type: grid
cards:
  - show_name: true
    show_icon: true
    type: button
    tap_action:
      action: toggle
    entity: <entity with a reasonably long name>

Additional information

Checklist

  • [x] The code change is tested and works locally.
  • [x] There is no commented out code in this PR.
  • [ ] Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

Nezz avatar Dec 10 '22 20:12 Nezz

Hi Nezz

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

home-assistant[bot] avatar Dec 10 '22 20:12 home-assistant[bot]

What is your font size setting on your phone?

bramkragten avatar Dec 14 '22 09:12 bramkragten

It's the default setting (4/7) on the iPhone 14 Pro.

Nezz avatar Dec 14 '22 12:12 Nezz

Are you using a theme or other custom things?

I'm not able to reproduce this issue, furthermore, because we have set a fixed font size on the html element (which makes rem a bit useless, but we should still use it someday) it should not matter what your settings are...

Anyway, we should not change the styling everywhere because it is not correct on 1 device.

bramkragten avatar Dec 14 '22 15:12 bramkragten

Try this:

type: grid
columns: 5
square: true
cards:
  - show_name: true
    show_icon: true
    type: button
    entity: scene.living_room_afternoon
    name: Afternoon

I'm using the stock dashboard without themes. The issue happens for me both in the app and Safari. I'd assume that it also affects Android phones. I'm also able to reproduce by increasing the zoom in my desktop browser to 150%.

Is the button designed to just have a very large text and therefore using 5 columns with more than 6 characters on each is just too much?

Nezz avatar Dec 14 '22 16:12 Nezz

@bramkragten Do you think we can come to a compromise on this?

Nezz avatar Jan 11 '23 09:01 Nezz

Can we give it a none rem size, so that it stays the same on all devices and is fixed for Safari?

bramkragten avatar Jan 23 '23 20:01 bramkragten

Sure, I updated it to 16.8 pixels, which matches the 14px rem size on desktop:

Nezz avatar Jan 23 '23 23:01 Nezz