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(shared/system, eslint-config-favolink): factory, createComponent, forwardRef 함수, 관련 type 추가, eslint any를 사용 가능하도록 관련 설정 해제 #72

Merged
merged 7 commits into from
Mar 6, 2024

Conversation

sukvvon
Copy link
Collaborator

@sukvvon sukvvon commented Mar 6, 2024

이슈 번호

작업한 목록을 작성해 주세요

스크린샷

pr 포인트나 궁금한 점을 작성해 주세요

예제 코드

// factory 예시 코드

// apply
const Box = favolink('div');

// get
// Link.tsx
import { favolink, forwardRef } from '@favolink/system';
import { classNames } from '@favolink/utils';
import { type ComponentPropsWithoutRef } from 'react';

const LINK_CLASSNAME = 'favolink-link';

type LinkProps = ComponentPropsWithoutRef<'a'> & {
  isExternal?: boolean;
};

const Link = forwardRef<LinkProps, 'a'>(function Link(props, ref) {
  const { children, as, className, isExternal = false, ...restProps } = props;

  // get
  return (
    <favolink.a
      {...restProps}
      ref={ref}
      as={as}
      target={isExternal ? '_blank' : undefined}
      rel={isExternal ? 'noopener' : undefined}
      className={classNames(LINK_CLASSNAME, className)}
    >
      {children}
    </favolink.a>
  );
});

export default Link;


// example.tsx

import { Box, Heading, Link, Text, useToast } from '@favolink/react';
import { Link as RouterLink } from 'react-router-dom';

export default function FavoliteLink() {
  const toast = useToast();

  return (
    <>
      <Heading
        as="h4"
        weight="bold"
        onClick={() => {
          toast.show({ message: 'hello world', duration: 3000, link: 'hello' });
        }}
      >
        FavoliteLink
      </Heading>
      <Text scale="1regular">hello world</Text>
      <Box as={RouterLink} to="/saved">
        hello
      </Box>
      <Box as="main">hello world!</Box>
      <Box as="section">hell</Box>
      <Link as={RouterLink} to="/saved">
        hello world
      </Link>
    </>
  );
}
  • as props를 활용하여 디자인 시스템 내부 공통 컴포넌트의 tag 및 tag의 props를 바꿀 수 있게 하는 Proxy를 활용한 factory를 추가합니다!
  • 'div' 요소, Link 커스텀 컴포넌트와 같은 것을 인자로 받는 일반적인 컴포넌트를 생성하는 함수인 createComponent를 추가합니다!
  • 기존 forwardRef에 as prop이 추가된 forwardRef 함수를 추가합니다!
  • system 관련 함수와 관련된 type을 추가합니다!

@sukvvon sukvvon requested a review from heyman333 as a code owner March 6, 2024 16:09
@sukvvon sukvvon linked an issue Mar 6, 2024 that may be closed by this pull request
4 tasks
Copy link

vercel bot commented Mar 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
favolink-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 6, 2024 4:16pm

Copy link

github-actions bot commented Mar 6, 2024

Thanks for the contribution!
I have applied any labels matching special text in your title and description.

Please review the labels and make any necessary changes.

@github-actions github-actions bot added chore 빌드 프로세스나 패키지 매니징과 같은 일상적인 업무나 유지보수 작업(빌드 시스템, 도구, 환경 설정 등) feat 새로운 기능 추가 또는 기존 기능의 확장 labels Mar 6, 2024
@sukvvon sukvvon changed the title feat(shared/system): factory, createComponent, forwardRef 함수, 관련 type 추가 feat(shared/system, eslint-config-favolink): factory, createComponent, forwardRef 함수, 관련 type 추가, eslint any를 사용 가능하도록 관련 설정 해제 Mar 6, 2024
@sukvvon sukvvon merged commit 8f0ccd1 into main Mar 6, 2024
4 checks passed
@sukvvon sukvvon deleted the feat/69 branch March 6, 2024 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore 빌드 프로세스나 패키지 매니징과 같은 일상적인 업무나 유지보수 작업(빌드 시스템, 도구, 환경 설정 등) feat 새로운 기능 추가 또는 기존 기능의 확장
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(shared/system): factory, createComponent, forwardRef 함수, 관련 type 추가
1 participant