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

va-alert-sign-in: add new component #1424

Merged
merged 8 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions packages/storybook/stories/va-alert-sign-in.stories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import React from 'react';
import { getWebComponentDocs, propStructure, StoryDocs } from './wc-helpers';
import { VariantNames } from '../../web-components/src/components/va-alert-sign-in/VariantNames';

const alertSignInDocs = getWebComponentDocs('va-alert-sign-in');

export default {
title: 'Components/Alert - Sign-in',
id: 'components/va-alert-sign-in',
parameters: {
componentSubtitle: 'va-alert-sign-in web component',
docs: {
page: () => <StoryDocs storyDefault={Default} data={alertSignInDocs} />,
},
},
};

const defaultArgs = {
'variant': VariantNames.signInRequired,
'disable-analytics': true,
'visible': true,
'time-limit': null,
'no-sign-in-link': null,
'heading-level': null,
};

const SignInButton = () => <button>Sign In Button goes here</button>;
const IdMeSignInButton = () => (
<button>Sign In with ID.me Button goes here</button>
);
const IdMeVerifyButton = () => (
<button>Verify with ID.me Button goes here</button>
);
const LoginGovSignInButton = () => (
<button>Sign In with Login.gov Button goes here</button>
);
const LoginGovVerifyButton = () => (
<button>Verify with Login.gov Button goes here</button>
);

const SlotVariants = {
[VariantNames.signInRequired]: {
slotNames: ['SignInButton'],
buttons: [SignInButton],
},
[VariantNames.signInOptional]: {
slotNames: ['SignInButton'],
buttons: [SignInButton],
},
[VariantNames.signInEither]: {
slotNames: ['LoginGovSignInButton', 'IdMeSignInButton'],
buttons: [LoginGovSignInButton, IdMeSignInButton],
},
[VariantNames.verifyIdMe]: {
slotNames: ['IdMeVerifyButton'],
buttons: [IdMeVerifyButton],
},
[VariantNames.verifyLoginGov]: {
slotNames: ['LoginGovVerifyButton'],
buttons: [LoginGovVerifyButton],
},
};

const Template = ({
variant,
'disable-analytics': disableAnalytics,
visible,
'time-limit': timeLimit,
'no-sign-in-link': noSignInLink,
'heading-level': headingLevel,
}) => {
return (
<va-alert-sign-in
variant={variant}
disable-analytics={disableAnalytics}
visible={visible}
time-limit={timeLimit}
no-sign-in-link={noSignInLink}
heading-level={headingLevel}
>
{SlotVariants[variant].slotNames.map((name, i) => {
const ButtonToRender = SlotVariants[variant].buttons[i];
return (
<span key={i} slot={name}>
<ButtonToRender></ButtonToRender>
</span>
);
})}
</va-alert-sign-in>
);
};

export const Default = Template.bind(null);
Default.args = {
...defaultArgs,
};
Default.argTypes = propStructure(alertSignInDocs);

export const WithCustomHeadingLevel = Template.bind(null);
WithCustomHeadingLevel.args = {
...defaultArgs,
'heading-level': 3,
};

export const OptionalSignIn = Template.bind(null);
OptionalSignIn.args = {
...defaultArgs,
'variant': VariantNames.signInOptional,
'no-sign-in-link': 'https://example.com/',
'time-limit': '20 minutes',
};

export const VerifyWithIdMe = Template.bind(null);
VerifyWithIdMe.args = {
...defaultArgs,
variant: VariantNames.verifyIdMe,
};

export const VerifyWithLoginGov = Template.bind(null);
VerifyWithLoginGov.args = {
...defaultArgs,
variant: VariantNames.verifyLoginGov,
};

