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

Waitp 1231 base matrix component #4707

Merged
merged 26 commits into from
Jul 11, 2023

Conversation

alexd-bes
Copy link
Contributor

@alexd-bes alexd-bes commented Jul 6, 2023

Issue WAITP-1231: Base UI component for matrix table

Changes:

  • Created reusable matrix component in ui-components
  • Added stories
  • Exposed matrix-related types from types package

Note: column groups are not implemented as yet, that will be in a separate PR

Screenshots:

Basic matrix

Screenshot 2023-07-06 at 4 36 56 pm

Nested with dots

Screenshot 2023-07-06 at 4 37 47 pm

Nested with basic data

Screenshot 2023-07-06 at 4 38 39 pm

Modal with data, shown on click of cell

Screenshot 2023-07-06 at 4 38 09 pm


const MatrixTable = styled.table`
border-collapse: collapse;
border: 1px solid ${({ theme }) => hexToRgba(theme.palette.text.primary, 0.2)};
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm keen to remove the hexToRgba function in favour of just using hex colors with opacity. So for example we should just be able to do ${theme.palette.text.primary}33 to get the same result, right?.
https://www.w3schools.com/cssref/css_colors_legal.php

Comment on lines 71 to 79
value={{
presentationOptions,
columns,
rows,
startColumn,
maxColumns,
expandedRows,
enlargedCell,
}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think there is any need to wrap this context value in a useMemo to optimise performance?

${({ theme }) =>
theme.palette.background.default === 'transparent'
? 'transparent'
: hexToRgba(theme.palette.background.default, 0.8)};
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
: hexToRgba(theme.palette.background.default, 0.8)};
: `${theme.palette.background.default}cc`;

const updateMaxColumns = () => {
if (!tableEl || !tableEl?.current || !tableEl?.current?.offsetWidth) return;
const { offsetWidth } = tableEl?.current;
// 200px is the max width of a column that we want to show
Copy link
Contributor

Choose a reason for hiding this comment

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

nice comment


type RowTitle = MatrixRowType['title'];

const defaultContextValue = {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is really nice. I think that useReducer and context are a great choice here and it organises all these fiddly interactions really nicely.

*/

export { Matrix } from './Matrix';
export * from './utils';
Copy link
Contributor

Choose a reason for hiding this comment

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

Do the utils need to be exported? I can't see them used anywhere else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mainly did this in case of using them in tupaia-web but I can remove until that comes up

Copy link
Contributor

@tcaiger tcaiger left a comment

Choose a reason for hiding this comment

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

Looks so good. Nice work handling all that complexity. I just have one requested change about removing the rgb util

@alexd-bes alexd-bes requested a review from tcaiger July 11, 2023 00:14
Copy link
Contributor

@tcaiger tcaiger left a comment

Choose a reason for hiding this comment

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

Nice!

* Working legend, grouped columns

* Apply location values

* Tidy up

* Styled column groups

* Tiy up files

* Add in hidden column titles

* Update hidden column title and config types

* Generate types

* Move the buttons

* WAITP-1222: Marker layer (#4686)

* setup map entites

* wip

* wip

* re organise project view

* mobile search layout

* polygon layer

* map animation

* fix mini map

* Update Dashboard.tsx

* merging

* map overlay data

* add Map overlays feature folder

* useEntitiesWithLocation

* typescript

* remove test code

* Update InteractivePolygon.tsx

* set up

* fix api

* marker layer

* Update types.d.ts

* update map layout

* wip map overlays

* revert map control layout

* Update useEntities.ts

* copy lesmis

* wip

* Update MapOverlayList.tsx

* default map overlay

* radius overlays

* navigate to dashboard

* fix scroll

* measure level

* refactor marker layer

* refactor useDefaultMapOverlay

* types

* useEntitiesByMeasureLevel

* Update MapOverlaysRoute.ts

* fix active entity

* Update MarkerLayer.tsx

* add comments

* Update processMeasureData.ts

* refactor useDefaultMapOverlay

* Fix merge conflicts

* Fix conflict errors

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>
@alexd-bes alexd-bes merged commit d6943ec into epic-frontend-rewrite Jul 11, 2023
@alexd-bes alexd-bes deleted the waitp-1231-base-matrix-component branch July 11, 2023 03:15
tcaiger added a commit that referenced this pull request Jul 12, 2023
* WAITP-1231 Working table

* WIP

* Update Matrix.tsx

* Fix linting errors

* convert to use context

* Update hooks

* Fix issues

* Reorganise files

* reorganise context

* Working table

* Remove enlarged cell modal file

* Working modal

* Tidy up

* Update MatrixCell.tsx

* Tidy up hover

* Add cell handling for markdown

* fix types

* WAITP-1231 fixes

* Delete types.d.ts

* Update index.ts

* Fix type error

* Waitp 1231 base matrix part 2 (#4714)

* Working legend, grouped columns

* Apply location values

* Tidy up

* Styled column groups

* Tiy up files

* Add in hidden column titles

* Update hidden column title and config types

* Generate types

* Move the buttons

* WAITP-1222: Marker layer (#4686)

* setup map entites

* wip

* wip

* re organise project view

* mobile search layout

* polygon layer

* map animation

* fix mini map

* Update Dashboard.tsx

* merging

* map overlay data

* add Map overlays feature folder

* useEntitiesWithLocation

* typescript

* remove test code

* Update InteractivePolygon.tsx

* set up

* fix api

* marker layer

* Update types.d.ts

* update map layout

* wip map overlays

* revert map control layout

* Update useEntities.ts

* copy lesmis

* wip

* Update MapOverlayList.tsx

* default map overlay

* radius overlays

* navigate to dashboard

* fix scroll

* measure level

* refactor marker layer

* refactor useDefaultMapOverlay

* types

* useEntitiesByMeasureLevel

* Update MapOverlaysRoute.ts

* fix active entity

* Update MarkerLayer.tsx

* add comments

* Update processMeasureData.ts

* refactor useDefaultMapOverlay

* Fix merge conflicts

* Fix conflict errors

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>
tcaiger added a commit that referenced this pull request Jul 12, 2023
* WAITP-1231 Working table

* WIP

* Update Matrix.tsx

* Fix linting errors

* convert to use context

* Update hooks

* Fix issues

* Reorganise files

* reorganise context

* Working table

* Remove enlarged cell modal file

* Working modal

* Tidy up

* Update MatrixCell.tsx

* Tidy up hover

* Add cell handling for markdown

* fix types

* WAITP-1231 fixes

* Delete types.d.ts

* Update index.ts

* Fix type error

* Waitp 1231 base matrix part 2 (#4714)

* Working legend, grouped columns

* Apply location values

* Tidy up

* Styled column groups

* Tiy up files

* Add in hidden column titles

* Update hidden column title and config types

* Generate types

* Move the buttons

* WAITP-1222: Marker layer (#4686)

* setup map entites

* wip

* wip

* re organise project view

* mobile search layout

* polygon layer

* map animation

* fix mini map

* Update Dashboard.tsx

* merging

* map overlay data

* add Map overlays feature folder

* useEntitiesWithLocation

* typescript

* remove test code

* Update InteractivePolygon.tsx

* set up

* fix api

* marker layer

* Update types.d.ts

* update map layout

* wip map overlays

* revert map control layout

* Update useEntities.ts

* copy lesmis

* wip

* Update MapOverlayList.tsx

* default map overlay

* radius overlays

* navigate to dashboard

* fix scroll

* measure level

* refactor marker layer

* refactor useDefaultMapOverlay

* types

* useEntitiesByMeasureLevel

* Update MapOverlaysRoute.ts

* fix active entity

* Update MarkerLayer.tsx

* add comments

* Update processMeasureData.ts

* refactor useDefaultMapOverlay

* Fix merge conflicts

* Fix conflict errors

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>

---------

Co-authored-by: Tom Caiger <caigertom@gmail.com>
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