NCIOCPL / ncids

NCI Design System
10 stars 5 forks source link

Automate `usa-site-alert` component id #563

Closed olitharp-nci closed 11 months ago

olitharp-nci commented 2 years ago

Issue description

The site alert component requires an ID for both collapse and close functionality. This ID can be generated automatically instead of requiring a user to add it correctly via HTML.

Make sure this is backwards compatible so that if someone does have an id set, it won't break.

ESTIMATE TBD

What's the expected change?

Slim variant

<section
  aria-label="Slim emergency site alert example"
  class="usa-site-alert usa-site-alert--nci-slim usa-site-alert--nci-emergency"
- id="site-alert-example1"
  >
  <div class="usa-alert">
    <div class="usa-alert__body">
      <div class="usa-alert__text">
        <strong>Short alert message.</strong> Additional context and followup information including <a class="usa-link" href="#">a link</a>.
      </div>
    </div>
  </div>
</section>

Standard variant

<section
    aria-label="Standard emergency site alert example"
    class="usa-site-alert usa-site-alert--nci-standard usa-site-alert--nci-emergency"
-   id="site-alert-example3"
  >
    <div class="usa-alert">
        <div class="usa-alert__body">
            <header class="usa-alert__nci-header">
                <h3 class="usa-alert__heading">COVID-19 resources.</h3>
            </header>
-           <div class="usa-alert__nci-content" id="gov-banner-default1">
+           <div class="usa-alert__nci-content">
                <ul class="usa-alert__nci-list">
                    <li><a class="usa-link" href="#">What people with cancer should know</a></li>
                    <li><a class="usa-link" href="#">Get the latest public health information from CDC</a></li>
                    <li><a class="usa-link" href="#"> Guidance for cancer researchers</a></li>
                    <li><a class="usa-link" href="#">Get the latest research information from NIH</a></li>
                </ul>
            </div>
        </div>
    </div>
</section>

What's the updated acceptance criteria?

Scenario: NCIDS Site Alert component will generate an id if it does not already exist
  Given the site alert component code exists on a page
    And the site alert HTML Element does not already contain an ID
  When  the component is created (NCISiteAlert.create(...);)
  Then  the component should generate a unique ID
    And attach the ID to the HTML Element

Tasks

olitharp-nci commented 2 years ago

@NCIOCPL/product This can be MVP 2