-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Issue 358] Goal Content for Static Site (#371)
* Story for goal content * Tests for goal content Co-authored-by: Daphne Gold <[email protected]>
- Loading branch information
1 parent
d77735a
commit e760b7d
Showing
13 changed files
with
174 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { | ||
Grid, | ||
GridContainer, | ||
Alert as USWDSAlert, | ||
} from "@trussworks/react-uswds"; | ||
|
||
type Props = { | ||
type: "success" | "warning" | "error" | "info"; | ||
children: React.ReactNode; | ||
}; | ||
|
||
const getBGColor = (type: Props["type"]) => { | ||
switch (type) { | ||
case "success": | ||
return "bg-green-cool-5"; | ||
case "warning": | ||
return "bg-yellow-5"; | ||
case "error": | ||
return "bg-red-warm-10"; | ||
case "info": | ||
return "bg-cyan-5"; | ||
} | ||
}; | ||
|
||
const FullWidthAlert = ({ type, children }: Props) => { | ||
return ( | ||
<div className={`${getBGColor(type)}`}> | ||
<GridContainer> | ||
<Grid> | ||
<USWDSAlert | ||
className="border-left-0 bg-transparent padding-left-0 margin-x-neg-2" | ||
type={type} | ||
headingLevel="h4" | ||
slim | ||
> | ||
{children} | ||
</USWDSAlert> | ||
</Grid> | ||
</GridContainer> | ||
</div> | ||
); | ||
}; | ||
|
||
export default FullWidthAlert; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useTranslation } from "next-i18next"; | ||
import { Grid, GridContainer } from "@trussworks/react-uswds"; | ||
|
||
const GoalContent = () => { | ||
const { t } = useTranslation("common", { keyPrefix: "Index" }); | ||
|
||
return ( | ||
<GridContainer> | ||
<Grid row> | ||
<h2 className="margin-bottom-0">{t("goal_title")}</h2> | ||
</Grid> | ||
<Grid row gap="md"> | ||
<Grid tablet={{ col: 6 }}> | ||
<p className="usa-intro">{t("goal_paragraph_1")}</p> | ||
</Grid> | ||
<Grid tablet={{ col: 6 }}> | ||
<h3>{t("goal_title_2")}</h3> | ||
<p>{t("goal_paragraph_2")}</p> | ||
<h3>{t("goal_title_3")}</h3> | ||
<p>{t("goal_paragraph_3")}</p> | ||
</Grid> | ||
</Grid> | ||
</GridContainer> | ||
); | ||
}; | ||
|
||
export default GoalContent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
...tend/stories/components/Alert.stories.tsx → ...ies/components/FullWidthAlert.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Meta } from "@storybook/react"; | ||
|
||
import GoalContent from "src/components/GoalContent"; | ||
|
||
const meta: Meta<typeof GoalContent> = { | ||
title: "Goal Content", | ||
component: GoalContent, | ||
}; | ||
export default meta; | ||
|
||
export const Default = { | ||
parameters: { | ||
design: { | ||
type: "figma", | ||
url: "https://www.figma.com/file/lpKPdyTyLJB5JArxhGjJnE/beta.grants.gov?type=design&node-id=14-830&mode=design&t=S3j65DqL38Dpg3qK-4", | ||
}, | ||
}, | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
|
||
import FullWidthAlert from "src/components/FullWidthAlert"; | ||
|
||
describe("FullWidthAlert", () => { | ||
it("Renders without errors", () => { | ||
render(<FullWidthAlert type="success">This is a test</FullWidthAlert>); | ||
const alert = screen.getByTestId("alert"); | ||
expect(alert).toBeInTheDocument(); | ||
}); | ||
|
||
it("Renders children content in a <p> tag", () => { | ||
render(<FullWidthAlert type="success">This is a test</FullWidthAlert>); | ||
const alert = screen.getByTestId("alert"); | ||
expect(alert).toHaveTextContent("This is a test"); | ||
expect(alert).toContainHTML("p"); | ||
}); | ||
|
||
it("Renders info alert", () => { | ||
render(<FullWidthAlert type="info">This is a test</FullWidthAlert>); | ||
const alert = screen.getByTestId("alert"); | ||
expect(alert).toBeInTheDocument(); | ||
}); | ||
|
||
it("Renders error alert", () => { | ||
render(<FullWidthAlert type="error">This is a test</FullWidthAlert>); | ||
const alert = screen.getByTestId("alert"); | ||
expect(alert).toBeInTheDocument(); | ||
}); | ||
|
||
it("Renders warning alert", () => { | ||
render(<FullWidthAlert type="warning">This is a test</FullWidthAlert>); | ||
const alert = screen.getByTestId("alert"); | ||
expect(alert).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
|
||
import GoalContent from "src/components/GoalContent"; | ||
|
||
describe("Goal Content", () => { | ||
it("Renders without errors", () => { | ||
render(<GoalContent />); | ||
const goalH2 = screen.getByRole("heading", { | ||
level: 2, | ||
name: /What's the goal?/i, | ||
}); | ||
|
||
expect(goalH2).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters