Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
50f1edd
docs: update guide for reviewer
wmakerjun Sep 12, 2023
2c584df
refactor: 중복되는 타입 코드 변경 및 사용하지 않는 코드 삭제
Gilpop8663 Sep 25, 2023
63e6459
1.0.8
Gilpop8663 Sep 25, 2023
5636598
1.0.9
Gilpop8663 Sep 25, 2023
03cd6c6
1.0.10
Gilpop8663 Sep 25, 2023
17fe703
1.0.11
Gilpop8663 Sep 25, 2023
ef0178d
chore: ReactElement, ReactNode 관련 타입 에러 나는 부분 수정
Gilpop8663 Sep 25, 2023
82782fe
1.0.12
Gilpop8663 Sep 25, 2023
7fff750
chore: ReactElement, ReactNode 관련 타입 에러 나는 부분 수정 해결 완료
Gilpop8663 Sep 25, 2023
8258090
docs: 타입 에러 관련 해결한 방법 기록 및 fixup.sh 파일 개행 추가
Gilpop8663 Sep 25, 2023
8a40986
1.0.13
Gilpop8663 Sep 25, 2023
9079a26
feat: MasonryLayout 컴포넌트 기본 틀 구현
Gilpop8663 Sep 25, 2023
81f5015
docs: 컴포넌트 구현할 목록 정리 및 스토리북 초안 작성
Gilpop8663 Sep 25, 2023
e32ed0a
Merge branch 'step2' of https://github.com/Gilpop8663/layout-componen…
Gilpop8663 Sep 26, 2023
8fc1ac7
feat: MasonryLayout 컴포넌트 column 방향 구현
Gilpop8663 Sep 26, 2023
d671b1e
chore: column 방향을 우선 지원하도록 하기 위해 direction 코드 삭제
Gilpop8663 Sep 26, 2023
59d7d6b
docs: MasonryLayout 컴포넌트 사용방법 및 Props 문서화
Gilpop8663 Sep 26, 2023
b34e036
1.1.0
Gilpop8663 Sep 26, 2023
cc3c4da
feat: re-export에 MasonryLayout 컴포넌트 경로 추가
Gilpop8663 Sep 26, 2023
2f13c11
1.1.1
Gilpop8663 Sep 26, 2023
34fab5e
feat: re-export에 미적용 되었던 MasonryLayout 컴포넌트 경로 추가
Gilpop8663 Sep 26, 2023
1b323af
1.1.2
Gilpop8663 Sep 26, 2023
f134e84
chore: 패키지 실행이 안되는 문제 파악중
Gilpop8663 Sep 26, 2023
6458ea6
1.1.3
Gilpop8663 Sep 26, 2023
b082f91
chore: 패키지 설치 작동되는 것 확인 후 코드 복구
Gilpop8663 Sep 26, 2023
5d8c736
1.1.4
Gilpop8663 Sep 26, 2023
3e24c7a
docs: 설치 방법 수정
Gilpop8663 Sep 26, 2023
051d887
chore: 패키지 설치 에러나는 것 원인 분석
Gilpop8663 Sep 26, 2023
1e63e66
1.1.5
Gilpop8663 Sep 26, 2023
456c21e
chore: 패키지 설치 후 에러나는 것 원인 분석
Gilpop8663 Sep 26, 2023
07cdac6
1.1.5
Gilpop8663 Sep 26, 2023
dbda963
1.1.6
Gilpop8663 Sep 26, 2023
3d12e1a
feat: Masonry 컴포넌트에서 반응형으로 이미지 사이즈를 조절할 수 있도록 구현
Gilpop8663 Sep 27, 2023
f41d054
feat: Masonary 컴포넌트에서 RowGap 부분도 반응형 되도록 구현
Gilpop8663 Sep 27, 2023
fa77599
feat: childArray의 any 타입을 ReactElement로 선언 및 문자열 방어 로직 작성
Gilpop8663 Sep 27, 2023
adbfd8f
docs: 스토리북 MasonryLayout, Intro 설명 문서에 Meta 추가
Gilpop8663 Sep 27, 2023
66a99af
docs: 스토리북 문서에 공통 CSS Props에 대한 설명 추가
Gilpop8663 Sep 27, 2023
e25707f
docs: MasonryLayout 반응형 Props에 대한 설명 추가
Gilpop8663 Sep 27, 2023
6c0c8dd
docs: 공통 스타일 Props에 대해해jsDoc 작성
Gilpop8663 Sep 27, 2023
86d2d94
docs: Container, Flex, Grid jsDoc 작성
Gilpop8663 Sep 27, 2023
6a33989
docs: MasonryLayout 컴포넌트 Props에 jsDoc을 이용하여 설명 추가
Gilpop8663 Sep 27, 2023
27ce531
fix: 반응형에서 의도한대로 동작하지 않는 코드 수정
Gilpop8663 Sep 27, 2023
c6251b8
feat: ResizeObserver에서 debounce를 사용하여 너무 빠르게 resize 되는 부분을 제어 any 타입 …
Gilpop8663 Sep 27, 2023
6f244c7
1.1.7
Gilpop8663 Sep 27, 2023
0a4cbe6
docs: 참고자료 업데이트
Gilpop8663 Sep 27, 2023
8317a13
chore: npm 배포하는 방법을 vite의 설정을 이용하여 배포하도록 수정
Gilpop8663 Oct 2, 2023
5b39744
1.1.7
Gilpop8663 Oct 2, 2023
cc40230
1.1.8
Gilpop8663 Oct 2, 2023
72488a4
chore: 사용하지 않는 파일 삭제 및 tsconfig 초기 설정으로 변경
Gilpop8663 Oct 2, 2023
acf2dd5
chore: merge 후 충돌나는 코드 병합
Gilpop8663 Oct 2, 2023
ab49de6
1.1.9
Gilpop8663 Oct 2, 2023
0dd7e7d
docs: README와 문서 설명 업데이트
Gilpop8663 Oct 2, 2023
2e65460
docs: 참고자료 업데이트
Gilpop8663 Oct 2, 2023
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
10 changes: 8 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:react-hooks/recommended', 'plugin:storybook/recommended'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
'plugin:storybook/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
Expand All @@ -10,5 +15,6 @@ module.exports = {
'warn',
{ allowConstantExport: true },
],
'@typescript-eslint/no-explicit-any': 'off',
},
}
};
20 changes: 12 additions & 8 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import type { StorybookConfig } from "@storybook/react-vite";
import type { StorybookConfig } from '@storybook/react-vite';

