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

Writing code to convert Stack to LegacyStack & AlphaStack to Stack #1813

Closed
Tracked by #1800
yangwooseong opened this issue Dec 15, 2023 · 1 comment · Fixed by #1836
Closed
Tracked by #1800

Writing code to convert Stack to LegacyStack & AlphaStack to Stack #1813

yangwooseong opened this issue Dec 15, 2023 · 1 comment · Fixed by #1836
Assignees
Labels
bezier-codemod Issue or PR related to bezier-codemod

Comments

@yangwooseong
Copy link
Collaborator

yangwooseong commented Dec 15, 2023

Summary

V2부터는 기존의 StackStackItem 을 섞어서 사용하던 방식을 지원 중단하고 AlphaStack 사용을 권장하게 됩니다. 따라서 이를 사용하는 기존의 코드를 마이그레이션하는 codemod 를 작성합니다.

Description

// As-is
import { HStack, StackItem, Spacer } from '@channel.io/bezier-react' // HStack, Stack 까지 고려

<HStack>
  <StackItem>
    { SomeElement }
  </StackItem>
  <Spacer />
  <StackItem>
    { SomeElement }
  </StackItem>
</HStack>

// To-be
import { LegacyHStack, LegacyStackItem, LegacySpacer } from '@channel.io/bezier-react'

<LegacyHStack>
  <LegacyStackItem>
    { SomeElement }
  </LegacyStackItem>
  <LegacySpacer />
  <LegacyStackItem>
    { SomeElement }
  </LegacyStackItem>  
</LegacyHStack>
// As-is
import { AlphaStack } from '@channel.io/bezier-react'

<AlphaStack direction="horizontal">
  { SomeElement }
</AlphaStack>

// To-be
import { Stack } from '@channel.io/bezier-react'

<Stack direction="horizontal">
  { SomeElement }
</Stack
@yangwooseong yangwooseong added the bezier-codemod Issue or PR related to bezier-codemod label Dec 15, 2023
@sungik-choi
Copy link
Contributor

(+ Spacer!)

@yangwooseong yangwooseong self-assigned this Dec 18, 2023
yangwooseong added a commit that referenced this issue Dec 19, 2023
<!--
  How to write a good PR title:
- Follow [the Conventional Commits
specification](https://www.conventionalcommits.org/en/v1.0.0/).
  - Give as much context as necessary and as little as possible
  - Prefix it with [WIP] while it’s a work in progress
-->

## Self Checklist

- [x] I wrote a PR title in **English** and added an appropriate
**label** to the PR.
- [x] I wrote the commit message in **English** and to follow [**the
Conventional Commits
specification**](https://www.conventionalcommits.org/en/v1.0.0/).
- [x] I [added the
**changeset**](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md)
about the changes that needed to be released. (or didn't have to)
- [x] I wrote or updated **documentation** related to the changes. (or
didn't have to)
- [x] I wrote or updated **tests** related to the changes. (or didn't
have to)
- [x] I tested the changes in various browsers. (or didn't have to)
  - Windows: Chrome, Edge, (Optional) Firefox
  - macOS: Chrome, Edge, Safari, (Optional) Firefox

## Related Issue
<!-- Please link to issue if one exists -->

<!-- Fixes #0000 -->

- Fixes #1813 

## Summary
<!-- Please brief explanation of the changes made -->

- `Stack`을 `LegacyStack`으로, `AlphaStack`을 `Stack`으로 변환하는 codemod 를
추가합니다.

## Details
<!-- Please elaborate description of the changes -->

- 변경사항은 다음과 같습니다. 
- As-is

```tsx
import { VStack, StackItem, AlphaStack } from "@channel.io/bezier-react";

function Foo() {
  return (
    <VStack>
      <StackItem>
        <div />
      </StackItem>
      <StackItem>
        <div />
      </StackItem>
    </VStack>
  );
}

function Bar() {
  return (
    <AlphaStack direction="horizontal">
      <div />
      <div />
    </AlphaStack>
  );
}
```

- To-be 

```tsx
import { LegacyVStack, LegacyStackItem, Stack } from "@channel.io/bezier-react";

function Foo() {
  return (
    <LegacyVStack>
      <LegacyStackItem>
        <div />
      </LegacyStackItem>
      <LegacyStackItem>
        <div />
      </LegacyStackItem>
    </LegacyVStack>
  );
}

function Bar() {
  return (
    <Stack direction="horizontal">
      <div />
      <div />
    </Stack>
  );
}
```

- `AlphaStack`에서 `Alpha`를 떼어낼 때, 같은 파일내에서 이미 다른 변수로 `Stack` 을 선언했다면 변수가
중복되어 컴파일 에러가 뜹니다. 해당 케이스는 사용처에 책임을 넘기는 게 좋을 듯 하여 별도로 방어 코드를 작성하지는 않았습니다.

### Breaking change? (Yes/No)
<!-- If Yes, please describe the impact and migration path for users -->

- No

## References
<!-- Please list any other resources or points the reviewer should be
aware of -->

- #1813
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bezier-codemod Issue or PR related to bezier-codemod
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants