-
Notifications
You must be signed in to change notification settings - Fork 55
feat: Base implementation for Grid #11
Comments
I started working on this and got a few questions for the first version: 1. Is this the complete API? It looks a bit limiting to have only these props (I extracted them in an interface): interface IGridProps {
as?: string
children?: ReactNode
className?: string
columns?: string | number
content?: ReactNode
rows?: string
} 2. Shouldn't we add a sub-component for children ( 3. Related to 2; how do we align items?
4. Children and content
|
Looking back, this is short sighted. If you have a grid with a fixed height, you very well may want to equally divide up that vertical space by passing a number of rows. Let's give the same API to rows as columns has.
Yes, let's save for a future PR.
Best practice is to never parse/loop over children. This is because they can be wrapped in HOCs making it difficult to work with as you don't know what component you might encounter or what features they support. We'll use the CSS grid syntax from the parent to position children. Once we get to fine grained positioning for one off children, we'll likely have a GridItem type of component. Similar to how SUIR has a Grid and Grid.Column/Grid.Row. |
Opened a PR for it, WIP #15 |
We need to ensure the grid renders correctly with the requirements here: #29 |
Feature Request
OP: @levithomason linked from react-old/issues/97
Grid
This API proposal is for creating a minimal base implementation of a Grid component. I propose this is done using CSS Grid syntax, respecting IE 11 shortcomings (no gap, no template areas).
Helpful resource: https://learncssgrid.com
API Proposal
columns (quantity)
A Grid can define an arbitrary number of columns of equal width.
columns (explicit)
A Grid can explicitly define columns and their sizes.
For now, this is simply using the
grid-template-columns
value syntax. Proposing we consider more useful abstractions later.rows (quantity)
Note, unlike the columns I'm not proposing a way of defining an arbitrary number of rows. Rows are created automatically when columns wrap. Therefore, it makes no sense to say a Grid will have X rows ahead of time.
It may prove useful to be able to say "assign this value to all rows", however, I'm leaving this out of the base implementation proposal.
rows (explicit)
A Grid can explicitly define the sizes of its rows.
For now, this is simply using the
grid-template-rows
value syntax. Proposing we consider more useful abstractions later.The text was updated successfully, but these errors were encountered: