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

feat: Alerts refactor - create new Alert component for admin/FormBuilder #2446

Merged
merged 39 commits into from
Aug 4, 2023

Conversation

dsamojlenko
Copy link
Member

@dsamojlenko dsamojlenko commented Jul 25, 2023

Summary | Résumé

Create a new Alert component for use on the Admin/FormBuilder side of the app. To replace the current globals/Alert.tsx and globals/Attention/Attention.tsx components.

Includes extensive set of Cypress Component tests that serve as a good reference for how to use the Alert component.

Intention is to streamline all Admin/FormBuilder Alerts to line up with the figma designs and create a flexible and customizable component that can be used for each of the different alert styles unique to the Admin/FormBuilder section.

Usage

Simple Alert - includes default icon (see tests)

<Alert.Success title="This is a title" body="This is a body" />
<Alert.Warning title="This is a title" body="This is a body" />
<Alert.Info title="This is a title" body="This is a body" />
<Alert.Danger title="This is a title" body="This is a body" />
image

Custom icon

<Alert.Success
    title="This is a title"
    body="This is a body"
    icon={<CircleCheckIcon className="mr-1 h-12 w-12" />}
/>

No icon

<Alert.Warning title="This is a title" body="This is a body" icon={false} />
image

Dismissible - includes onDismiss action that removes the alert

<Alert.Success dismissible title="This is a title" body="This is a body" />
image

Dismissible - custom onDismiss action

<Alert.Success
    dismissible
    onDismiss={onDismissHandler}
    title="This is a title"
    body="This is a body"
/>

Focussable

<Alert.Success focussable title="This is a title" body="This is a body" />

Complex alerts

Alerts are highly customizable by providing children components for Icon, Title, and Body

<Alert.Warning title="This is a title" body="This is a body">
    <Alert.IconWrapper>
        <CircleCheckIcon />
    </Alert.IconWrapper>
    <Alert.Title>Test Title</Alert.Title>
    <Alert.Body>Test body</Alert.Body>
</Alert.Warning>

Each of these inner components can accept custom class overrides, and you can specify a heading level on the Title

<Alert.Success className="mt-8>
    <Alert.Title headingTag="h4" className="pb-4 text-xl">
        Test Title
    </Alert.Title>
    <Alert.Body className="p-4">Test body</Alert.Body>
</Alert.Success>

The body of the Alert can just be any arbitrary elements, but not plain text

<Alert.Success title="This is an Alert">
    <p>With a paragraph</p>
    <ul>
        <li>And a list</li>
        <li>Another list item</li>
    </ul>
    <>Here is some text wrapped in a fragment</>
    <p>
        This paragraph <a href="/nowhere">contains a link</a>.
    </p>
    <Button className="mt-8">And a button</Button>

    This text will not render
</Alert.Success>
image

Design

https://www.figma.com/file/93udAjdrHbzOOCxaC5lqN1/GC-Forms-component-library?type=design&node-id=19-640&mode=design&t=pC0kVSSf7AG1PKqi-0

cn()

Includes a new cn util function for resolving Tailwindcss priority/conflicts. When passing in custom classes to the various components, instead of just appending them to the end of existing classes, this utility will merge them and ensure classes added later will take precedence.

TODO

This PR just includes the new component and related code. Future PRs will implement this Alert component everywhere that components/Alert.tsx and components/Attention/Attention.tsx are currently being used.

@dsamojlenko dsamojlenko marked this pull request as draft July 25, 2023 20:11
@dsamojlenko dsamojlenko self-assigned this Jul 25, 2023
@github-actions
Copy link
Contributor

@dsamojlenko dsamojlenko changed the title [WIP] Alerts refactor Alerts refactor Aug 3, 2023
@dsamojlenko dsamojlenko marked this pull request as ready for review August 3, 2023 20:21
Copy link
Member

@timarney timarney left a comment

Choose a reason for hiding this comment

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

Nice work @dsamojlenko

Let's get this merged and than implement a first one here as per the design in the security questions branch.

https://www.figma.com/file/89fRce4gmy64UIArSZoAM8/v3.-GC-Forms-(builder-and-vault)?type=design&node-id=1783-78150&mode=design&t=kypKK3BIN3a4xKfw-0

@dsamojlenko dsamojlenko changed the title Alerts refactor feat: Alerts refactor - create new Alert component for admin/FormBuilder Aug 4, 2023
@dsamojlenko dsamojlenko merged commit 3122649 into develop Aug 4, 2023
10 checks passed
@dsamojlenko dsamojlenko deleted the feature/alert-refactor branch August 4, 2023 13:41
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