-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Set up SCSS module environment(ts, storybook) and change Spinner
to classname-based styling
#1488
Set up SCSS module environment(ts, storybook) and change Spinner
to classname-based styling
#1488
Conversation
|
Chromatic Report🚀 Congratulations! Your build was successful! |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## styled-system #1488 +/- ##
=================================================
- Coverage 87.31% 87.27% -0.05%
=================================================
Files 280 279 -1
Lines 3848 3835 -13
Branches 805 806 +1
=================================================
- Hits 3360 3347 -13
Misses 415 415
Partials 73 73
☔ View full report in Codecov by Sentry. |
declare module '*.module.scss' { | ||
const classes: { [className: string]: string } | ||
export default classes | ||
} |
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.
SCSS 모듈을 위한 전역 타입 선언을 추가합니다.
size = SpinnerSize.M, | ||
color, | ||
...rest | ||
}, forwardedRef) { | ||
const Element = as || 'div' |
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.
styled-components의 as
prop은 이러한 방식으로 직접 구현해주어야합니다.
style={{ | ||
'--bezier-spinner-color': color ? `var(--${color})` as const : undefined, | ||
...style, | ||
}} | ||
className={classNames( | ||
styles.Spinner, | ||
styles[size], | ||
className, | ||
)} |
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.
동적 스타일은 style, 정적 스타일은 className으로 구현합니다.
height: $size; | ||
} | ||
|
||
@layer components { |
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.
@@ -46,7 +46,7 @@ module.exports = { | |||
position: 'after', | |||
}, | |||
{ | |||
pattern: './**/*.styled', | |||
pattern: './**/*.+(styled|scss)', |
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.
import/order 규칙이 scss도 지원하도록 개선합니다.
describe('Spinner >', () => { | ||
const renderSpinner = (props?: React.ComponentProps<typeof Spinner>) => render( | ||
<Spinner {...props} />, |
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.
jest & testing-library에서 css를(className은 가능) jsdom에 제대로 모킹하지 못하는 문제가 있습니다. 이를 해결하고자 리서치를 해봤지만 마땅한 해결책은 없었습니다.
#1330 에서 제안하는 유닛 테스트의 책임을 명확히하고, 테스트를 적절한 방식으로 변경하는 방향으로 문제를 해결하고자 했습니다. 즉, 상세한 스타일(css)에 대한 검증은 유닛 테스트에선 진행하지 않는 것입니다.
- 컴포넌트가 엘리먼트를 잘 렌더하는지
BezierComponentProps
인터페이스를 잘 준수하는지- 클래스 네임이 의도대로 설정되는지
이 PR에선 위 3가지를 검증하기 위한 테스트 케이스로 변경했습니다.
- 이후 스타일에 대한 검증은 Chromatic 사용 방식을 개선하여 시각적 회귀 테스트를 작성하는 방향으로 진행해볼 예정입니다.
- 더 복잡한 테스트가 필요한 경우, Storybook의 Interaction test, A11y test 등을 적용해볼 예정입니다.
f9fd8e7
to
14c4deb
Compare
b0e0918
to
0cecad0
Compare
… classname-based styling (#1488) * chore(d.ts): add scss module declaration * style(eslint): add scss module pattern to eslint import order rule * test(story): sass environment setting * feat(spinner): change to classname-based styling * docs(component-props): deprecated interpolation prop * refactor(d.ts): change target module pattern * chore(storybook): delete mock style * refactor(spinner): rename component to element * chore(env): enhance to support CSS modules in TS * fix: delete unused ts interface * chore(styles): apply temporary relative path * style(storybook): apply tilde alias * fix(spinner): fix xl size * refactor(spinner): use mixin * test(spinner): rm test cases that don't work * test: update snapshot * test(spinner): enhance * test(spinner): add test case for forward ref * chore: change code owner * test(spinner): add test case for color prop
Self Checklist
CODEOWNERS
file.Related Issue
Summary
Spinner
에 class name 기반의 스타일링을 적용합니다.@storybook/addon-styling
패키지를 추가하여 sass를 지원하도록 합니다.typescript-plugin-css-modules
플러그인 및 vscode에서 workspace의 ts를 사용하도록 변경합니다. 더 안전하게 CSS 모듈을 사용할 수 있도록 합니다.Details
자세한 내용은 셀프 코드 리뷰로 남깁니다.
Breaking change or not (Yes/No)
Yes
interpolation
prop이 deprecated 됩니다.SpinnerThickness
enum이 deprecated 됩니다.References