export const SignInWithAnotherAccount = Template.bind(null);
SignInWithAnotherAccount.args = {
...defaultArgs,
variant: VariantNames.signInEither,
};
81 changes: 81 additions & 0 deletions packages/web-components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,37 @@ export namespace Components {
*/
"trigger": string;
}
/**
* @componentName Alert - Sign In
* @maturityCategory caution
* @maturityLevel candidate
*/
interface VaAlertSignIn {
/**
* If `true`, doesn't fire the CustomEvent which can be used for analytics tracking.
*/
"disableAnalytics"?: boolean;
/**
* Header level for button wrapper. Must be between 1 and 6
*/
"headingLevel"?: number;
/**
* For the 'optional' variant, the link to the form to complete without signing in
*/
"noSignInLink"?: string;
/**
* For the 'optional' variant, how long the respondent has to submit their form
*/
"timeLimit"?: string;
/**
* Determines the text content and border/background color. Must be one of "signInRequired", "signInOptional", "signInEither", "verifyIdMe", or "verifyLoginGov".
*/
"variant"?: string;
/**
* If `true`, the alert will be visible.
*/
"visible"?: boolean;
}
/**
* @componentName Back to top
* @maturityCategory use
Expand Down Expand Up @@ -2118,6 +2149,17 @@ declare global {
prototype: HTMLVaAlertExpandableElement;
new (): HTMLVaAlertExpandableElement;
};
/**
* @componentName Alert - Sign In
* @maturityCategory caution
* @maturityLevel candidate
*/
interface HTMLVaAlertSignInElement extends Components.VaAlertSignIn, HTMLStencilElement {
}
var HTMLVaAlertSignInElement: {
prototype: HTMLVaAlertSignInElement;
new (): HTMLVaAlertSignInElement;
};
/**
* @componentName Back to top
* @maturityCategory use
Expand Down Expand Up @@ -3094,6 +3136,7 @@ declare global {
"va-additional-info": HTMLVaAdditionalInfoElement;
"va-alert": HTMLVaAlertElement;
"va-alert-expandable": HTMLVaAlertExpandableElement;
"va-alert-sign-in": HTMLVaAlertSignInElement;
"va-back-to-top": HTMLVaBackToTopElement;
"va-banner": HTMLVaBannerElement;
"va-breadcrumbs": HTMLVaBreadcrumbsElement;
Expand Down Expand Up @@ -3299,6 +3342,37 @@ declare namespace LocalJSX {
*/
"trigger": string;
}
/**
* @componentName Alert - Sign In
* @maturityCategory caution
* @maturityLevel candidate
*/
interface VaAlertSignIn {
/**
* If `true`, doesn't fire the CustomEvent which can be used for analytics tracking.
*/
"disableAnalytics"?: boolean;
/**
* Header level for button wrapper. Must be between 1 and 6
*/
"headingLevel"?: number;
/**
* For the 'optional' variant, the link to the form to complete without signing in
*/
"noSignInLink"?: string;
/**
* For the 'optional' variant, how long the respondent has to submit their form
*/
"timeLimit"?: string;
/**
* Determines the text content and border/background color. Must be one of "signInRequired", "signInOptional", "signInEither", "verifyIdMe", or "verifyLoginGov".
*/
"variant"?: string;
/**
* If `true`, the alert will be visible.
*/
"visible"?: boolean;
}
/**
* @componentName Back to top
* @maturityCategory use
Expand Down Expand Up @@ -5245,6 +5319,7 @@ declare namespace LocalJSX {
"va-additional-info": VaAdditionalInfo;
"va-alert": VaAlert;
"va-alert-expandable": VaAlertExpandable;
"va-alert-sign-in": VaAlertSignIn;
"va-back-to-top": VaBackToTop;
"va-banner": VaBanner;
"va-breadcrumbs": VaBreadcrumbs;
Expand Down Expand Up @@ -5328,6 +5403,12 @@ declare module "@stencil/core" {
* @maturityLevel candidate
*/
"va-alert-expandable": LocalJSX.VaAlertExpandable & JSXBase.HTMLAttributes<HTMLVaAlertExpandableElement>;
/**
* @componentName Alert - Sign In
* @maturityCategory caution
* @maturityLevel candidate
*/
"va-alert-sign-in": LocalJSX.VaAlertSignIn & JSXBase.HTMLAttributes<HTMLVaAlertSignInElement>;
/**
* @componentName Back to top
* @maturityCategory use
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export enum VariantNames {
/* eslint-disable i18next/no-literal-string */
signInRequired = 'signInRequired',
signInOptional = 'signInOptional',
verifyIdMe = 'verifyIdMe',
verifyLoginGov = 'verifyLoginGov',
signInEither = 'signInEither',
/* eslint-enable i18next/no-literal-string */
}
Loading
Loading