-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: AnchorButton の disabledDetail 対応 (#5133)
- Loading branch information
Showing
6 changed files
with
204 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
packages/smarthr-ui/src/components/Button/DisabledDetail.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React, { type FC } from 'react' | ||
import { tv } from 'tailwind-variants' | ||
|
||
import { FaCircleInfoIcon } from '../Icon' | ||
import { Tooltip } from '../Tooltip' | ||
|
||
type DisabledDetailProps = { | ||
button: React.JSX.Element | ||
disabledDetail: { | ||
icon?: React.FunctionComponent | ||
message: React.ReactNode | ||
} | ||
} | ||
|
||
const disabledDetailStyle = tv({ | ||
slots: { | ||
disabledWrapper: [ | ||
'smarthr-ui-Button-disabledWrapper', | ||
'shr-inline-flex shr-items-center shr-gap-0.25', | ||
], | ||
disabledTooltip: [ | ||
'shr-overflow-y-visible', | ||
/* Tooltip との距離を変えずに反応範囲を広げるために negative space を使う */ | ||
'[&_.smarthr-ui-Icon]:-shr-m-0.25', | ||
/* global style��どでborder-boxが適用されている場合表示崩れを起こす為、content-boxを指定する */ | ||
'[&_.smarthr-ui-Icon]:shr-box-content', | ||
'[&_.smarthr-ui-Icon]:shr-p-0.25', | ||
'[&_.smarthr-ui-Icon]:shr-text-grey', | ||
], | ||
}, | ||
}) | ||
|
||
export const DisabledDetail: FC<DisabledDetailProps> = ({ button, disabledDetail }) => { | ||
const { disabledWrapper, disabledTooltip } = disabledDetailStyle() | ||
const DisabledDetailIcon = disabledDetail.icon ?? FaCircleInfoIcon | ||
|
||
return ( | ||
<div className={disabledWrapper()}> | ||
{button} | ||
<Tooltip | ||
message={disabledDetail.message} | ||
triggerType="icon" | ||
horizontal="auto" | ||
vertical="auto" | ||
className={disabledTooltip()} | ||
> | ||
<DisabledDetailIcon /> | ||
</Tooltip> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.