-
Notifications
You must be signed in to change notification settings - Fork 141
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
chore: Heading/LanguageSwitcher, Icon, InformationPanelの内部ロジックを整理する #5433
base: master
Are you sure you want to change the base?
Conversation
const ARROW_KEY_REGEX = /^Arrow(Up|Down|Left|Right)$/ | ||
const ARROW_UPS_REGEX = /^Arrow(Up|Left)$/ | ||
|
||
const appLauncher = tv({ | ||
const ON_KEY_DOWN_CONTENT = (e: KeyboardEvent<HTMLDivElement>) => { |
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.
stateなどと依存関係がないため、定数化しました
commit: |
const ARROW_KEY_REGEX = /^Arrow(Up|Down|Left|Right)$/ | ||
const ARROW_UPS_REGEX = /^Arrow(Up|Left)$/ | ||
|
||
const appLauncher = tv({ | ||
const ON_KEY_DOWN_CONTENT = (e: KeyboardEvent<HTMLDivElement>) => { |
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.
imo: 関数も大文字にするの見慣れない感じがしました。特に定数感を強めなくても handleKeyDownContent
や keyDownContentHandler
などでも十分に見えます。
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.
あー、どうなんだろう。
一応定数であることを明示するメリットはあるかなーと思いますが...
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.
(個人的には)あまり見慣れないなぁと思いました。
JS でファイルグローバルにある関数はみんな定数としての関数なのか? という感じ。
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.
難しいな。
でも関数が定数形式の名称になってると、実行するときとかに違和感あるのは 🦀 なので キャメルケースに変更します。
onかhandleかはどうしましょうね....
#5433 (comment)
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.
キャメルケースに戻すのは自分に良さそうに思いました!
on or handleですが、Reactに合わせるならhandle
が良いかもしれませんね〜!
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.
onになりました。
https://kufuinc.slack.com/archives/CGC58MW01/p1741237708852539
まとめ
- どちらかに明確なメリットはないため、厳格に決定する必要はなさそう
- その上で、smarthr-uiはコンポーネントライブラリなので既に
onXxxx
系の属性が存在する - 最終的にonXxxx系属性に設定されることになるものはonXxxxという名前にしたほうがわかりやすい
- 逆にonXxxx系属性に設定されない関数に関してはこのルールを適用することはない(しない方が良い場合が多い)
- 上記から記述的に短いこともありonXxxxというフォーマットを採用します
packages/smarthr-ui/src/components/Header/LanguageSwitcher/LanguageSwitcher.tsx
Show resolved
Hide resolved
packages/smarthr-ui/src/components/InformationPanel/InformationPanel.tsx
Show resolved
Hide resolved
packages/smarthr-ui/src/components/InformationPanel/InformationPanel.tsx
Show resolved
Hide resolved
packages/smarthr-ui/src/components/InformationPanel/InformationPanel.tsx
Show resolved
Hide resolved
@@ -150,7 +153,7 @@ export const LanguageSwitcher: FC<Props & ElementProps> = ({ | |||
className={classNames.switchButton} | |||
label={decoratedTexts.triggerLabel} | |||
/> | |||
<DropdownContent onKeyDown={ON_KEY_DOWN_CONTENT} role="presentation"> | |||
<DropdownContent role="presentation" onKeyDown={ON_KEY_DOWN_CONTENT}> |
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.
ここも同様の理由でキャメルケースに戻すと良いですかね?
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.
細かいところですがコメントしました!
…format-class-name-generator-5
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.
yay!!
関連URL
概要
変更内容
確認方法