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

Info Panel Container #67

Merged
merged 8 commits into from
Feb 11, 2025
Merged

Info Panel Container #67

merged 8 commits into from
Feb 11, 2025

Conversation

atweedie
Copy link
Collaborator

Description

Adds an initial version of an info panel container component for use within the map container grid.

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Snapshot test written to verify correct classes and children are rendered
  • Story written for the component and viewed in storybook
  • Developed in link with consuming project

Checklist:

  • I have read the CONTRIBUTING doc
  • I have performed a self-review of my own code
  • I have updated Storybook with relevant examples
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that the feature works
  • New and existing unit tests pass locally with my changes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would be curious to know how people feel about adding snapshot tests. I couldn't think of a cleaner way to test these container components as they are so simple and there's not really any 'functionality' to test.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I have used them in the past. They can be useful in cases like this. They become a frustration when the snapshots cover a large part of an application fail if anything changes but I don't think that's the case here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

On top of this, can you think of a way to verify that the different positions work?

Copy link
Collaborator Author

@atweedie atweedie Jan 24, 2025

Choose a reason for hiding this comment

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

Not really as it's purely achieved via CSS. My thinking is that this sort of thing should be verified with visual regression testing through storybook which would be a nice thing to have but we're not there yet.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I have used them in the past. They can be useful in cases like this. They become a frustration when the snapshots cover a large part of an application fail if anything changes but I don't think that's the case here.

import { ReactElement } from "react";
import styles from "./InfoPanelContainer.module.css";

type InfoPanelProps = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Position prop accepts any string but only a limited set values work. Should use a union type.

Also consider adding aria-label and role accessibility (although I'm not exactly sure what role should default to

type Position = 'topLeft' | 'topRight' | 'centerLeft' | 'centerRight' | 'bottomLeft' | 'bottomRight';
type InfoPanelProps = {
    children: ReactElement,
    position: Position,
    "aria-label": string,
    role?: string
}

export const InfoPanelContainer = ({
    children, 
    position = 'centerRight',
    "aria-label" = 'Info panel',
    role = 'complementary?, tooltip? etc'
}: InfoPanelProps) => (
    <div 
        className={`${styles.infoPanelContainer} ${styles[position]}`}
        role={role}
        aria-label={ariaLabel}
    >
        {children}
    </div>
);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Personally I don't think we should be applying any aria attributes to this as it is only a 'presentation' container. I don't think any role truly fits the use case of this element other than presentation (which is unnecessary on a div and also should not include an aria label ) The accessibility requirements would be purely down to the contents within the container.

All that being said, best practice here might be to use a Section or Aside tag instead of a div. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, that makes sense. I like the idea of using a Section or Aside tag.

Copy link
Collaborator

Choose a reason for hiding this comment

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

On top of this, can you think of a way to verify that the different positions work?


export const InfoPanelContainer = ({children, position='centerRight'}:InfoPanelProps) => (
<div className={`${styles.infoPanelContainer} ${styles[position]}`}>
<div>{children}</div>
Copy link
Collaborator

@JBurkinshaw JBurkinshaw Jan 24, 2025

Choose a reason for hiding this comment

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

Is the <div> element necessary here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope, removed.

flex-direction: column;
box-shadow: 0 3px 10px rgb(0 0 0 / 0.2);
border-radius: 8px;
z-index: 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is z-index relative to? How will this interact with other applications?

I'm not an expert on this but maybe there's more you could specify for the stacking context? isolation would be one example

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The idea for this component was that it would be used to create a semi-permanent card somewhere within the map container. This could be used a a permanent element or as a temporary one to be displayed after an event as it is currently being used in APEx.

Whilst not sticking exactly to the concept from https://mapuipatterns.com/info-panel/ this was the inspiration for this component.

align-self: center;
flex-direction: column;
box-shadow: 0 3px 10px rgb(0 0 0 / 0.2);
border-radius: 8px;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use a border radius from theme.css? I added --border-radius-input in this datepicker PR but it may not be the best name/most flexible approach

Copy link
Collaborator Author

@atweedie atweedie Jan 24, 2025

Choose a reason for hiding this comment

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

Good shout. I had intended to use this.

@atweedie atweedie merged commit 9e83acd into main Feb 11, 2025
1 check passed
@atweedie atweedie deleted the popover branch February 11, 2025 09:10
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