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

Initial build of service-list web component #1475

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

bellepx0
Copy link
Contributor

@bellepx0 bellepx0 commented Jan 31, 2025

Chromatic

https://create-va-service-list-component--65a6e2ed2314f7b8f98609d8.chromatic.com


Configuring this pull request

  • Link to any related issues in the description so they can be cross-referenced.
  • Add the appropriate version patch label (major, minor, patch, or ignore-for-release).
    • See How to choose a version number for guidance.
    • Use ignore-for-release if files haven't been changed in a component library package. (ie. only Storybook files)
  • DST Only: Increment the /packages/core version number if this will be the last PR merged before a release.
  • Complete all sections below.
  • Delete this section once complete

Description

Closes #295

Summary

  • Added new service-list web component
  • Added Storybook file
  • Added e2e test for component

QA Checklist

  • Component maintains 1:1 parity with design mocks
  • Text is consistent with what's been provided in the mocks
  • Component behaves as expected across breakpoints
  • Accessibility expert has signed off on code changes (if applicable. If not applicable provide reason why)
  • Designer has signed off on changes (if applicable. If not applicable provide reason why)
  • Tab order and focus state work as expected
  • Changes have been tested against screen readers (if applicable. If not applicable provide reason why)
  • New components are covered by e2e tests; updates to existing components are covered by existing test suite
  • Changes have been tested in vets-website using Verdaccio (if applicable. If not applicable provide reason why)

Screenshots

Screenshot 2025-01-31 at 11 07 24 AM

Acceptance criteria

  • QA checklist has been completed
  • Screenshots have been attached that cover desktop and mobile screens

Definition of done

  • Documentation has been updated, if applicable
  • A link has been provided to the originating GitHub issue (or connected to it via ZenHub)

Copy link
Contributor

@adamwhitlock1 adamwhitlock1 left a comment

Choose a reason for hiding this comment

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

I'm still working on getting this working locally as I'm having environment / node-gyp issues. I've added some comments though from my first read through of the code.

min-width: 40px !important;
max-width: 40px !important;
color: #ffffff !important;
background-color: #162e51 !important;
Copy link
Contributor

Choose a reason for hiding this comment

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

question: How do we make the background color dynamic? Looks like the designs have several different background colors shown for different icons.

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 added the icon prop to the class so we can define the background colors for each icon directly in the SCSS file. There might be an alternative approach like dynamically setting the background color inline using a prop such as vads-color-hub-life-insurance, with life-insurance being the passed prop. But I’m keeping it simple for now and we can revisit and adjust the implementation later if needed when integrating this into vets-website

<a href="/">
<div class="header">
<slot name="icon">
<va-icon class="icon" size={3} icon={icon}></va-icon>
Copy link
Contributor

Choose a reason for hiding this comment

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

since the icon is optional, we will need a way to not render that here if the icon identifier isn't passed in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

shadow: true,
})
export class VaServiceList {
@Prop() serviceDetails: any;
Copy link
Contributor

Choose a reason for hiding this comment

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

we should get a type created here for the serviceDetails so that it isn't using any

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created an interface for ServiceDetails and for ServiceAction as well to avoid using any

try {
this.parsedServiceDetails = typeof newValue === 'string' ? JSON.parse(newValue) : newValue;
} catch (error) {
console.error('Error parsing serviceDetails:', error);
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a consoleDevError that might be worth using here instead of console.error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

</li>
));

const actionNeeded = serviceStatus === 'Eligible';
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 not sure about this check here. Would it be more appropriate to instead check if parsedAction has href and text to determine if actionNeeded is truthy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes that would be better. Changed the line to const actionNeeded = parsedAction?.href && parsedAction?.text

<va-icon class="icon" size={3} icon={icon}></va-icon>
</slot>
<slot name="service-name">
<h3 class="service-name">{serviceName}</h3>
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 heading level be dynamic? My guess is that an H3 may not work in every scenario, and we should be able to configure this via a serviceNameHeadingLevel prop or similar naming. Creating it with a default level of 3 would also probably be a good default then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@adamwhitlock1
Copy link
Contributor

Last thing from reviewing this initial work:

I think all the slots should be removed. Having named slots means that every slot's content can be replaced by passing in a slot element as a child to the component, which would leave the door open for any markup to be placed in this component.

@bellepx0
Copy link
Contributor Author

bellepx0 commented Feb 4, 2025

Last thing from reviewing this initial work:

I think all the slots should be removed. Having named slots means that every slot's content can be replaced by passing in a slot element as a child to the component, which would leave the door open for any markup to be placed in this component.

Makes sense. I removed all the slots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor For a minor Semantic Version change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Initial build of Service List web component
2 participants