department-of-veterans-affairs / va.gov-team

Public resources for building on and in support of VA.gov. Visit complete Knowledge Hub:
https://depo-platform-documentation.scrollhelp.site/index.html
275 stars 194 forks source link

Migrate 21-526EZ checkboxes from fields to patterns #82294

Open zack opened 2 weeks ago

zack commented 2 weeks ago

In #76663 all of the checkboxes in 21-526EZ were migrated from v1 to v3 components. The v3 components were implemented using fields, but platform would prefer that they are implemented using patterns.

A field looks like this:

export const uiSchema = {
  'view:hasAlternateName': {
    'ui:title': 'Have you served under a different name?',
    'ui:widget': 'yesNo',
  }
}

export const schema = {
  type: 'object',
  properties: {
    'view:hasAlternateName': {
      type: 'boolean',
      properties: {},
    },
  },
};

A pattern looks like this:

import { yesNoUI, yesNoSchema } from 'platform/forms-system/src/js/web-component-patterns';
export const uiSchema = {
  'view:hasAlternateName': yesNoUI({
    title: 'Have you served under a different name?',
  })
}

export const schema = {
  type: 'object',
  properties: {
    'view:hasAlternateName': yesNoSchema,
  },
};

Relevant Documentation

Fields and patterns: https://depo-platform-documentation.scrollhelp.site/developer-docs/va-forms-library-web-component-fields-and-patterns

How to use patterns: https://depo-platform-documentation.scrollhelp.site/developer-docs/how-to-use-web-component-patterns

How to use fields: https://depo-platform-documentation.scrollhelp.site/developer-docs/how-to-use-web-component-fields