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

Handle percent & auto line height value units #9

Open
MiguelFranken opened this issue Apr 17, 2024 · 0 comments
Open

Handle percent & auto line height value units #9

MiguelFranken opened this issue Apr 17, 2024 · 0 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@MiguelFranken
Copy link
Collaborator

MiguelFranken commented Apr 17, 2024

Currently only line heights with unit PIXELS can be generated in all three possible generation modes (inferred, arbitrary, variable). See details for the possible types here.

If the unit is percent we only allow generating in arbitrary mode. We should support the other two generation modes as well!

The unit could be "PIXELS" | "PERCENT" | "AUTO" and it should be possible to output utility values also for inference & tokens mode.

Information

Possible generation modes:
https://github.com/MiguelFranken/onyx/blob/a03827c40994cbe1accec8eb404095070b6982b7/packages/code/src/builder/types.ts#L50-L54

Relevant method to change: https://github.com/MiguelFranken/onyx/blob/bc8e6aa7b4db03ab8654bce0383de2fbbd3f19a3/packages/code/src/builder/inference/line-height.ts#L6-L23

Tailwind utility class to generate:
https://tailwindcss.com/docs/line-height

Unitless line height value:
https://developer.mozilla.org/en-US/docs/Web/CSS/line-height#number

Transform percent values to unitless-numbers

Input: Percent Line Height (e.g. 128%)

Step 1:
Transform 128% to Unitless Number.

Output:
1.28

Step 2 (Inference):
Get the nearest inferred value available in Tailwind.
Input: 1.28
Output: 1.25

Step 3 (Generate utility class):
leading-tight

Possible values:

leading-none	line-height: 1;
leading-tight	line-height: 1.25;
leading-snug	line-height: 1.375;
leading-normal	line-height: 1.5;
leading-relaxed	line-height: 1.625;
leading-loose	line-height: 2;
@MiguelFranken MiguelFranken self-assigned this Apr 17, 2024
@MiguelFranken MiguelFranken added bug Something isn't working good first issue Good for newcomers labels Apr 17, 2024
@MiguelFranken MiguelFranken moved this to Backlog in Onyx Board Apr 20, 2024
@MiguelFranken MiguelFranken moved this from Backlog to Ready in Onyx Board Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Status: Ready
Development

No branches or pull requests

2 participants