Skip to content
Open
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
2 changes: 2 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
"project": ["./tsconfig.json"]
},
"rules": {
"no-param-reassign": "off",
"no-console": "off",
"react/react-in-jsx-scope": "off",
"react/prop-types": "off",
"react/jsx-props-no-spreading": "off",
"@typescript-eslint/no-unused-vars": "warn",
"react/jsx-no-useless-fragment": "off",
"import/prefer-default-export": "off",
Expand Down
55 changes: 53 additions & 2 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ $ yarn start
```

## 1회 Chip Component

## 2회 Button Component
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"react-scripts": "5.0.1",
"styled-components": "^6.0.7",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4"
"web-vitals": "^2.1.4",
"zustand": "^4.4.1"
},
"scripts": {
"start": "react-scripts start",
Expand Down
8 changes: 3 additions & 5 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<meta name="description" content="Web site created using create-react-app" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
Expand Down Expand Up @@ -39,5 +36,6 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<div id="modal"></div>
</body>
</html>
43 changes: 17 additions & 26 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
// Img
import check from './assets/images/chip/check.png';
import close from './assets/images/chip/close.png';

// Component
import Chip from './chip';
import Modal from 'modal';
import { useEffect } from 'react';
import useModal from 'stores/useModal';

const App = () => {
const { openModal } = useModal();

useEffect(() => {
openModal({
COMMON: {
component: <>COMMON</>,
callback() {
console.log('Call Back');
},
},
});
}, [openModal]);

return (
<>
<Chip>
<Chip.Label>SUGGESTION</Chip.Label>
</Chip>
<Chip useSelected backgroundColor={{ default: '#bcbcbc', select: '#f17c7c' }}>
<Chip.LeadingImg src={check} />
<Chip.Label>ASSIST</Chip.Label>
</Chip>
<Chip useSelected>
<Chip.LeadingImg src={check} />
<Chip.Label>FILTER USE SELECT</Chip.Label>
</Chip>
<Chip
useSelected
backgroundColor={{ default: '#fff', select: '#f17c7c' }}
borderColor={{ default: '#f17c7c', select: '#f17c7c' }}
>
<Chip.LeadingImg src={check} />
<Chip.Label>INPUT</Chip.Label>
<Chip.TrailingImg src={close} />
</Chip>
<Modal />
</>
);
};
Expand Down
33 changes: 33 additions & 0 deletions src/button/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { ButtonHTMLAttributes, FC, PropsWithChildren } from 'react';
import { StyledButton } from './style';
import { Spinner } from '../loading/style';

interface IButton extends ButtonHTMLAttributes<HTMLButtonElement>, PropsWithChildren {
isFetching?: boolean;
height?: string;
width?: string;
bgColor?: string;
borderRadius?: string;
hoverOption?: {
bgColor?: string;
color?: string;
};
}
const Button: FC<IButton> = ({ isFetching, children, ...rest }) => {
return (
<StyledButton type="button" {...rest}>
{isFetching ? <Spinner /> : children}
</StyledButton>
);
};

export default Button;

Button.defaultProps = {
isFetching: false,
height: '50px',
width: '150px',
bgColor: undefined,
borderRadius: '2.778vw',
hoverOption: undefined,
};
33 changes: 33 additions & 0 deletions src/button/style/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { styled } from 'styled-components';

export const StyledButton = styled.button<{
isFetching?: boolean;
borderRadius?: string;
height?: string;
width?: string;
bgColor?: string;
hoverOption?: {
bgColor?: string;
color?: string;
};
}>`
width: ${(props) => props.width};
height: ${(props) => props.height};
background-color: ${(props) => props.bgColor};
border-color: ${(props) => props.bgColor};
display: flex;
justify-content: center;
align-items: center;
border-radius: ${(props) => props.borderRadius};
margin: 16px;
${(props) => !props.disabled && 'cursor: pointer;'}
${(props) =>
!props.disabled &&
`
&:hover {
border-color: ${props.hoverOption?.bgColor};
background-color: ${props.hoverOption?.bgColor};
color: ${props.hoverOption?.color};
}
`}
`;
2 changes: 1 addition & 1 deletion src/chip/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FC, PropsWithChildren, useState } from 'react';

// Style
import { ChipContainer, ChipLeadingImg, ChipLabel, ChipTrailingImg } from './styled';
import { ChipContainer, ChipLeadingImg, ChipLabel, ChipTrailingImg } from './style';

interface IChip extends PropsWithChildren {
useSelected?: boolean;
Expand Down
File renamed without changes.
35 changes: 35 additions & 0 deletions src/chip/test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Img
import check from './assets/images/chip/check.png';
import close from './assets/images/chip/close.png';

// Component
import Chip from '.';

const ChipTest = () => {
return (
<>
<Chip>
<Chip.Label>SUGGESTION</Chip.Label>
</Chip>
<Chip useSelected backgroundColor={{ default: '#bcbcbc', select: '#f17c7c' }}>
<Chip.LeadingImg src={check} />
<Chip.Label>ASSIST</Chip.Label>
</Chip>
<Chip useSelected>
<Chip.LeadingImg src={check} />
<Chip.Label>FILTER USE SELECT</Chip.Label>
</Chip>
<Chip
useSelected
backgroundColor={{ default: '#fff', select: '#f17c7c' }}
borderColor={{ default: '#f17c7c', select: '#f17c7c' }}
>
<Chip.LeadingImg src={check} />
<Chip.Label>INPUT</Chip.Label>
<Chip.TrailingImg src={close} />
</Chip>
</>
);
};

export default ChipTest;
26 changes: 26 additions & 0 deletions src/loading/style/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import styled, { keyframes } from 'styled-components';

const rotation = keyframes`
from{
transform: rotate(0deg);
}

to{
transform: rotate(360deg);
}
`;

export const Spinner = styled.div<{
height?: string;
width?: string;
color?: string;
}>`
position: relative;
height: ${(props) => props.height || '30px'};
width: ${(props) => props.width || '30px'};
border: 1px solid ${(props) => props.color || '#000'};
border-radius: 50%;
border-top: none;
border-right: none;
animation: ${rotation} 1s linear infinite;
`;
Loading