Skip to content

Commit

Permalink
final fitnfinsh changes complete
Browse files Browse the repository at this point in the history
Signed-off-by: Shubh Sahu <shubhvs@amazon.com>
  • Loading branch information
Shubh Sahu committed Sep 2, 2024
1 parent 60a21ab commit 344c090
Show file tree
Hide file tree
Showing 26 changed files with 878 additions and 567 deletions.
6 changes: 5 additions & 1 deletion public/components/BottomBar/BottomBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,9 @@ export default function BottomBar(props: CustomFormRowProps) {
};
}, []);

return <EuiBottomBar ref={bottomBarRef}>{props.children}</EuiBottomBar>;
return (
<EuiBottomBar ref={bottomBarRef} position="sticky">
{props.children}
</EuiBottomBar>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

exports[`<FormGenerator /> spec render the component 1`] = `
HTMLCollection [
<div />,
<div>
<section
aria-label="Page level controls"
class="euiBottomBar euiBottomBar--fixed euiBottomBar--paddingMedium"
class="euiBottomBar euiBottomBar--sticky euiBottomBar--paddingMedium"
>
<h2
class="euiScreenReaderOnly"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,25 @@
*/

import React from "react";
import { render } from "@testing-library/react";
import { render, cleanup } from "@testing-library/react";
import UnsavedChangesBottomBar from "./index";

describe("<FormGenerator /> spec", () => {
let appWrapper: HTMLDivElement;

beforeEach(() => {
// Create a mock DOM element with the ID 'app-wrapper'
appWrapper = document.createElement("div");
appWrapper.setAttribute("id", "app-wrapper");
document.body.appendChild(appWrapper);
});

afterEach(() => {
// Clean up the mock DOM element after each test
document.body.removeChild(appWrapper);
cleanup();
});

it("render the component", () => {
render(<UnsavedChangesBottomBar unsavedCount={0} onClickCancel={async () => {}} onClickSubmit={async () => {}} />);
expect(document.body.children).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiSmallButtonEmpty, EuiButtonPro
import classNames from "classnames";
import BottomBar from "../BottomBar";
import "./index.scss";
import { createPortal } from "react-dom";

export type CustomFormRowProps = {
unsavedCount: number;
Expand Down Expand Up @@ -67,7 +68,7 @@ export default function UnsavedChangesBottomBar(props: CustomFormRowProps) {
iconType="check"
color="primary"
fill
size="m"
size="s"
children="Save"
{...props.confirmButtonProps}
/>
Expand Down Expand Up @@ -116,9 +117,9 @@ export default function UnsavedChangesBottomBar(props: CustomFormRowProps) {
</>
));

return (
const bottomBar = (
<BottomBar>
<EuiFlexGroup alignItems="center">
<EuiFlexGroup alignItems="center" gutterSize="s" justifyContent="spaceBetween">
{renderProps({
renderCancel,
renderConfirm,
Expand All @@ -128,4 +129,6 @@ export default function UnsavedChangesBottomBar(props: CustomFormRowProps) {
</EuiFlexGroup>
</BottomBar>
);

return createPortal(bottomBar, document.getElementById("app-wrapper")!);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

exports[`<FormGenerator /> spec render the component 1`] = `
HTMLCollection [
<div />,
<div>
<div
id="app-wrapper"
>
<section
aria-label="Page level controls"
class="euiBottomBar euiBottomBar--fixed euiBottomBar--paddingMedium"
class="euiBottomBar euiBottomBar--sticky euiBottomBar--paddingMedium"
>
<h2
class="euiScreenReaderOnly"
>
Page level controls
</h2>
<div
class="euiFlexGroup euiFlexGroup--gutterLarge euiFlexGroup--alignItemsCenter euiFlexGroup--directionRow euiFlexGroup--responsive"
class="euiFlexGroup euiFlexGroup--gutterSmall euiFlexGroup--alignItemsCenter euiFlexGroup--justifyContentSpaceBetween euiFlexGroup--directionRow euiFlexGroup--responsive"
>
<div
class="euiFlexItem euiFlexItem--flexGrowZero"
Expand All @@ -39,7 +40,7 @@ HTMLCollection [
class="euiFlexItem euiFlexItem--flexGrowZero"
>
<button
class="euiButton euiButton--primary euiButton--fill"
class="euiButton euiButton--primary euiButton--small euiButton--fill"
type="button"
>
<span
Expand All @@ -63,5 +64,6 @@ HTMLCollection [
There is a new region landmark with page level controls at the end of the document.
</p>
</div>,
<div />,
]
`;
Loading

0 comments on commit 344c090

Please sign in to comment.