Skip to content

Commit

Permalink
fix!: FloatAreaのresponseMessage属性の型を実装に合わせて調整する (#5299)
Browse files Browse the repository at this point in the history
  • Loading branch information
AtsushiM authored Jan 28, 2025
1 parent 849fc30 commit 0fd3afa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
22 changes: 6 additions & 16 deletions packages/smarthr-ui/src/components/FloatArea/FloatArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { ComponentPropsWithoutRef, FC, ReactNode, useMemo } from 'react'
import { tv } from 'tailwind-variants'

import { AbstractSize, CharRelativeSize } from '../../themes/createSpacing'
import { Gap, ResponseMessageType } from '../../types'
import { Gap, ResponseMessageTypeWithoutProcessing } from '../../types'
import { Base } from '../Base'
import { Cluster } from '../Layout'
import { ResponseMessage } from '../ResponseMessage'
Expand Down Expand Up @@ -54,7 +54,7 @@ type Props = StyleProps & {
/** tertiary 領域に表示するボタン */
tertiaryButton?: ReactNode
/** 操作に対するフィードバックメッセージ */
responseMessage?: ResponseMessageType
responseMessage?: ResponseMessageTypeWithoutProcessing
}
type ElementProps = Omit<ComponentPropsWithoutRef<'div'>, keyof Props>

Expand All @@ -69,26 +69,16 @@ export const FloatArea: FC<Props & ElementProps> = ({
className,
...rest
}) => {
const styleProps = useMemo(
() => ({
style: { ...style, zIndex },
}),
[style, zIndex],
)
const styleAttr = useMemo(() => ({ ...style, zIndex }), [style, zIndex])
const actualClassName = useMemo(() => floatArea({ bottom, className }), [bottom, className])

return (
<Base
{...styleProps}
{...rest}
className={floatArea({ bottom, className })}
layer={3}
padding={1}
>
<Base {...rest} style={styleAttr} layer={3} padding={1} className={actualClassName}>
<Cluster gap={1}>
{tertiaryButton}
<div className="shr-ms-auto">
<Cluster gap={1} align="center">
{(responseMessage?.status === 'success' || responseMessage?.status === 'error') && (
{responseMessage && (
<ResponseMessage type={responseMessage.status}>
{responseMessage.text}
</ResponseMessage>
Expand Down
9 changes: 5 additions & 4 deletions packages/smarthr-ui/src/types/ResponseMessage.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { ReactNode } from 'react'

export type ResponseMessageTypeWithoutProcessing = {
status: 'success' | 'error'
text: ReactNode
}
export type ResponseMessageType =
| {
status: 'success' | 'error'
text: ReactNode
}
| ResponseMessageTypeWithoutProcessing
| {
status: 'processing'
}
2 changes: 1 addition & 1 deletion packages/smarthr-ui/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type { Gap, SeparateGap } from './Gap'
export type { DecoratorsType, DecoratorType } from './Decorator'
export type { ResponseMessageType } from './ResponseMessage'
export type { ResponseMessageType, ResponseMessageTypeWithoutProcessing } from './ResponseMessage'
export type { LocaleMap } from './Locale'
export type { ElementRef, ElementRefProps } from './ComponentTypes'

0 comments on commit 0fd3afa

Please sign in to comment.