Skip to content

Commit

Permalink
feat: updated Message to ContextualAlert to match GCWeb
Browse files Browse the repository at this point in the history
  • Loading branch information
zeddotes committed Jan 19, 2023
1 parent 973bac0 commit 5d4f35d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import warning_img from "../../assets/warning_img.svg";
import danger_img from "../../assets/danger_img.svg";
import info_img from "../../assets/info_img.svg";

export function Message(props) {
export function ContextualAlert(props) {
const {
message_heading,
message_body,
Expand Down Expand Up @@ -69,7 +69,7 @@ export function Message(props) {
);
}

Message.propTypes = {
ContextualAlert.propTypes = {
/**
* component id
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Message } from "./Message";
import { ContextualAlert } from "./ContextualAlert";
export default {
title: "Components/Message",
component: Message,
title: "Components/ContextualAlert",
component: ContextualAlert,
};

const Template = (args) => <Message {...args} />;
const Template = (args) => <ContextualAlert {...args} />;

export const Success = Template.bind({});
export const Info = Template.bind({});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import React from "react";
import { render, screen } from "@testing-library/react";
import "@testing-library/jest-dom/extend-expect";
import { axe, toHaveNoViolations } from "jest-axe";
import { Success, Warning, Info, Danger } from "./Message.stories.js";
import { Success, Warning, Info, Danger } from "./ContextualAlert.stories.js";

expect.extend(toHaveNoViolations);

describe("Messages", () => {
describe("ContextualAlert", () => {
it("renders alert image", () => {
render(<Success {...Success.args} />);
expect(screen.getByAltText("success icon"));
Expand All @@ -16,7 +16,7 @@ describe("Messages", () => {
const results = await axe(container);
expect(results).toHaveNoViolations();
});
it("has no a11y Warning", async () => {
it("has no a11y Warnsing", async () => {
const { container } = render(<Warning {...Warning.args} />);
const results = await axe(container);
expect(results).toHaveNoViolations();
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export { Menu } from "./components/Menu/Menu";
export { Footer } from "./components/Footer/Footer";

/**
* Message
* ContextualAlert
*/
export { Message } from "./components/Message/Message";
export { ContextualAlert } from "./components/ContextualAlert/ContextualAlert";

/**
* Cards
Expand Down
4 changes: 2 additions & 2 deletions src/stories/Patterns.stories.mdx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Meta } from '@storybook/addon-docs/blocks';
import { Message } from '../components/Message/Message'
import { ContextualAlert } from '../components/ContextualAlert/ContextualAlert'
import { Image } from '../components/Image/Image'
import { Link } from '../components/Link/Link'
import { Collapse } from '../components/Collapse/Collapse'

<Meta title="Documentation/Patterns" />

<h1 className="ds-heading1"> Opt-in to give consent</h1>
<Message
<ContextualAlert
alert_icon_alt_text="info icon"
alert_icon_id="info icon"
id="info"
Expand Down
11 changes: 6 additions & 5 deletions src/storyExamples/CallOut/CallOut.stories.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CallOut } from "./CallOut";
import { CheckBoxes } from "../../components/CheckBoxes/CheckBoxes";
import { CheckBoxForm } from "../../components/CheckBoxForm/CheckBoxForm";
import { Message } from "../../components/Message/Message";
import { ContextualAlert } from "../../components/ContextualAlert/ContextualAlert";
import React from "react";

export default {
Expand Down Expand Up @@ -30,7 +30,7 @@ const Template = () => {
/>
{errorState ? (
<div className="ds-mt-34px">
<Message
<ContextualAlert
alert_icon_alt_text="warning"
alert_icon_id="warning icon"
id="warning"
Expand Down Expand Up @@ -58,6 +58,7 @@ Default.args = {};
const Template2 = () => {
const [errorState, setErrorState] = React.useState(false);
const [errorState2, setErrorState2] = React.useState(false);
const onSubmit = React.useCallback(() => true, []);
const exampleCode = [
<div>
<CheckBoxForm
Expand Down Expand Up @@ -96,11 +97,11 @@ const Template2 = () => {
required: true,
}}
id="temp"
onSubmit={() => {}}
onSubmit={onSubmit}
/>
{errorState ? (
<div className="ds-mt-34px">
<Message
<ContextualAlert
alert_icon_alt_text="danger icon"
alert_icon_id="danger icon"
id="danger"
Expand All @@ -112,7 +113,7 @@ const Template2 = () => {
) : null}
{errorState2 ? (
<div className="ds-mt-34px">
<Message
<ContextualAlert
alert_icon_alt_text="success icon"
alert_icon_id="success icon"
id="success"
Expand Down

0 comments on commit 5d4f35d

Please sign in to comment.