-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Modal): footers for new Modal component (#2553)
- Loading branch information
1 parent
97d81fa
commit ba63288
Showing
11 changed files
with
136 additions
and
9 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
packages/core/src/components/ModalNew/footers/ModalFooter/ModalFooter.module.scss
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,12 @@ | ||
.primary { | ||
order: 2; | ||
|
||
&:only-child { | ||
margin-left: auto; | ||
} | ||
} | ||
|
||
.secondary { | ||
order: 1; | ||
margin-left: auto; | ||
} |
32 changes: 32 additions & 0 deletions
32
packages/core/src/components/ModalNew/footers/ModalFooter/ModalFooter.tsx
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,32 @@ | ||
import React, { forwardRef } from "react"; | ||
import cx from "classnames"; | ||
import ModalFooterBase from "../ModalFooterBase/ModalFooterBase"; | ||
import { getTestId } from "../../../../tests/test-ids-utils"; | ||
import { ComponentDefaultTestId } from "../../../../tests/constants"; | ||
import { ModalFooterProps } from "./ModalFooter.types"; | ||
import styles from "./ModalFooter.module.scss"; | ||
|
||
const ModalFooter = forwardRef( | ||
( | ||
{ primaryButton, secondaryButton, renderSideAction, "data-testid": dataTestId, className, id }: ModalFooterProps, | ||
ref: React.ForwardedRef<HTMLDivElement> | ||
) => { | ||
const primary = { ...primaryButton, className: cx(primaryButton.className, styles.primary) }; | ||
const secondary = secondaryButton | ||
? { ...secondaryButton, className: cx(secondaryButton.className, styles.secondary) } | ||
: undefined; | ||
return ( | ||
<ModalFooterBase | ||
ref={ref} | ||
className={className} | ||
id={id} | ||
data-testid={dataTestId || getTestId(ComponentDefaultTestId.MODAL_NEXT_FOOTER, id)} | ||
primaryButton={primary} | ||
secondaryButton={secondary} | ||
renderAction={renderSideAction} | ||
/> | ||
); | ||
} | ||
); | ||
|
||
export default ModalFooter; |
6 changes: 6 additions & 0 deletions
6
packages/core/src/components/ModalNew/footers/ModalFooter/ModalFooter.types.ts
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,6 @@ | ||
import React from "react"; | ||
import { ModalFooterBaseProps } from "../ModalFooterBase/ModalFooterBase.types"; | ||
|
||
export interface ModalFooterProps extends Omit<ModalFooterBaseProps, "renderAction"> { | ||
renderSideAction?: React.ReactNode; | ||
} |
File renamed without changes.
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
File renamed without changes.
14 changes: 14 additions & 0 deletions
14
...ages/core/src/components/ModalNew/footers/ModalFooterWizard/ModalFooterWizard.module.scss
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,14 @@ | ||
.primary { | ||
order: 2; | ||
} | ||
|
||
.secondary { | ||
order: 1; | ||
} | ||
|
||
.stepDots { | ||
position: absolute; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
margin: 0; | ||
} |
60 changes: 60 additions & 0 deletions
60
packages/core/src/components/ModalNew/footers/ModalFooterWizard/ModalFooterWizard.tsx
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,60 @@ | ||
import React, { forwardRef } from "react"; | ||
import { VibeComponentProps } from "../../../../types"; | ||
import cx from "classnames"; | ||
import ModalFooterBase from "../ModalFooterBase/ModalFooterBase"; | ||
import { ModalFooterBaseProps } from "../ModalFooterBase/ModalFooterBase.types"; | ||
import { getTestId } from "../../../../tests/test-ids-utils"; | ||
import { ComponentDefaultTestId } from "../../../../tests/constants"; | ||
import styles from "./ModalFooterWizard.module.scss"; | ||
import { StepsGalleryHeader } from "../../../Steps/StepsGalleryHeader"; | ||
|
||
export interface ModalFooterWizardProps | ||
extends Required<Pick<ModalFooterBaseProps, "primaryButton" | "secondaryButton">>, | ||
VibeComponentProps { | ||
stepCount: number; | ||
activeStep: number; | ||
onDotClick: (e: React.MouseEvent, stepIndex: number) => void; | ||
} | ||
|
||
const ModalFooterWizard = forwardRef( | ||
( | ||
{ | ||
primaryButton, | ||
secondaryButton, | ||
stepCount, | ||
activeStep, | ||
onDotClick, | ||
"data-testid": dataTestId, | ||
className, | ||
id | ||
}: ModalFooterWizardProps, | ||
ref: React.ForwardedRef<HTMLDivElement> | ||
) => { | ||
const primary = { ...primaryButton, className: cx(primaryButton.className, styles.primary) }; | ||
const secondary = secondaryButton | ||
? { ...secondaryButton, className: cx(secondaryButton.className, styles.secondary) } | ||
: undefined; | ||
const steps = ( | ||
<StepsGalleryHeader | ||
stepsCount={stepCount} | ||
activeStepIndex={activeStep} | ||
onChangeActiveStep={onDotClick} | ||
className={styles.stepDots} | ||
/> | ||
); | ||
|
||
return ( | ||
<ModalFooterBase | ||
ref={ref} | ||
className={className} | ||
id={id} | ||
data-testid={dataTestId || getTestId(ComponentDefaultTestId.MODAL_NEXT_FOOTER, id)} | ||
primaryButton={primary} | ||
secondaryButton={secondary} | ||
renderAction={steps} | ||
/> | ||
); | ||
} | ||
); | ||
|
||
export default ModalFooterWizard; |
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