feat(flex): support responsive prop values#284
Conversation
🦋 Changeset detectedLatest commit: f4f7b57 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들과 동작이 다른데, 의도하신 걸까요?
| [mediaQuery.lg]: style, | ||
| }, | ||
| })), | ||
| }); |
There was a problem hiding this comment.
responsiveGap 처럼 하나의 style() 호출 안에서
@media 우선순위를 명시하는 방식으로 바꾸는 게 더 안전할 것 같습니다.
나중에 이 함수 근처에 다른 mediaQuery.lg 참조가 먼저 추가되거나
객체 프로퍼티 순서가 바뀌면,
lg 값이 적용돼야 할 1060px 이상 화면에서 md 값이 대신 적용되는 일이 생길 수도 있을 것 같습니다.
|
@KYBee 질문이 있습니다. 의 케이스에 대해서, 코드를 작성하는 입장에서는, 자식 요소의 Flex gap 속성 값이 나중에 Flex 를 매우 복잡하게 사용해야 할 때는, 의도치 못한 이슈가 발생할 수도 있을 것 같은데. |
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