Skip to content

Commit

Permalink
add site example
Browse files Browse the repository at this point in the history
  • Loading branch information
Fercas123 committed Oct 21, 2024
1 parent 3ed8434 commit 8803846
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 0 deletions.
6 changes: 6 additions & 0 deletions site/docs/components/dialog/examples.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,11 @@ This forces a user to action something within the dialog.

Use the `disableScrim` prop to prevent the scrim from rendering.

</LivePreview>
<LivePreview componentName="dialog" exampleName="WithHeader" >
## 🚧 With header

`DialogHeader` can be added to provide a structured header for dialog. The header includes a title and actions that follows our Header Block pattern.

</LivePreview>
</LivePreviewControls>
94 changes: 94 additions & 0 deletions site/src/examples/dialog/WithHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import {
Button,
Dialog,
DialogActions,
DialogContent,
H2,
H3,
StackLayout,
useId,
} from "@salt-ds/core";
import { CloseIcon } from "@salt-ds/icons";
import { DialogHeader } from "@salt-ds/lab";
import { type ReactElement, useState } from "react";

export const WithHeader = (): ReactElement => {
const [open, setOpen] = useState(false);
const id = useId();

const handleRequestOpen = () => {
setOpen(true);
};

const onOpenChange = (value: boolean) => {
setOpen(value);
};

const handleClose = () => {
setOpen(false);
};

const closeButton = (
<Button
aria-label="Close dialog"
appearance="transparent"
onClick={handleClose}
>
<CloseIcon aria-hidden />
</Button>
);

return (
<>
<Button onClick={handleRequestOpen}>Open dialog with header</Button>
<Dialog open={open} onOpenChange={onOpenChange} id={id}>
<DialogHeader
header={<H2>Terms and conditions</H2>}
actions={closeButton}
/>
<DialogContent>
<StackLayout>
<div>
When you add a Chase Card to a Wallet, you agree to these Terms:
</div>
<H3>Adding Your Chase Card</H3>
<div>
You can add an eligible Chase Card to a Wallet by either following
our instructions as they appear on a Chase proprietary platform
(e.g., Chase Mobile® app or chase.com) or by following the
instructions of the Wallet provider. Only Chase Cards that we
determine are eligible can be added to the Wallet.
</div>
<div>
If your Chase Card or underlying account is not in good standing,
that Chase Card will not be eligible to be added to or enrolled in
the Wallet. We may determine other eligibility criteria in our
sole discretion.
</div>
When you add a Chase Card to a Wallet, the Wallet may allow you to
(a) use the Chase Card to (i) enable transfers of money between you
and others who are enrolled with the Wallet provider or a partner of
such Wallet provider, and/or (ii) enter into transactions where the
Wallet is accepted, including the ability to use the Chase Card to
complete transactions at participating merchants' physical
locations, e-commerce locations, and at ATMs; and (b) use other
services that are described in the Wallet provider's agreement or
that they may offer from time to time. The Wallet may not be
accepted at all places where your Chase Card is accepted.
<div>
We reserve the right to terminate our participation in a Wallet or
with a Wallet provider at any time and the right to designate a
maximum number of Chase Cards that may be added to a Wallet.
</div>
</StackLayout>
</DialogContent>
<DialogActions>
<Button onClick={handleClose}>Cancel</Button>
<Button variant="cta" onClick={handleClose}>
Accept
</Button>
</DialogActions>
</Dialog>
</>
);
};
1 change: 1 addition & 0 deletions site/src/examples/dialog/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from "./Error";
export * from "./Warning";
export * from "./Success";
export * from "./WithoutAccent";
export * from "./WithHeader";
export * from "./CloseButton";
export * from "./MandatoryAction";
export * from "./Sizes";
Expand Down

0 comments on commit 8803846

Please sign in to comment.