Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(web-domains): 공통 모달 컴포넌트 #71

Merged
merged 5 commits into from
Jul 26, 2024
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
6 changes: 3 additions & 3 deletions apps/web/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { FirstDomainExampleScreen } from '@sambad/web-domains/first-domain';

export default FirstDomainExampleScreen;
export default function Second() {
return <div></div>;
}
8 changes: 1 addition & 7 deletions apps/web/app/second/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import { SecondDomainExampleScreen } from '@sambad/web-domains/second-domain';

import styles from '../page.module.css';

export default function Second() {
return (
<main className={styles.main}>
<SecondDomainExampleScreen />
</main>
);
return <main className={styles.main}></main>;
}

This file was deleted.

5 changes: 3 additions & 2 deletions packages/core/sds/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ButtonHTMLAttributes, forwardRef, HTMLAttributes } from 'react';
import { ButtonSize, ButtonVariant } from './types';
import { ButtonHTMLAttributes, forwardRef } from 'react';

import { buttonCss, buttonDisabledVariants, buttonSizeVariants, buttonVariantVariants } from './styles';
import { ButtonSize, ButtonVariant } from './types';

export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
size?: ButtonSize;
Expand Down
2 changes: 2 additions & 0 deletions packages/core/sds/src/components/Button/styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { css } from '@emotion/react';

import { borderRadiusVariants, colors } from '../../theme';

import { ButtonSize, ButtonVariant } from './types';

const buttonHeightVar = '--sambad-button-height';
Expand Down
8 changes: 5 additions & 3 deletions packages/core/sds/src/components/TextButton/TextButton.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { ButtonHTMLAttributes, Children, forwardRef } from 'react';
import { TextButtonVariant } from './types';
import { ButtonHTMLAttributes, forwardRef } from 'react';

import { colors } from '../../theme';
import { Icon } from '../Icon';

import { arrowIconCss, textButtonCss } from './styles';
import { colors } from '../../theme';
import { TextButtonVariant } from './types';

export interface TextButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
variant?: TextButtonVariant;
Expand Down
1 change: 0 additions & 1 deletion packages/core/sds/src/components/TextButton/styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { css } from '@emotion/react';
import { colors } from '../../theme';

export const textButtonCss = css({
display: 'inline-flex',
Expand Down
65 changes: 65 additions & 0 deletions packages/web-domains/src/common/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
'use client';

import { borderRadiusVariants, colors } from '@sambad/sds/theme';
import { HTMLAttributes, PropsWithChildren, ReactNode, useEffect, useState } from 'react';
import { createPortal } from 'react-dom';

export interface ModalProps extends HTMLAttributes<HTMLDivElement> {
isOpen: boolean;
footer?: ReactNode;
onClose?: () => void;
}

export const Modal = ({ isOpen, onClose, children, footer, ...rest }: PropsWithChildren<ModalProps>) => {
const [element, setElement] = useState<HTMLElement | null>(null);

const handleClose = () => {
onClose?.();
};

useEffect(() => {
setElement(document.body);
}, []);

useEffect(() => {
if (isOpen) {
document.body.style.overflow = 'hidden';
} else {
document.body.style.overflow = 'auto';
}

return () => {
document.body.style.overflow = 'auto';
};
}, [isOpen]);

if (typeof window === 'undefined' || !element || !isOpen) {
return <></>;
}

return createPortal(
<div
css={{ width: '100%', height: '100%', background: '#00000066', position: 'fixed', top: 0 }}
onClick={handleClose}
>
<div
id="modal"
css={{
padding: '20px',
width: '335px',
position: 'fixed',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
backgroundColor: colors.white,
borderRadius: borderRadiusVariants.medium,
}}
{...rest}
>
{children}
<div id="modal-footer">{footer}</div>
</div>
</div>,
element,
);
};
Empty file.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions packages/web-domains/src/first-domain/index.ts

This file was deleted.

This file was deleted.

Empty file.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion packages/web-domains/src/second-domain/index.ts

This file was deleted.

This file was deleted.

Loading