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

[COMP]: Add layout utilities #98

Open
andrewrubin opened this issue Jan 31, 2024 · 11 comments
Open

[COMP]: Add layout utilities #98

andrewrubin opened this issue Jan 31, 2024 · 11 comments
Assignees
Labels
COMP Tickets related to wethegit-components enhancement New feature or request good first issue Good for newcomers investigate This needs further investigation and is parked for now.

Comments

@andrewrubin
Copy link
Member

Even just a CSS file that gets added β€”Β I think it will be useful to have Sass helpers like @include full-absolute(4px) (yes I'm aware of inset πŸ˜› )

@andrewrubin andrewrubin added enhancement New feature or request good first issue Good for newcomers COMP Tickets related to wethegit-components labels Jan 31, 2024
@marlonmarcello
Copy link
Member

@andrewrubin can you give another example? Something that we definitely use?

@andrewrubin
Copy link
Member Author

No. No, I cannot πŸ˜ƒ

Any ideas? I'm happy to just add this specific helper, as needed, on projects.

@marlonmarcello
Copy link
Member

All good, let's leave this here and if something pops up we can come back to it.

@marlonmarcello marlonmarcello added the investigate This needs further investigation and is parked for now. label Feb 29, 2024
@andrewrubin
Copy link
Member Author

andrewrubin commented May 1, 2024

Some utilities I often find helpful are below. Should these be included in some kind of utility class stylesheet, or would we rather implement that on a per-project basis? These are, admittedly, pretty arbitrary.

Let me know your thoughts @marlonmarcello @rvno @NicholasLancey !

.block {
  display: block;
}

.relative {
  position: relative;
}

.fill {
  width: 100%;
}

.constrain {
  max-width: 100%;
}

.center {
  margin-inline: auto;
}

@NicholasLancey
Copy link
Contributor

I use pretty much all of those helpers frequently. I usually set up text alignment ones too, txt-center, txt-left and txt-right.

I feel it would be best to include these in some kind of utility stylesheet, purely because I see them so often in our codebases I just assume most projects already have them!

@liamegan
Copy link
Member

liamegan commented May 1, 2024 via email

@andrewrubin
Copy link
Member Author

Thanks for your input @NicholasLancey !
I agree, the text alignment ones are nice. Our Text component does have an align prop, but it's nice to be able to set that on a parent instead of on each text node.

Aside: .center { margin-inline: auto; } can be achieved with our existing spacing utility, so we could ditch that one from my "proposal".

@marlonmarcello
Copy link
Member

marlonmarcello commented May 1, 2024

I am not sure if @liamegan was joking but he does have a point. If I remember when doing research for this Tailwind could:

  1. prefix classes to avoid clashes
  2. restrict which category of utilities were available

We could use tailwind solely for these types of utilities, the ones that don't affect the visual parts of the website. Things like margin, padding, text alignment, display, overflow, etc, these are all just functional.

Should we start an RFC?

@marlonmarcello
Copy link
Member

@marlonmarcello
Copy link
Member

Let's chat some time, now that we've used this for a few projects and have a better understanding of our needs. My initial concern which was having to learn a new framework still holds true but it might have less weight.

@marlonmarcello
Copy link
Member

@andrewrubin in out slack chat you mentioned that we should just import the utility css modules and use them directly like so:

// components/my-component/my-component.tsx

import spacing from '@local/styles/spacing.module.scss

function Component {
  return <div className={spacing.margin2} />
}

I think this is a great idea and we should give it a shot. When you get a chance could explore that a bit more?

  • try to define a naming standard, prolly camelCase but maybe try others, who knows
  • because these will be imported in many places, please check if the bundlers actually just generate a single set of classnames or if they are created for every single instance that this is imported. you can check this by just inspecting the markup in the browser and comparing the classnames

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
COMP Tickets related to wethegit-components enhancement New feature or request good first issue Good for newcomers investigate This needs further investigation and is parked for now.
Projects
None yet
Development

No branches or pull requests

4 participants