-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1017 from chrisolsen/1134-detail
feat(DDI-1134): add details component
- Loading branch information
Showing
15 changed files
with
366 additions
and
12 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<h2>Detail</h2> | ||
|
||
<goa-details | ||
heading="This is the titleThis is the titleThis is the titleThis is the titleThis is the titleThis is the titleThis is the titleThis is the title" | ||
> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vel lacinia | ||
metus, sed sodales lectus. Aliquam sed volutpat velit. Sed in lacus ut dui | ||
placerat accumsan malesuada quis erat. Aenean mi diam, rhoncus vitae justo | ||
eu, venenatis maximus nunc. In vel est commodo, porttitor sem vel, tincidunt | ||
ipsum. In hac habitasse platea dictumst. Mauris varius mollis dui. Aenean ut | ||
dui eu arcu rutrum auctor. Curabitur cursus velit vel libero sollicitudin | ||
tincidunt. Proin tincidunt, enim et ultrices rhoncus, nibh leo imperdiet | ||
sapien, sed porttitor ipsum nulla non massa. Nulla facilisi. | ||
</p> | ||
</goa-details> | ||
|
||
<goa-details heading="This is the title"> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vel lacinia | ||
metus, sed sodales lectus. Aliquam sed volutpat velit. Sed in lacus ut dui | ||
placerat accumsan malesuada quis erat. Aenean mi diam, rhoncus vitae justo | ||
eu, venenatis maximus nunc. In vel est commodo, porttitor sem vel, tincidunt | ||
ipsum. In hac habitasse platea dictumst. Mauris varius mollis dui. Aenean ut | ||
dui eu arcu rutrum auctor. Curabitur cursus velit vel libero sollicitudin | ||
tincidunt. Proin tincidunt, enim et ultrices rhoncus, nibh leo imperdiet | ||
sapien, sed porttitor ipsum nulla non massa. Nulla facilisi. | ||
</p> | ||
<img src="https://picsum.photos/200" /> | ||
</goa-details> |
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,9 @@ | ||
import { Component } from "@angular/core"; | ||
|
||
@Component({ | ||
selector: "abgov-detail", | ||
templateUrl: "./detail.html", | ||
}) | ||
export class DetailComponent { | ||
constructor() {} | ||
} |
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,111 @@ | ||
import { Meta, Story } from "@storybook/addon-docs"; | ||
import { | ||
Props, | ||
Prop, | ||
Tabs, | ||
Tab, | ||
CodeSnippet, | ||
SupportInfo, | ||
Markdown, | ||
} from "@abgov/shared/storybook-common"; | ||
import { GoADetails } from "@abgov/react-components"; | ||
|
||
<Meta title="Components/Details" /> | ||
|
||
# Details | ||
|
||
### Details lets users reveal more detailed information when they need it. | ||
|
||
[Figma design component](https://www.figma.com/file/MwuK2yVZZQMN2Nbk9NYSQ7/Component---Accordion-%2B-Detail?node-id=1494%3A268005&t=stVkhUjzWnPvtUOk-0) | ||
|
||
--- | ||
|
||
#### Properties | ||
|
||
<Props showTabs={true}> | ||
<Prop | ||
name="heading" | ||
type="string" | ||
description="The title heading" | ||
required="true" | ||
/> | ||
</Props> | ||
|
||
<details> | ||
<summary>Additional Properties</summary> | ||
<Props showTabs={true}> | ||
<Prop | ||
name="mt" | ||
type="none | 3xs | 2xs | xs | s | m | l | xl | 2xl | 3xl | 4xl" | ||
defaultValue="none" | ||
description="Top margin" | ||
/> | ||
<Prop | ||
name="mr" | ||
type="none | 3xs | 2xs | xs | s | m | l | xl | 2xl | 3xl | 4xl" | ||
defaultValue="none" | ||
description="Right margin" | ||
/> | ||
<Prop | ||
name="mb" | ||
type="none | 3xs | 2xs | xs | s | m | l | xl | 2xl | 3xl | 4xl" | ||
defaultValue="none" | ||
description="Bottom margin" | ||
/> | ||
<Prop | ||
name="ml" | ||
type="none | 3xs | 2xs | xs | s | m | l | xl | 2xl | 3xl | 4xl" | ||
defaultValue="none" | ||
description="Left margin" | ||
/> | ||
</Props> | ||
</details> | ||
|
||
#### Basic | ||
|
||
<Story name="Basic"> | ||
<GoADetails heading="This is the title"> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vel lacinia | ||
metus, sed sodales lectus. Aliquam sed volutpat velit. Sed in lacus ut dui | ||
placerat accumsan malesuada quis erat. Aenean mi diam, rhoncus vitae justo | ||
eu, venenatis maximus nunc. In vel est commodo, porttitor sem vel, | ||
tincidunt ipsum. In hac habitasse platea dictumst. Mauris varius mollis | ||
dui. Aenean ut dui eu arcu rutrum auctor. Curabitur cursus velit vel | ||
libero sollicitudin tincidunt. Proin tincidunt, enim et ultrices rhoncus, | ||
nibh leo imperdiet sapien, sed porttitor ipsum nulla non massa. Nulla | ||
facilisi. | ||
</p> | ||
</GoADetails> | ||
</Story> | ||
|
||
<Tabs> | ||
<Tab label="Angular"> | ||
<CodeSnippet | ||
lang="html" | ||
code={` | ||
<goa-details heading="This is the title"> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vel lacinia metus, sed sodales lectus. Aliquam sed volutpat velit. Sed in lacus ut dui placerat accumsan malesuada quis erat. Aenean mi diam, rhoncus vitae justo eu, venenatis maximus nunc. In vel est commodo, porttitor sem vel, tincidunt ipsum. In hac habitasse platea dictumst. Mauris varius mollis dui. Aenean ut dui eu arcu rutrum auctor. Curabitur cursus velit vel libero sollicitudin tincidunt. Proin tincidunt, enim et ultrices rhoncus, nibh leo imperdiet sapien, sed porttitor ipsum nulla non massa. Nulla facilisi. | ||
</p> | ||
</goa-details> | ||
`} | ||
/> | ||
</Tab> | ||
<Tab label="React"> | ||
<CodeSnippet | ||
lang="tsx" | ||
code={` | ||
<GoADetails heading="This is the title"> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vel lacinia metus, sed sodales lectus. Aliquam sed volutpat velit. Sed in lacus ut dui placerat accumsan malesuada quis erat. Aenean mi diam, rhoncus vitae justo eu, venenatis maximus nunc. In vel est commodo, porttitor sem vel, tincidunt ipsum. In hac habitasse platea dictumst. Mauris varius mollis dui. Aenean ut dui eu arcu rutrum auctor. Curabitur cursus velit vel libero sollicitudin tincidunt. Proin tincidunt, enim et ultrices rhoncus, nibh leo imperdiet sapien, sed porttitor ipsum nulla non massa. Nulla facilisi. | ||
</p> | ||
</GoADetails> | ||
`} | ||
/> | ||
</Tab> | ||
</Tabs> | ||
|
||
--- | ||
|
||
<SupportInfo /> |
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,15 @@ | ||
import { render } from "@testing-library/react"; | ||
|
||
import { GoADetails } from "./details"; | ||
|
||
describe("Detail", () => { | ||
it("should render successfully", () => { | ||
const { baseElement } = render( | ||
<GoADetails heading="The heading">The content</GoADetails> | ||
); | ||
|
||
const el = baseElement.querySelector("goa-details"); | ||
expect(el.getAttribute("heading")).toBe("The heading"); | ||
expect(baseElement.innerHTML).toContain("The content"); | ||
}); | ||
}); |
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,38 @@ | ||
import React, { ReactNode } from "react"; | ||
import { Margins } from "../../common/styling"; | ||
|
||
interface WCProps extends Margins { | ||
heading: string; | ||
} | ||
|
||
declare global { | ||
// eslint-disable-next-line @typescript-eslint/no-namespace | ||
namespace JSX { | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
interface IntrinsicElements { | ||
"goa-details": WCProps & React.HTMLAttributes<HTMLElement>; | ||
} | ||
} | ||
} | ||
|
||
/* eslint-disable-next-line */ | ||
export interface DetailsProps extends Margins { | ||
heading: string; | ||
children: ReactNode; | ||
} | ||
|
||
export function GoADetails(props: DetailsProps) { | ||
return ( | ||
<goa-details | ||
heading={props.heading} | ||
mt={props.mt} | ||
mr={props.mr} | ||
mb={props.mb} | ||
ml={props.ml} | ||
> | ||
{props.children} | ||
</goa-details> | ||
); | ||
} | ||
|
||
export default GoADetails; |
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
Oops, something went wrong.