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

fix: Loaderの表示遅延処理を削除する #5003

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/smarthr-ui/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ export const Button = forwardRef<HTMLButtonElement, BaseProps & ElementProps & P
)
const { createPortal } = usePortal()

const loader = (
<Loader size="s" deferDisplay={false} className={loaderStyle} role="presentation" />
)
const loader = <Loader size="s" className={loaderStyle} role="presentation" />
const actualPrefix = !loading && prefix
const actualSuffix = loading && !square ? loader : suffix
const disabledOnLoading = loading || disabled
Expand Down
89 changes: 38 additions & 51 deletions packages/smarthr-ui/src/components/Loader/Loader.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,58 +9,45 @@ export default {
component: Loader,
}

export const All: StoryFn = () => {
// NOTE: 本来は表示を遅延させているが、VRT 向けにデフォルトでは表示を遅延させない。
const [deferDisplay, setDeferDisplay] = React.useState(false)
return (
<>
<label>
<input
type="checkbox"
name="defer_display"
checked={deferDisplay}
onChange={() => setDeferDisplay(!deferDisplay)}
/>
defer display
</label>
<Wrapper>
<Text>Primary</Text>
<List>
<dt>Default</dt>
<dd>
<Loader deferDisplay={deferDisplay} />
</dd>
<dt>Small</dt>
<dd>
<Loader deferDisplay={deferDisplay} size="s" />
</dd>
<dt>With text</dt>
<dd>
<Loader deferDisplay={deferDisplay} text="loading message" />
</dd>
</List>
</Wrapper>
export const All: StoryFn = () => (
<>
<Wrapper>
<Text>Primary</Text>
<List>
<dt>Default</dt>
<dd>
<Loader />
</dd>
<dt>Small</dt>
<dd>
<Loader size="s" />
</dd>
<dt>With text</dt>
<dd>
<Loader text="loading message" />
</dd>
</List>
</Wrapper>

<GrayWrapper>
<Text>Light</Text>
<List>
<dt>Default</dt>
<dd>
<Loader deferDisplay={deferDisplay} type="light" />
</dd>
<dt>Small</dt>
<dd>
<Loader deferDisplay={deferDisplay} type="light" size="s" />
</dd>
<dt>With text</dt>
<dd>
<Loader deferDisplay={deferDisplay} type="light" text="loading message" />
</dd>
</List>
</GrayWrapper>
</>
)
}
<GrayWrapper>
<Text>Light</Text>
<List>
<dt>Default</dt>
<dd>
<Loader type="light" />
</dd>
<dt>Small</dt>
<dd>
<Loader type="light" size="s" />
</dd>
<dt>With text</dt>
<dd>
<Loader type="light" text="loading message" />
</dd>
</List>
</GrayWrapper>
</>
)
All.storyName = 'all'
All.parameters = { withTheming: true }

Expand Down
11 changes: 0 additions & 11 deletions packages/smarthr-ui/src/components/Loader/Loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ type Props = {
text?: ReactNode
/** コンポーネントの色調 */
type?: 'primary' | 'light'
/** 表示を遅延させるかどうか */
deferDisplay?: boolean
as?: string | React.ComponentType<any>
}
type ElementProps = Omit<ComponentProps<'span'>, keyof Props>
Expand Down Expand Up @@ -120,13 +118,6 @@ const loaderStyle = tv({
],
},
},
deferDisplay: {
true: {
// NOTE: Loaderの表示時間が短い場合のUIのちらつきを抑えるため、opacityの変化でアニメーションの表示を遅延させる
wrapper: 'shr-opacity-0 shr-animate-[loader-fade-in_0s_ease_200ms_forwards]',
},
false: {},
},
},
})
export const Loader: FC<Props & ElementProps> = ({
Expand All @@ -135,14 +126,12 @@ export const Loader: FC<Props & ElementProps> = ({
text,
type = 'primary',
role = 'status',
deferDisplay = true,
className,
...props
}) => {
const { wrapper, spinner, line, cog, cogInner, textSlot } = loaderStyle({
type,
size,
deferDisplay,
})
const wrapperStyle = useMemo(() => wrapper({ className }), [wrapper, className])
const spinnerStyle = useMemo(() => spinner(), [spinner])
Expand Down