feat(flex): support responsive prop values#284
Conversation
🦋 Changeset detectedLatest commit: e9034fd The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (2)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
fa78aeb to
594a33d
Compare
| type FlexBreakpoint = 'sm' | 'md' | 'lg'; | ||
| type ResponsiveValue<T> = T | Partial<Record<FlexBreakpoint, T>>; | ||
| type ResponsiveStyleVariants<T extends string> = Record<FlexBreakpoint, Record<T, string>>; |
There was a problem hiding this comment.
export 하지 않으면 사용부에서 한번 더 정의해야해서 export를 해야할꺼 같습니다~
| md: 'screen and (min-width: 780px)', | ||
| lg: 'screen and (min-width: 1060px)', |
There was a problem hiding this comment.
780/1060은 기존 @sipe-team/tokens layout breakpoint(md/lg) 값과 맞춘 값입니다. 해당 token export가 deprecated 상태라 Flex 내부에 로컬 상수로 두고, 그 맥락을 코드 주석에 추가했습니다.
| getResponsiveClassNames(direction, 'row', styles.direction), | ||
| getResponsiveClassNames(align, 'normal', styles.align), | ||
| getResponsiveClassNames(justify, 'normal', styles.justify), | ||
| getResponsiveClassNames(wrap, 'nowrap', styles.wrap), |
There was a problem hiding this comment.
이거 gap 은 없는데 혹시 의도하신 걸까요...?
gap={{ md: '16px', lg: '24px' }}처럼 sm을 생략하면
780px 미만 화면에서 --side-flex-gap-sm이 설정 안 되서
폴백 없이 무효화되고 gap이 0이 되는 것 같은데.
이게 다른 prop들과 동작이 다른데, 의도하신 걸까요?
There was a problem hiding this comment.
문의 주신 부분을 확인해보았습니다. sm을 생략한 구간에서는 Flex의 기본 gap인 normal(flex 레이아웃에서는 0)을 사용하는 동작을 의도했습니다. 다른 responsive prop도 값이 없는 기본 구간에서는 각 prop의 기본값을 사용하고 있어 같은 기준으로 보았습니다. 이번 수정에서는 이 계약이 명확하게 드러나도록 sm 기본값을 명시하고 관련 테스트를 추가했습니다. (e9034fd)
| [mediaQuery.lg]: style, | ||
| }, | ||
| })), | ||
| }); |
There was a problem hiding this comment.
responsiveGap 처럼 하나의 style() 호출 안에서
@media 우선순위를 명시하는 방식으로 바꾸는 게 더 안전할 것 같습니다.
나중에 이 함수 근처에 다른 mediaQuery.lg 참조가 먼저 추가되거나
객체 프로퍼티 순서가 바뀌면,
lg 값이 적용돼야 할 1060px 이상 화면에서 md 값이 대신 적용되는 일이 생길 수도 있을 것 같습니다.
There was a problem hiding this comment.
말씀해주신 것처럼 1060px 이상에서는 md와 lg 조건이 함께 적용되므로 최종 CSS 선언 순서가 중요하다고 보았습니다. 실제 빌드 결과를 확인한 결과, 현재 responsiveGap의 단일 style()에 선언된 md → lg 순서가 같은 파일의 미디어 규칙 정렬에 반영되어 md 블록 다음에 lg 블록이 생성되고 있었습니다. 이번 변경 후에도 해당 순서가 유지되는 것을 다시 확인했으며, 현재 구조에서는 lg 값이 정상적으로 우선 적용되고 있어 이 부분은 기존 구현을 유지했습니다.
|
@KYBee 질문이 있습니다. 의 케이스에 대해서, 코드를 작성하는 입장에서는, 자식 요소의 Flex gap 속성 값이 나중에 Flex 를 매우 복잡하게 사용해야 할 때는, 의도치 못한 이슈가 발생할 수도 있을 것 같은데. |
|
@G-hoon 문의 주신 중첩 케이스를 확인해보았습니다. 이번 responsive API는 별도로 참고한 특정 컴포넌트나 라이브러리 구현은 없으며, 기존 확인 과정에서 CSS custom property가 상속되면서 자식 Flex가 생략한 breakpoint에서 부모의 gap 값을 가져오는 문제가 있었습니다. 의도한 동작은 아니어서, 자식 Flex가 각 breakpoint 값을 자체 기본값과 직전 breakpoint 값으로 해석하도록 수정했습니다. 예시의 자식 |
Changes
Flex의 기존 단일 값 prop 계약을 유지하면서{ sm, md, lg }responsive 값을 추가로 받을 수 있도록 확장했습니다.direction,align,justify,wrap,gap에서 단일 값과 breakpoint 객체 값을 모두 지원합니다.@sipe-team/tokens에 정식 breakpoint token이 정의되면, 외부 사용 방식은 유지하고 내부 구현만 token 기반으로 교체할 수 있습니다.@sipe-team/flexminor /@sipe-team/sidepatch changeset을 추가했습니다.Visuals
Flex/Responsive예시를 추가했습니다.Checklist
Additional Discussion Points
sipe.team마이그레이션은 이 PR 배포 이후 별도 PR에서 진행할 수 있습니다.Validation
mise exec -- pnpm --filter @sipe-team/flex test -- run src/Flex.test.tsxmise exec -- pnpm --filter @sipe-team/flex typecheckmise exec -- pnpm --filter @sipe-team/flex lintmise exec -- pnpm --filter @sipe-team/flex buildmise exec -- pnpm --filter @sipe-team/side typecheckmise exec -- pnpm --filter @sipe-team/side buildgit diff --check origin/dev..HEAD