-
Notifications
You must be signed in to change notification settings - Fork 49
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
Migrate Divider
component with scss
#1861
Migrate Divider
component with scss
#1861
Conversation
- it had been exported from styled component
|
Chromatic Report🚀 Congratulations! Your build was successful! |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## alpha #1861 +/- ##
==========================================
- Coverage 86.37% 86.27% -0.11%
==========================================
Files 275 274 -1
Lines 3765 3751 -14
Branches 795 789 -6
==========================================
- Hits 3252 3236 -16
Misses 434 434
- Partials 79 81 +2 ☔ View full report in Codecov by Sentry. |
}) | ||
const divider = getByTestId(DIVIDER_TEST_ID) | ||
|
||
expect(divider).toHaveStyle('margin: 6px') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ orientation: 'horizontal' }
속성을 주었을 때 horizontal
classname 을 갖는 것을 테스트하는 것은 무의미하다고 생각하여 지웠습니다
@@ -1,3 +1,2 @@ | |||
export { default as Divider } from './Divider' | |||
export { Divider, DIVIDER_THICKNESS } from './Divider' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SegmentedControlIndicator
에서 사용됩니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DIVIDER_THICKNESS
의 중복을 줄이면 더 좋을 거 같은데요, 어떤 방법이 좋을지 고민입니다.
- scss export를 써서(
export:
) scss에서 DIVIDER_THICKNESS를 export한다...
$DIVIDER_THICKNESS: 1;
:export {
DIVIDER_THICKNESS: $DIVIDER_THICKNESS;
}
styles/
디렉터리에 전역 components layer의 css variable을 만든다... 이 편이 더 CSS스럽고 특정 기술에 덜 의존적이라 1번보다는 마음에 듭니다.
@layer components {
--b-divider-thickness: 1px;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
둘다 좋아보이지만 고르라면 저도 2번 인 것 같습니다!
-> 다시 생각해보니 2번으로 하면 divider 관련 상수가 divider 로부터 멀리 떨어지는 것이 아쉬워지네요. 그리고 이렇게 selector 없이 css variable 만 선언할 수 있나요? :where(:root) 같은 selector 를 선언하기 애매한 부분도 있는 것 같아요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 이렇게 selector 없이 css variable 만 선언할 수 있나요? -> 예시를 잘못 작성했어요. :where(:root) 같은 selector 필요합니다..!
전역으로 이동하는 게 애매하다면... 이런 식으로 해볼 수도 있을 거 같아요
.Divider {
.variables {
--b-divider-thickness: 1px;
}
/* ... */
}
import dividerStyles from '../../Divider.module.scss'
divdierStyles.variables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이렇게 해서 dividerStyles.variables
를 가져와도 className이라서 css variable를 가져오는 것과는 다른 것 같습니다. 아마 js에서 css 에서 선언된 변수를 가져오기는 어려운 걸로 알고 있어요.
그래서 divider.tsx 에서 DIVIDER_THICKNESS
를 css variable(--b-divider-thickness
)로서 넘기고, 다른 컴포넌트에서 사용한다면 DIVIDER_THICKNESS
를, 다른 css 파일에서 사용한다면 --b-divider-thickness
를 import 해서 쓰게 하면 될 것 같네요 (431bea4)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제가 컨텍스트를 하나 건너뛰었네요. 이 부분이 적용되려면 SegmentedControlIndicator
의 스타일링 방식도 JS 변수 -> 인라인 스타일 주입에서 CSS 내부에서 css variable을 사용해서 calc하는 방식으로 변경되어야할 거 같아요.
이건 제가 후속 PR로 SegmentedControl scss 마이그레이션하면서 css variable만 사용할 수 있도록 리팩토링해볼게요
|
||
&.without-indent { | ||
width: 100%; | ||
margin: 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Divider가 가지고 있는 margin 속성의 우선순위때문에(nested selector) 공통 margin prop이 적용되지 않는 문제가 있습니다.
- 더 나아가서 margin prop을 지원하지 않는게 좋다고 생각해요. 저희 디자인 시스템의
Divider
컴포넌트는 특이하게 컴포넌트 외부의 margin 또한 컴포넌트 스펙의 일부여서(DIVIDER_INDENT_SIZE 6px
) 이 값을 커스텀할 수 있게 하면 안될 거 같아요..! 어떻게 생각하시는지 궁금합니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아하 그렇네요..! 지원안하는 것으로 변경하겠습니다
@@ -1,3 +1,2 @@ | |||
export { default as Divider } from './Divider' | |||
export { Divider, DIVIDER_THICKNESS } from './Divider' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DIVIDER_THICKNESS
의 중복을 줄이면 더 좋을 거 같은데요, 어떤 방법이 좋을지 고민입니다.
- scss export를 써서(
export:
) scss에서 DIVIDER_THICKNESS를 export한다...
$DIVIDER_THICKNESS: 1;
:export {
DIVIDER_THICKNESS: $DIVIDER_THICKNESS;
}
styles/
디렉터리에 전역 components layer의 css variable을 만든다... 이 편이 더 CSS스럽고 특정 기술에 덜 의존적이라 1번보다는 마음에 듭니다.
@layer components {
--b-divider-thickness: 1px;
}
|
||
interface DividerOptions { | ||
interface DividerOwnProps { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
약간 변덕스럽게 **Options interface를 더 잘 어울리는 거 같다는 이유로 조용히 **OwnProps로 변경했었는데... 적용해주셔서 감사합니다 ㅎㅎ
Self Checklist
Related Issue
Summary
Divider
컴포넌트의 스타일링을 styled-components 에서 scss 으로 변경합니다.Details
Divider
컴포넌트의 인터페이스에MarginProps
가 추가됩니다.Breaking change? (Yes/No)
References