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

Fixed the misalignment in number text of money type cell #4097

Conversation

sharath-1517
Copy link
Contributor

Fixes #4085

Technical details

  • I have added a isMoneyCell flag in the SteppedInputCell.svelte component to make sure that only money fields will get the font-variant-numeric: tabular-nums;` style.

Screenshots

  • Before:
    image

  • After (See the decimal values):

image

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the develop branch of the repository
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no
    visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@seancolsen seancolsen self-assigned this Jan 3, 2025
@seancolsen seancolsen added the pr-status: review A PR awaiting review label Jan 3, 2025
Copy link
Contributor

@seancolsen seancolsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @sharath-1517, but this is not going to be a clean approach. We should keep the SteppedInputCell component entirely decoupled from the concept of data types. Adding an isMoneyCell prop couples it tightly to that data type and introduces mess that would be tricky to disentangle later on.

It's worth mentioning that this cell-level code is already super messy. It really is begging for a refactor, but we're not prioritizing that at the moment.

Notice how money cells and number cells are right aligned instead of left aligned? We should follow the same pattern when setting this new CSS.

  1. Set the CSS within CellWrapper, and add a new prop to handle it. Name your prop in accordance with what is happening inside the component, not outside. So don't mention "money". I suggest a boolean prop named useTabularNumbers which defaults to false. Then a class with a similar name.

  2. Forward that prop up through SteppedInputCell.

  3. Set the prop to true within the respective components for Number, Money, Date, Date Time, Time, and Duration cell types.

@seancolsen seancolsen assigned sharath-1517 and unassigned seancolsen Jan 6, 2025
@seancolsen seancolsen added pr-status: revision A PR awaiting follow-up work from its author after review and removed pr-status: review A PR awaiting review labels Jan 6, 2025
@sharath-1517
Copy link
Contributor Author

@seancolsen I understand the issues very well and your other added information has made it really easier for me going ahead with this issue. I really appreciate your time and ideas. Thanks a lot!

@sharath-1517
Copy link
Contributor Author

Hey @seancolsen , I have added the guided changes. Requesting for a review. Thanks!

@zackkrida zackkrida requested a review from seancolsen January 6, 2025 20:49
@zackkrida zackkrida added pr-status: review A PR awaiting review and removed pr-status: revision A PR awaiting follow-up work from its author after review labels Jan 6, 2025
Copy link
Contributor

@seancolsen seancolsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed 4ec84e7 to properly handle Duration cells.

The code looks good to me now.

@seancolsen
Copy link
Contributor

I'm going to hold off on merging since I'm not actually able to reproduce this issue the way Zack was. For me, all numbers render equally spaced, even before this PR. I suspect that the difference in observations between me and Zack is due to our systems using different fonts. Mathesar uses system fonts, so different users will see the UI with different fonts. That behavior is an intentional design choice. But it makes it somewhat tricky here.

@zackkrida can you give this PR a whirl and see if it fixes the issue as you originally described it? If so, please merge.

@seancolsen seancolsen assigned zackkrida and unassigned seancolsen Jan 6, 2025
@zackkrida
Copy link
Contributor

Excellent, this indeed fixes the issue. Thank you @sharath-1517!

With the new CSS class disabled:

image

With it enabled:

Screenshot From 2025-01-06 18-06-44

In the font in use here, Canterell, the "1"s are a particularly good example of the change.

@zackkrida zackkrida added this pull request to the merge queue Jan 6, 2025
Merged via the queue into mathesar-foundation:develop with commit d0bae78 Jan 6, 2025
70 checks passed
@sharath-1517
Copy link
Contributor Author

Excellent, this indeed fixes the issue. Thank you @sharath-1517!

With the new CSS class disabled:

image

With it enabled:

Screenshot From 2025-01-06 18-06-44

In the font in use here, Canterell, the "1"s are a particularly good example of the change.

Thank you Zach!

@sharath-1517
Copy link
Contributor Author

I pushed 4ec84e7 to properly handle Duration cells.

The code looks good to me now.

Thanks Sean!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-status: review A PR awaiting review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use font-variant-numeric: tabular-nums; for known numeric columms
3 participants