Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/components/sandbox/Sandbox.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.sandbox-note {
color: #666;
margin-top: var(--goa-space-m);
margin-bottom: var(--goa-space-2xl);
font: var(--goa-typography-body-s);
}

.sandbox-render {
Expand Down
20 changes: 18 additions & 2 deletions src/components/sandbox/Sandbox.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { ReactElement, ReactNode, useContext, useEffect, useState } from "react";
import { GoabCallout } from "@abgov/react-components";
import { GoabCalloutType } from "@abgov/ui-components-common";

import SandboxProperties from "./SandboxProperties";
import { CodeSnippet } from "@components/code-snippet/CodeSnippet";
Expand All @@ -22,7 +24,7 @@ type Serializer = (el: any, properties: ComponentBinding[]) => string;
interface SandboxProps {
properties?: ComponentBinding[];
formItemProperties?: ComponentBinding[];
note?: string;
note?: string | { type?: GoabCalloutType; heading?: string; content: string };
Comment thread
bdfranck marked this conversation as resolved.
fullWidth?: boolean;
onChange?: (bindings: ComponentBinding[], props: Record<string, unknown>) => void;
onChangeFormItemBindings?: (bindings: ComponentBinding[], props: Record<string, unknown>) => void;
Expand Down Expand Up @@ -140,7 +142,21 @@ export const Sandbox = (props: SandboxProps) => {
</GoabAccordion>
)}
<SandboxCode props={props} formatLang={formatLang} lang={lang} serializers={serializers} version={version} />
{props.note && (<div className="sandbox-note">{props.note}</div>)}
{props.note &&
(typeof props.note === "string" ? (
<p className="sandbox-note">{props.note}</p>
) : (
<GoabCallout
type={props.note.type || "important"}
size="medium"
heading={props.note.heading}
maxWidth="596px"
mt="m"
mb="2xl"
>
{props.note.content}
</GoabCallout>
))}
</>
);
};
Expand Down
7 changes: 6 additions & 1 deletion src/examples/modal/ModalWarnUserDeadlineExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ export const ModalWarnUserDeadlineExample = () => {
const {version} = useContext(LanguageVersionContext);
const [warnCalloutModalOpen, setWarnCalloutModalOpen] = useState<boolean>();
return (
<Sandbox skipRender>
<Sandbox skipRender
note={{
type: "important",
heading: "AlertDialog Accessibility",
content: "Do not make the modal closeable or add any focusable elements before the action button when using an AlertDialog. This ensures that the screen reader will announce the full content."
}}>
<GoabButton type="secondary" onClick={() => setWarnCalloutModalOpen(true)}>
Save for later
</GoabButton>
Expand Down