const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
stories: [
'../src/Intro.stories.mdx',
'../src/**/*.mdx',
'../src/**/*.stories.@(js|jsx|mjs|ts|tsx)',
],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-onboarding",
"@storybook/addon-interactions",
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-onboarding',
'@storybook/addon-interactions',
],
framework: {
name: "@storybook/react-vite",
name: '@storybook/react-vite',
options: {},
},
docs: {
autodocs: "tag",
autodocs: 'tag',
},
};
export default config;
44 changes: 35 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,41 @@
# Wus-Layout-Component
## Wus Layout Component

## Introduce
## Docs

<p align="center">
It's a package made to use layout components comfortably
</p>
### <a href="https://gilpop8663.github.io/layout-component">문서 보러가기</a>

## Documentation
## Get started

For full documentation, visit [wus-layout-component.com](https://gilpop8663.github.io/layout-component/).
레이아웃 컴포넌트를 편하게 사용할 수 있도록 제작된 패키지입니다

## Contributing
### Install

If you're interested in contributing to Wus-Layout-Component
`npm i wus-layout-component -D`

### how to use?

```tsx
import { Flex } from 'wus-layout-component';

<Flex
css={css}
justifyContent={justifyContent}
direction={direction}
alignItems={alignItems}
flexWrap={flexWrap}
>
<div
style={{
width: '100px',
height: '100px',
backgroundColor: 'gray',
}}
></div>
</Flex>;
```

### Supporting

해당 패키지는 CommonJs와 ES Modules를 지원합니다.

### @2023
18 changes: 18 additions & 0 deletions docs/MasonryLayout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
목적 : 여러 크기의 아이템을 격자 형태로 정렬하되, 각 행과 열의 높이가 동일하지 않아 빈 공간이 최소화되는 레이아웃 컴포넌트를 만든다. 사용자: 무한 스크롤을 통해 정렬되어 있는 디자인을 보여줘야하는 개발자요구사항:

- 열의 수를 설정할 수 있어야 함.
- 빈 공간 없이 아이템을 정렬해야 함.
- 가로 폭을 제한해서 보여줄지, 세로 폭을 제한해서 보여줄 지 정할 수 있다.
- 반응형(모바일, 작은 화면, 큰화면)에 따라 다르게 보이도록 한다.
-

- 가로: 가로로 사용할 행의 개수
- 세로: 세로로 사용할 열의 개수
- 가로 갭: 가로에서 공백을 보여줄 단위
- 세로 갭: 세로에서 공백을 보여줄 단위

- 모바일에서 어떻게 할지 설정한다

1. 크로스 브라우징/반응형
2. 가독성 있는 컴포넌트와 문서
3. CSS 관점에서 의미론적 네이밍과 재사용성
15 changes: 15 additions & 0 deletions docs/참고자료.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,18 @@ https://toss.tech/article/commonjs-esm-exports-field
- [x] Container
- [ ] Flex
- [ ] Grid

### step2

https://wit.nts-corp.com/2022/10/26/6595

https://medium.com/@andybarefoot/a-masonry-style-layout-using-css-grid-8c663d355ebb https://ellen92.tistory.com/64 https://w3bits.com/css-grid-masonry/ https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver https://github.com/woowacourse/layout-component/pull/58/files#diff-914ac3af5acb7507102327d7a0965b7fd543635b8addd127329ef953577f70d3 (참새 PR)

https://github.com/devrelm/resize-observer/issues/23 (디바운스)

- 방향을 정한다. row, column - 현재 미구현
- 최소로 보여질 사이즈를 정한다. 개수는 부모의 너비 / 최소 사이즈로 계산되며 빈 공간 없이 최소 길이 이상으로 넓어진다. itemSize
- div로 해당 개수만큼 생성하고, flex 방향으로 채운다. 아래쪽이 울퉁불퉁한것은 무한 스크롤을 한다는 가정하에 고려하지 않는다.
- 이미지 사이즈는 itemSize에 맞추고, 이미지는 비율에 맞게 직사각형으로 조정한다.

https://devpluto.tistory.com/entry/React-vite%EC%99%80-%ED%95%A8%EA%BB%98-%EB%A6%AC%EC%95%A1%ED%8A%B8-%EC%BB%B4%ED%8F%AC%EB%84%8C%ED%8A%B8-npm%EC%97%90-%EB%B0%B0%ED%8F%AC%ED%95%98%EA%B8%B0 (vite 배포)
90 changes: 90 additions & 0 deletions docs/타입 관련 에러 해결.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
## ReactNode, ReactElement 관련 에러 발생

### ReactElement로 하였을 때

const Grid << 이 부분에서 타입 에러가 납니다. 에러는 ForwardRefExoticComponent의 반환 값이 ReactNode에 해당하지 않아서 에러가 나는 것이였습니다.

```tsx
type GridComponent = <T extends ElementType>(
props: GridProps<T>
) => ReactElement | null;

const Grid : GridComponent = forwardRef(function Grid<
```

```
Type 'ForwardRefExoticComponent<Omit<GridProps<ElementType>, "ref"> & RefAttributes<unknown>>' is not assignable to type 'GridComponent'.
Type 'ReactNode' is not assignable to type 'ReactElement<any, string | JSXElementConstructor<any>> | null'.ts(2322)
```

### 해결 방법

@types/react의 파일에서 forwardRef의 반환 값의 타입을 수정하여 타입 에러를 해결했습니다. ExoticComponent의 타입 코드 중 (props: P): ReactNode; 을 (props: P): ReactElement | null; 으로 수정하였습니다.

이 방법의 단점으로는 node_modules를 다른 컴퓨터에서 설치 후 작업할 때 동일한 과정을 해줘야 한다는 단점이 있습니다.

```tsx
function forwardRef<T, P = {}>(
render: ForwardRefRenderFunction<T, P>
): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;

// ForwardRefExoticComponent을 타고 들어갑니다.
interface ForwardRefExoticComponent<P> extends NamedExoticComponent<P> {
defaultProps?: Partial<P> | undefined;
propTypes?: WeakValidationMap<P> | undefined;
}

// NamedExoticComponent을 타고 들어갑니다.
interface NamedExoticComponent<P = {}> extends ExoticComponent<P> {
displayName?: string | undefined;
}

// ExoticComponent을 타고 들어갑니다.
interface ExoticComponent<P = {}> {
/**
* **NOTE**: Exotic components are not callable.
*/

(props: P): ReactNode; // => (props: P): ReactElement | null;

readonly $$typeof: symbol;
}
```

### ReactNode로 하였을 때

컴파일러 과정에서는 오류가 나지 않습니다. forwardRef의 반환 값과 일치하기 때문입니다.

```tsx
type ContainerComponent = <T extends ElementType>(
props: ContainerProps<T>
) => ReactNode | null;

const Container: ContainerComponent = forwardRef(
```

하지만 npm 배포 후 설치를 한다면 타입 에러가 사용자에게 납니다. 따라서 사용자가 타입 에러로 인해 잘못된 패키지를 설치했다고 생각이 들고, 직접 패키지의 타입을 수정하지 않는 이상 사용을 할 수 없는 일이 발생합니다.

```
JSX 문법에서는 컴포넌트의 반환 값이 유효한 JSX 엘리먼트 타입이어야 하기 때문에, 'Container' 컴포넌트의 반환 타입이 'ReactNode'라고 하더라도 JSX 엘리먼트로 사용할 수 없는 경우에 이러한 에러가 발생합니다.

또한, 'undefined' 타입은 JSX 엘리먼트로 사용될 수 없고, 'Element' 또는 'null' 타입에만 할당할 수 있기 때문에, 'Container' 컴포넌트의 반환 값이 'undefined'인 경우에도 에러가 발생합니다.
```

```tsx
import { Container } from 'wus-layout-component';

export default function Example() {
return <Container as="animate">asds</Container>;
}
```

```
'Container' cannot be used as a JSX component.
Its return type 'ReactNode' is not a valid JSX element.
Type 'undefined' is not assignable to type 'Element | null'.ts(2786)
```

### 결론

@types/react의 타입의 반환 값 타입을 직접 변경하여 사용하기로 했습니다. 패키지를 설치했는데 타입 에러가 난다면 사용자의 신뢰가 떨어져서 사용을 하지 않을 것이기 때문입니다.
15 changes: 0 additions & 15 deletions fixup.sh

This file was deleted.

Loading