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

ActionButtonに他カラーを追加 #302

Merged
merged 13 commits into from
Apr 13, 2021
Merged

ActionButtonに他カラーを追加 #302

merged 13 commits into from
Apr 13, 2021

Conversation

hirokikondo86
Copy link
Contributor

@hirokikondo86 hirokikondo86 commented Apr 13, 2021

Ref

DST #2715
XD

やったこと

  • Warningを追加
  • color prop を追加し、primary, warning, disable を選択可能(後方互換性を保つためオプショナルです)
  • デフォルトではprimaryが選択される
  • Disabledを追加
  • onClickは反応しない

スクショ

Before

image

After

image

確認方法

https://deploy-preview-302--ingred-ui.netlify.app/?path=/story/components-inputs-actionbutton--example

@hirokikondo86 hirokikondo86 self-assigned this Apr 13, 2021
@netlify
Copy link

netlify bot commented Apr 13, 2021

Deploy preview for ingred-ui ready!

Built with commit dab0056

https://deploy-preview-302--ingred-ui.netlify.app

@hirokikondo86
Copy link
Contributor Author

type=っていう風にしたいけど、button要素がデフォルトで持ってるtypeと被るので一旦modeでいく。

@hirokikondo86
Copy link
Contributor Author

buttonがデフォルトでdisabledを持っているが、type="disabled"っていう風な指定をできるようにするべきかどうか。

@hirokikondo86
Copy link
Contributor Author

hirokikondo86 commented Apr 13, 2021

buttonがデフォルトでdisabledを持っているが、type="disabled"っていう風な指定をできるようにするべきかどうか。

modeではなくcolorという命名にして、デフォルトのdisabledを使う。
(Buttonコンポーネントもそうしてるっぽい)

@hirokikondo86 hirokikondo86 marked this pull request as ready for review April 13, 2021 05:04
@hirokikondo86 hirokikondo86 requested a review from a team as a code owner April 13, 2021 05:04
@hirokikondo86 hirokikondo86 requested review from ryokosuge and noronaoki and removed request for a team and ryokosuge April 13, 2021 05:04
@noronaoki
Copy link
Contributor

@hirokikondo86 Disabledにhoverした時のマウスカーソルの形状を、他のコンポーネントと同様にしてください

Copy link
Contributor

@noronaoki noronaoki left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 12 to 21
export type ActionButtonColorStyle = {
normal: {
background: string;
color: string;
};
hover: {
background: string;
color: string;
};
};
Copy link
Contributor

Choose a reason for hiding this comment

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

これ、 export する必要あるかな?このComponent以外で使ってなさそう

Copy link
Contributor Author

Choose a reason for hiding this comment

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

使ってないですね…。
今後どこかで使うかもみたいな感覚で書いていたのですがやっぱよくないですよね…。
修正します…!

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.

あ、ActionButtonColorStyleはstyledで使ってました…!
ただ、上のActionButtonColorは使ってないのでそっちを修正します!

Copy link
Contributor

Choose a reason for hiding this comment

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

あーだとしたら、双方向でimportしてるのなんかおかしい気がする
お互いに依存しあっちゃってるな

Comment on lines 10 to 14
const getBackgroundColor = (theme: Theme) => ({
primary: theme.palette.background.hint,
warning: theme.palette.danger.highlight,
disabled: theme.palette.gray.light,
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

関数名だけ見るとこいつ背景色全部取ってきそうなので、AtNormalとかの方が範囲狭められてよさそう。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

通常

normal
usual
common:
general 

共通してないので、commonとかgeneralは違いそう。
usualもいつものっていう意味合いがありそうなので違いそう。
やっぱnormalなのかな…?

Comment on lines 5 to 6
backgroundColorAtNormal: string;
backgroundColorAtHover: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

normalBackgroundColor: string;
hoverBackgroundColor: string;

の方が読みやすいかな

const getColorByDisabled = (
color: ColorProp,
disabled?: boolean,
): string => {
Copy link
Contributor

Choose a reason for hiding this comment

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

string じゃなくて ColorProp | 'disabled' みたいに厳格に型詰めていきましょう

};

const colorForStyle = getColorByDisabled(color, disabled);
const normalBackgroundColor = getBackgroundColorAtNormal(theme)[
Copy link
Contributor

Choose a reason for hiding this comment

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

getBackgroundColorAtNormal は変えない?

const normalBackgroundColor = getBackgroundColorAtNormal(theme)[
colorForStyle
];
const hoverBackgroundColor = getBackgroundColorAtHover(theme)[
Copy link
Contributor

Choose a reason for hiding this comment

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

getBackgroundColorAtHover こっちもかな

Copy link
Contributor Author

Choose a reason for hiding this comment

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

完全に見逃してた…。修正します!🙇‍♂️

Copy link
Contributor

@ryokosuge ryokosuge left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@hirokikondo86 hirokikondo86 merged commit ad9c09d into master Apr 13, 2021
@hirokikondo86 hirokikondo86 deleted the action-btn-color branch April 13, 2021 09:29
@hirokikondo86 hirokikondo86 added the enhancement New feature or request label Apr 14, 2021
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

3 participants