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
77 changes: 38 additions & 39 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"prettier": "npx prettier . --write"
},
"dependencies": {
"@abgov/react-components": "6.5.0",
"@abgov/ui-components-common": "1.5.0",
"@abgov/web-components": "1.35.1",
"@abgov/react-components": "6.6.0-alpha.4",
"@abgov/ui-components-common": "1.6.0-alpha.4",
"@abgov/web-components": "1.36.0-alpha.6",
"@faker-js/faker": "^8.3.1",
"highlight.js": "^11.8.0",
"js-cookie": "^3.0.5",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ interface ComponentPropertyProps {
props: ComponentProperty;
}

function ComponentProperty({ props }: ComponentPropertyProps) {
export function ComponentProperty({ props }: ComponentPropertyProps) {
return (
<div className={css["component-props"]}>
<div className={css.details}>
Expand Down
74 changes: 74 additions & 0 deletions src/components/function-properties/FunctionProperties.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { GoabText, GoabContainer } from "@abgov/react-components";
import { ReactNode, useContext, useEffect, useState } from "react";

import { ComponentProperty as ComponentPropertyType, ComponentProperty } from "@components/component-properties/ComponentProperties.tsx";
import { LanguageVersionContext } from "@contexts/LanguageVersionContext.tsx";

interface Props {
properties: ComponentPropertyType[];
oldProperties?: ComponentPropertyType[];
heading?: string;
subHeading?: ReactNode;
codeSnippets?: {
angular?: ReactNode;
react?: ReactNode;
};
}

export const FunctionProperties = (props: Props) => {
const { language, version } = useContext(LanguageVersionContext);
const [filteredProperties, setFilteredProperties] = useState<ComponentPropertyType[]>([]);

const filterBy = (properties: ComponentPropertyType[]) => {
const result = properties.filter((child: ComponentPropertyType) => {
return !child.lang || child.lang === language;
});
return result;
};

useEffect(() => {
if (version === "old") {
setFilteredProperties([...filterBy(props.oldProperties || props.properties)]);
return;
}
setFilteredProperties([...filterBy(props.properties)]);
}, [language, version, props.properties, props.oldProperties]);

function dasherize(str: string): string {
return str.replace(" ", "-").toLowerCase();
}

return (
<>
<h2
id={props.heading ? `components-${dasherize(props.heading)}` : "function-properties"}
className="hidden"
aria-hidden="true">
{props.heading || "Function Properties"}
</h2>
<GoabText size="heading-m" mt="2xl">
{props.heading || "Function Properties"}
</GoabText>
{props.subHeading && (
<GoabText size="body-s" mb="l">
{props.subHeading}
</GoabText>
)}

{props.codeSnippets && (
<div style={{ marginBottom: "1rem" }}>
{props.codeSnippets.angular}
{props.codeSnippets.react}
</div>
)}

<GoabContainer type="interactive">
<div>
{filteredProperties.map((property, index) => (
<ComponentProperty key={index} props={property} />
))}
</div>
</GoabContainer>
</>
);
};
93 changes: 93 additions & 0 deletions src/examples/show-a-notification-with-an-action.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { GoabButton } from "@abgov/react-components";
import { CodeSnippet } from "@components/code-snippet/CodeSnippet.tsx";
import { Sandbox } from "@components/sandbox";
import { TemporaryNotification } from "@abgov/ui-components-common";

export const ShowANotificationWithAnAction = () => {
const comment = () => {
const uuid = TemporaryNotification.show(
"Edna Mode commented on your assigned case.",
{
actionText: "View",
action: () => {
TemporaryNotification.dismiss(uuid);
},
}
);
};

return (
<Sandbox skipRender>
<GoabButton onClick={comment}>Comment</GoabButton>

<CodeSnippet
lang="typescript"
tags="angular"
allowCopy={true}
code={`
import { TemporaryNotification } from "@abgov/ui-components-common";

export class ExampleComponent {
comment() {
const uuid = TemporaryNotification.show(
"Edna Mode commented on your assigned case.",
{
actionText: "View",
action: () => {
TemporaryNotification.dismiss(uuid);
},
}
);
}
}
`}
/>

<CodeSnippet
lang="typescript"
tags="react"
allowCopy={true}
code={`
import { TemporaryNotification } from "@abgov/ui-components-common";

const comment = () => {
const uuid = TemporaryNotification.show(
"Edna Mode commented on your assigned case.",
{
actionText: "View",
action: () => {
TemporaryNotification.dismiss(uuid);
},
}
);
};
`}
/>

<CodeSnippet
lang="typescript"
tags="react"
allowCopy={true}
code={`
<>
<GoabTemporaryNotificationCtrl />
<GoabButton onClick={comment}>Comment</GoabButton>
</>
`}
/>

<CodeSnippet
lang="html"
tags="angular"
allowCopy={true}
code={`
<goab-temporary-notification-ctrl/>

<goab-button (onClick)="comment()">Comment</goab-button>
`}
/>
</Sandbox>
);
};

export default ShowANotificationWithAnAction;
Loading