Skip to content

Commit

Permalink
feat: 기존 valinall CSS => styled-components 마이그레이션
Browse files Browse the repository at this point in the history
  • Loading branch information
sh981013s committed May 2, 2023
1 parent 5ad268e commit 2dbdd33
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/coverage

# production
/build
/dist

# misc
.DS_Store
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"start": "BROWSER='firefox' react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"prepare": "rm -rf dist && mkdir dist && tsc && cp src/lib/components/styles.css dist/components/styles.css"
"prepare": "rm -rf dist && mkdir dist && tsc && NODE_ENV=production babel src --out-dir dist --ignore '**/*.test.tsx'"
},
"eslintConfig": {
"extends": [
Expand Down
Empty file removed src/App.css
Empty file.
7 changes: 5 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import React from 'react';
import './App.css';
import MyModal from "./lib/components/MyModal";

const App = () => {
return (
<h1>Hello World</h1>
<MyModal trigger={<button>모달 열기</button>}>
<h2>제목</h2>
<p>내용</p>
</MyModal>
);
}

Expand Down
15 changes: 6 additions & 9 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import ReactDOM from 'react-dom';
import App from './App';

const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
24 changes: 24 additions & 0 deletions src/lib/components/MyModal.styles.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import styled from 'styled-components';

export const ModalOverlay = styled.div`
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
z-index: 1000;
`;

export const ModalContent = styled.div`
position: relative;
background-color: #fff;
padding: 1rem;
border-radius: 8px;
width: 80%;
max-width: 500px;
z-index: 1001;
`;
12 changes: 6 additions & 6 deletions src/lib/components/MyModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {ReactElement, ReactNode, useState} from "react";
import 'react-bottom-sheet-booungi/dist/components/styles.css';
import React, { ReactElement, ReactNode, useState } from "react";
import * as Styled from './MyModal.styles'

interface MyModalProps {
trigger: ReactElement;
Expand All @@ -21,11 +21,11 @@ const MyModal = ({ trigger, children }: MyModalProps) => {
<>
{React.cloneElement(trigger, { onClick: handleOpenModal })}
{isModalOpen && (
<div className="modal-overlay" onClick={handleCloseModal}>
<div className="modal" onClick={(e) => e.stopPropagation()}>
<Styled.ModalOverlay onClick={handleCloseModal}>
<Styled.ModalContent onClick={(e) => e.stopPropagation()}>
{children}
</div>
</div>
</Styled.ModalContent>
</Styled.ModalOverlay>
)}
</>
);
Expand Down
28 changes: 0 additions & 28 deletions src/lib/components/styles.css

This file was deleted.

0 comments on commit 2dbdd33

Please sign in to comment.