diff options
Diffstat (limited to 'src/components/atoms/flip/flip-side.tsx')
| -rw-r--r-- | src/components/atoms/flip/flip-side.tsx | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/components/atoms/flip/flip-side.tsx b/src/components/atoms/flip/flip-side.tsx new file mode 100644 index 0000000..31c23f5 --- /dev/null +++ b/src/components/atoms/flip/flip-side.tsx @@ -0,0 +1,35 @@ +import { + type ForwardRefRenderFunction, + type HTMLAttributes, + forwardRef, + type ReactNode, +} from 'react'; +import styles from './flip.module.scss'; + +export type FlipSideProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & { + /** + * The side contents. + */ + children: ReactNode; + /** + * Is it the back side of the flip component? + * + * @default false + */ + isBack?: boolean; +}; + +const FlipSideWithRef: ForwardRefRenderFunction< + HTMLDivElement, + FlipSideProps +> = ({ children, className = '', isBack = false, ...props }, ref) => { + const sideClass = [isBack ? styles.back : styles.front, className].join(' '); + + return ( + <div {...props} className={sideClass} ref={ref}> + {children} + </div> + ); +}; + +export const FlipSide = forwardRef(FlipSideWithRef); |
