refactor: extract generic EntityTableList component#529
Conversation
…refactor/extract-entity-table-list
|
Two small things worth addressing: CSS variable in a generic component
|
|
Thank you for the feedback. I implemented the following changes.
|
arturasmckwcz
left a comment
There was a problem hiding this comment.
LGTM
pls check comments and address if you recon they are to the point
| @@ -0,0 +1 @@ | |||
| export type ViewMode = "cards" | "list" | "map"; | |||
There was a problem hiding this comment.
here I'd suggest to use enum:
export enum ViewMode {
LIST = "list",
CARDS = "cards",
MAP = "map",
};
There was a problem hiding this comment.
Done I converted ViewMode to an enum
| const router = useRouter(); | ||
| const tabs = [t("dashboard.volunteers.tabs.tab1"), t("dashboard.volunteers.tabs.tab2")]; | ||
|
|
||
| const viewMode: ViewMode = selectedTabIndex === 0 ? "list" : "cards"; |
There was a problem hiding this comment.
this is totally okay for 2 tabs, but I'd define mapping object, in this case just an array: [...Object.values(ViewMode)][selectedTabIndex]
ViewMode has to be an enum in such a case of course.
There was a problem hiding this comment.
or you may list values in an order you need instead of using Object.values()
There was a problem hiding this comment.
and no need for spreading as Object.values() creates a new array anyway, so it'd look: Object.values(ViewMode)[selectedTabIndex]
There was a problem hiding this comment.
Done , I used Object.values(ViewMode)[selectedTabIndex].
Also updated VolunteerListController to use ViewMode.LIST instead of the string literal.
…refactor/extract-entity-table-list
…refactor/extract-entity-table-list
2b84b00 to
8f3b120
Compare
Description
Extracts a generic
EntityTableList<T>component toDashboard/common/EntityTableList/so opportunities (#477) and agents (#478) list views can reuse it instead of duplicating the table/header/pagination boilerplateAlso:
selectedTabIndexprop onVolunteerListControllerwithviewMode: ViewMode, controller no longer knows about tab indicesVOLUNTEER_COL_WIDTHSas single source of truth for column widthsLayout note: With filters open the filter panel overflows off screen (table takes full width). Tried
flex: 1on the container so filters sit side by side but some columns get clipped and also tried an overlay approach neither is clean. Figma has no spec for this state. What's the preferred behavior?Related Issues
Closes #526 Part of #441
Changes
EntityTableList<T>toDashboard/common/EntityTableList/ViewModetype toDashboard/common/types.tsvolunteerTableColumns.tswithcreateVolunteerTableColumns(t)VolunteerTableListto useEntityTableListselectedTabIndexwithviewMode: ViewModeonVolunteerListControllerScreenshots / Demos
If UI-related, add before/after or GIFs.
Checklist