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

Put card list grid items in rows #122

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

adebroux
Copy link
Contributor

@adebroux adebroux commented Jun 16, 2023

Problem

Card lists set to grid layout in responsive apps would have their height automatically collapse when they were selected in the editor.

https://trello.com/1/cards/645d32b21deee39c9c1d0441/attachments/645d35fac46e4d60cda83fb2/download/screencast_2023-05-11_22-35-32.mp4

Solution

Give the grid layout some structure, like we do with the masonry layout. Instead of just having a list of items, create rows for those items.

Additional Notes

There's still a problem where when you change the screen size or resize the component, the height of the items changes, but the bounding box for the card list component doesn't update until you de-select and re-select the component. This is a pre-existing issue with the card list in masonry layout, as well as the image list.
There's also a pre-existing issue with the card list in multi-column grid layout where it will flicker between showing 1 and 2 columns. We have a card for this already in the backlog.

@adebroux adebroux requested a review from a team June 16, 2023 22:07
@adebroux adebroux self-assigned this Jun 16, 2023
@adebroux
Copy link
Contributor Author

Copy link
Contributor

@michael-adalo michael-adalo left a comment

Choose a reason for hiding this comment

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

2 nitpicks, 1 change (just minor related to React key attributes), otherwise lookin' good!
🙌

Comment on lines 69 to 71
let columnCount = this.getColumnCount()
let count = Math.ceil(items.length / columnCount)
let rows = []
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: it should be possible to declare each of these as const, including rows.

{rows.map((row, i) => (
<View key={i} style={styles.row}>
{row.map((itm) => (
<View style={columnWidth}>
Copy link
Contributor

Choose a reason for hiding this comment

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

should this <View> also have a key attribute as it's directly within the .map()? Looking at the previous code, I see renderCell() includes a key attribute that probably isn't effective anymore.

let { fullWidth } = this.state
let width = fullWidth / columnCount - 8
const rows = this.getRows(items)
const columnWidth = { width: `${100 / columnCount}%` }
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: would it be worth calling this something like cellContainerStyles, or something similar, since the object could potentially contain any number of styles?
Alternatively, setting it directly on the <View> would also be fine.

@@ -420,8 +445,6 @@ class Cell extends Component {
editor,
} = this.props

let mediaPosition = media && media.position
Copy link
Contributor

Choose a reason for hiding this comment

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

image

@adebroux adebroux requested a review from michael-adalo June 20, 2023 14:31
Copy link
Contributor

@michael-adalo michael-adalo left a comment

Choose a reason for hiding this comment

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

✅ LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants