Skip to content
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: decoratorsに対する処理を共通化できるよう、useDecoratorsを定義する #5326

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

AtsushiM
Copy link
Member

@AtsushiM AtsushiM commented Jan 23, 2025

関連URL

概要

  • 各コンポーネント内で定義しているdecoratorsの扱いが煩雑になっているため、useDecoratorsを定義、共通の仕様で扱えるようにします

変更内容

  • useDecoratsを定義
  • Textareaをお試しで置き換え

確認方法

@yagimushi yagimushi force-pushed the chore-add-use-decorators branch 7 times, most recently from 93b6e65 to 2f643da Compare January 24, 2025 00:12
@yagimushi yagimushi force-pushed the chore-add-use-decorators branch from 2f643da to 0d284e1 Compare January 24, 2025 00:18
@AtsushiM AtsushiM marked this pull request as ready for review January 24, 2025 00:27
@AtsushiM AtsushiM requested a review from a team as a code owner January 24, 2025 00:27
@AtsushiM AtsushiM requested review from misako0927 and s-sasaki-0529 and removed request for a team January 24, 2025 00:27
Copy link

pkg-pr-new bot commented Jan 24, 2025

Open in Stackblitz

npm i https://pkg.pr.new/kufu/smarthr-ui@5326

commit: 660292c

@@ -1,7 +1,7 @@
import React, { FC, KeyboardEventHandler, useCallback, useMemo } from 'react'
import { tv } from 'tailwind-variants'

import { DecoratorsType } from '../../types'
import { type DecoratorsType } from '../../libs/decorator'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type の場合は type を強制する lint ってないのかしら。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありそう。
全プロダクトonにしてもいいのでは? (可読性かなり上がりそう)
https://typescript-eslint.io/rules/consistent-type-imports/

@@ -21,6 +21,30 @@ export default {
<Textarea {...args} maxLetters={5} value="テキスト" />
<Textarea {...args} maxLetters={5} value="テキストエ" />
<Textarea {...args} maxLetters={5} value="テキストエリア" />
<Textarea
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo: decorator.ts の動作が担保されているのであれば、各コンポーネントで VRT に足す必要はなさそうに思いました。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

decorator.ts の動作が担保されているのであれば、各コンポーネントで VRT に足す必要はなさそうに思いました。

decorator自体の動作はそうですが、decoratorがどこに反映されるのか?は確認できないのでVRTに含めておくほうが良くないです?
特に今回のような処理が外部で行われる様になる場合はバグったことが検知しにくくなるのでテストしておきたい所存

export type DecoratorType = (text: string) => ReactNode

export const useDecorators = <T extends string>(
defaultTexts: { [K in T]: string },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo: デフォルトテキスト、というかは変換表だなと思った。translateTable 的な。

Copy link
Member Author

@AtsushiM AtsushiM Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

変換表

いや、指定無い場合の文字列のまとまりなんでtranslateTableだと役割の一部しか表せてない気がします
役割も翻訳だけじゃなくて違う文字列にすることも有り得るのでtranslateは不適切っぽい。

@yagimushi yagimushi force-pushed the chore-add-use-decorators branch 4 times, most recently from 7c70320 to 606ccb4 Compare January 24, 2025 23:13
@yagimushi yagimushi force-pushed the chore-add-use-decorators branch from 606ccb4 to 7f05277 Compare January 24, 2025 23:19
@AtsushiM AtsushiM requested a review from uknmr January 24, 2025 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants