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

Notification Badgeの追加 #31

Merged
merged 14 commits into from
May 27, 2020
Merged

Notification Badgeの追加 #31

merged 14 commits into from
May 27, 2020

Conversation

youchann
Copy link
Contributor

No description provided.

@youchann youchann added the enhancement New feature or request label May 19, 2020
@youchann youchann self-assigned this May 19, 2020
Comment on lines 4 to 9
export type Props = {
content?: number | string;
position?: Styled.BadgeProps["position"];
size?: Styled.BadgeProps["size"];
max?: number;
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

依存の方向を1つにしたいので、styled.tsに型を置いている。。

Copy link
Contributor

Choose a reason for hiding this comment

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

型はNotificationBadge.tsxに置きたいな
styled側で三項演算子でstyle変えてるけど、判定後の値を渡すのではダメなんだろうか?

参考

fontWeight={color === "cancel" ? "normal" : "bold"}

background-color: ${({ theme }) => theme.palette.danger.main};
font-size: 0.75rem;
font-weight: bold;
z-index: 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

<Container />z-index指定していないので、全体に影響することはない。
Material-UIのBadgeで指定されていたから追加したけど、いらないような...:thinking:

Copy link
Contributor

Choose a reason for hiding this comment

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

不要なら消そう?

border-radius: 10rem;
color: ${({ theme }) => theme.palette.text.white};
background-color: ${({ theme }) => theme.palette.danger.main};
font-size: 0.75rem;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

今回はMaterial-UIにならってrem指定なのですが、相対値指定でのデメリットってありますかね...?

Copy link
Contributor

Choose a reason for hiding this comment

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

ingred-ui上でremにしないといけない理由があるのならそれで大丈夫だよ
inngred-uiではhtmlのfont-sizeに干渉しないので意図したsizeになるかは気になる

Copy link
Contributor Author

Choose a reason for hiding this comment

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

htmlのfont-sizeに干渉しないので意図したsizeになるかは気になる

確かにそうなので、pxで固定します!!

size変えたいニーズが出てきた時点で、修正を加える予定。

variant === "normal" ? "20px" : dotSizeMapping[size]};
min-width: ${({ variant, size }) =>
variant === "normal" ? "20px" : dotSizeMapping[size]};
padding: 0 ${({ variant }) => (variant === "normal" ? "6px" : 0)} 1px;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

末尾の1pxは指摘があって当てたのですが↓
https://cartaholdings.slack.com/archives/CKYAWNNLX/p1589886510429700?thread_ts=1589882789.427700&cid=CKYAWNNLX

なぜ1pxずれるのかがわからない....

Copy link
Contributor

Choose a reason for hiding this comment

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

line-height: 1にしたら直ったりしないかな?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

直らなかったです...

他の要素に影響はなさそうなので、このままでも良いかなという判断。

@youchann youchann requested a review from kinokoruumu May 20, 2020 00:43
@kinokoruumu
Copy link
Contributor

スクリーンショット 2020-05-20 15 21 34

バッジの中心が指定ポジションに来るっていうので合ってるのかな?
バッジの端が指定ポジションに来る方がいい気がした

@youchann
Copy link
Contributor Author

@kinokoruumu

※以降もコメは返していきますが、急ぎではないので返信は明日でも大丈夫です!!一気に評価会資料書いちゃってください!!!

端を軸にすると、ある程度大きい要素にBadgeつけた時に違和感がある気がしています...

  • Material-UIも同じ
  • 長い文字列を入れるケースは少なそう

なので、現行のままでいきたいです!!!

スクリーンショット 2020-05-20 16 02 16

@kinokoruumu
Copy link
Contributor

kinokoruumu commented May 20, 2020

@kinokoruumu

※以降もコメは返していきますが、急ぎではないので返信は明日でも大丈夫です!!一気に評価会資料書いちゃってください!!!

ありがとう!!!:sob::sob::sob:
資料落ち着いたら見ます!!

@youchann
Copy link
Contributor Author

@kinokoruumu

Drawerをingred-uiに乗っける時のココ↓に使えそうなので、お手隙でみていただけると:bow:

image

@kinokoruumu
Copy link
Contributor

sizeがdotの時しか反映されないのが気になった
そもそもdotのサイズって可変にしたんだっけ?

vertical-align: middle;
`;

export type BadgeProps = {
Copy link
Contributor

Choose a reason for hiding this comment

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

exportしてるけど使ってなさそう?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

使わなくなって、対応漏れですね...

@youchann
Copy link
Contributor Author

sizeがdotの時しか反映されないのが気になった
そもそもdotのサイズって可変にしたんだっけ?

XDに3サイズ書かれてあったので、可変だという判断でした。
自分的にはあまり気にならないのですが、不変にした方がいいですかね....??

@youchann youchann requested a review from kinokoruumu May 22, 2020 06:25
Copy link
Contributor Author

@youchann youchann left a comment

Choose a reason for hiding this comment

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

ほぼMaterial-uiになりました。

Comment on lines +52 to +53
line-height: 1;
padding: 0 ${({ variant }) => (variant === "normal" ? "6px" : 0)};
Copy link
Contributor Author

@youchann youchann May 22, 2020

Choose a reason for hiding this comment

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

line-height当てたんですけど、変わってますかね....?

僕見た感じ、変わってなくて...

border-radius: 10rem;
color: ${({ theme }) => theme.palette.text.white};
background-color: ${({ theme }) => theme.palette.danger.main};
font-size: 10.5px;
font-weight: bold;
transition: transform 0.3s;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

badgeが消える時にアニメーションがつくようになりました

@youchann
Copy link
Contributor Author

@kinokoruumu お手隙でご確認ください:bow:

@youchann
Copy link
Contributor Author

@kinokoruumu
すいません、line-heightが反映されているかアンケート取ろうという話でしたが、ブランチ環境だと自分のPCでもしっかり反映されていました。

よって、現行のままで問題ないと思います:bow:

| {
variant: "normal";
badgeContent: number;
dotSize?: never;
Copy link
Contributor

Choose a reason for hiding this comment

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

なんでneverにしてるんだろう?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

あ、この辺variantをoptionalにしない代わりに型を動的に変えるようにしてみました。

上のコードだと「variantnormalの時にはdotSizeを定義できない」ようにしたいのでnever型が適切だと考えたのですが、他に良い型あったりしますかね...??

Copy link
Contributor

Choose a reason for hiding this comment

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

OmitかExcludeで実現できないだろうか?

@youchann
Copy link
Contributor Author

export type Props =
  | ({
      variant: "dot";
    } & Omit<BaseProps, "BadgeContent" | "max" | "showZero">)
  | ({
      variant: "normal";
      badgeContent: number;
    } & Omit<BaseProps, "dotSize">)
  | ({
      variant: "normal";
      badgeContent: string;
    } & Omit<BaseProps, "max" | "dotSize" | "showZero">);

これだとmax,dotSize,showZeroがpropsの引数に入れられないと怒られたので、Excludeを使ってみる。(Excludeは結局never型を当てるらしいけども...

@youchann
Copy link
Contributor Author

variantによって他のキーを使う/使わないを決めたいので、Excludeは今回の目的にそぐわないかもしれない。

@youchann
Copy link
Contributor Author

  • Omit -> 期待通りの動作にならない
  • Exclude -> 今回の利用法にはそぐわない

ということで元に戻しました。

@youchann youchann requested a review from kinokoruumu May 27, 2020 07:27
Copy link
Contributor

@kinokoruumu kinokoruumu left a comment

Choose a reason for hiding this comment

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

neverはちょっと自分でも調べてみる!
このPRとしてはLGTMです!

@youchann youchann merged commit 21ca6e3 into master May 27, 2020
@youchann youchann deleted the add-notification-badge branch May 27, 2020 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants