-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: introduce database content layout #713
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
b7cbb00
to
a833e51
Compare
a833e51
to
cba8e0a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initial review.
should the searchtable also be useable on other layouts (i.e. is database layout necessary)?
packages/components/src/templates/next/components/internal/SearchableTable/SearchableTable.tsx
Outdated
Show resolved
Hide resolved
packages/components/src/templates/next/components/internal/SearchableTable/SearchableTable.tsx
Outdated
Show resolved
Hide resolved
packages/components/src/templates/next/components/internal/SearchableTable/SearchableTable.tsx
Outdated
Show resolved
Hide resolved
// This is the maximum number of columns that the table can have | ||
// 10 was decided because at 1240px, each column will only have 124px which is | ||
// the minimum width for a column to be readable | ||
export const MAX_NUMBER_OF_COLUMNS = 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in mobile will still look weird right haha. Might as well set min-width on each cell. Can always enhance it (and our other tables?) with something like https://www.npmjs.com/package/react-table-column-resizer (or write our own/vendorize) to allow users to resize columns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm this one to discuss with @sehyunidaaa. I think letting users resize the columns will not happen, but whether to use min-width I need to check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we set min-width (e.g., 124px) on the cols, will a table with 10 cols overflow and hori scroll on w=1025px (desktop)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think with the borders likely will overflow, so maybe we can use a smaller number such that the min-width of all columns + borders is <= 1024px?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I don't think overflow is necessarily bad when you have 10 (!!) columns, because at that point your data table is so big, that it's more important for us to guarantee that the column texts are readable than trying to avoid overflow. I'd rather the table be scrollable than we try to squeeze 10 columns into {1024px - margins} which might break words at awkward places.
I guess no issue in setting a min-width on columns, but should we be setting a max-width on the entire table instead? So we let the columns resize depending on content but prevent the scroll being ridiculously long, like 2* of the screen width
packages/components/src/templates/next/components/internal/SearchableTable/getFilteredItems.ts
Outdated
Show resolved
Hide resolved
Datadog ReportBranch report: ✅ 0 Failed, 8 Passed, 1 Skipped, 7.98s Total Time |
@dcshzj sorry to bother you again! just fyi got some small items pending on chromatic, after you push again please let me know i'll approve chromatic |
019344a
to
fe5cb0a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first pass review! some questoins on my end but overall seems ok. what's the point of the sentinel =HYPERLINK(
? are we going to use it internally for github stored pages?
also, do we need an equivalent on studio for the layotu here?
packages/components/src/templates/next/components/internal/SearchableTable/CellContent.tsx
Show resolved
Hide resolved
|
||
const maxNoOfColumns = Math.min( | ||
headers.length, | ||
...items.map((row) => row.row.length), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if we have a case where the header length is shorter than the max row length? do we have to handle overflow? (i never check on local)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This checks every row and finds the minimum number of columns. So if we have header row with 6 columns, 1st row with 6 columns and 2nd row with 3 columns, the max we should display is 3.
Overflow is handled automatically via scroll.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah ok, so to double check what happens here - we only display 3 and there's a scrollbar allowing us to horizontally scroll and see the other 6? ok with this, i wanted to double check that we're not just removing the content
.../components/src/templates/next/components/internal/SearchableTable/SearchableTableClient.tsx
Show resolved
Hide resolved
.../components/src/templates/next/components/internal/SearchableTable/SearchableTableClient.tsx
Show resolved
Hide resolved
.../components/src/templates/next/components/internal/SearchableTable/SearchableTableClient.tsx
Show resolved
Hide resolved
.../components/src/templates/next/components/internal/SearchableTable/SearchableTableClient.tsx
Show resolved
Hide resolved
searchValue, | ||
}: GetFilteredItemsParams) => | ||
items | ||
.filter((item) => item.key.includes(searchValue.toLowerCase())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we want a case insensitive search, might as well lowercase the key!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm the key is lowercased in the server component so the client does lesser stuff: https://github.com/opengovsg/isomer/pull/713/files#diff-5c209342b9152356c25bfdfc004d41eeb44c795172426b1bc17569d3b0e31bdb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not very good to assume here, we should just lowercase if it's cheap to do so. i think the runtime here won't be anyting significant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm this is done as part of a performance improvement suggested here: #713 (comment)
I'm more inclined to reduce the work that the client does, especially since our users may have devices that are extremely slow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok! can add a comment on the studio side then, so people are aware of this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh hmm there's no studio equivalent here, so the input is fine but on build time the key is generated with the lowercase.
This is to support links. The intent is for people to create their table in Excel, export as CSV then upload to Studio in the future.
Nope, editing on Studio for this layout is deprioritised for now, cos quite complicated to implement. |
Updated in 79a1f81. |
Problem
Closes ISOM-1592.
Solution
Breaking Changes
Features:
Screenshots