Make button slightly bigger than before

This commit is contained in:
Haishan 2022-06-06 00:02:54 +08:00
parent 6a402afa3f
commit 7f7cb27df1
4 changed files with 14 additions and 20 deletions

View file

@ -23,16 +23,16 @@
transform: scale(0.97); transform: scale(0.97);
} }
font-size: 0.85em; padding: 10px 13px;
padding: 4px 7px;
@media (--breakpoint-not-small) { &.circular {
font-size: 1em; padding: 8px;
padding: 6px 12px;
} }
&.minimal { &.minimal {
border-color: transparent; border-color: transparent;
background: none; background: none;
padding: 6px 12px;
&:focus { &:focus {
border-color: var(--color-focus-blue); border-color: var(--color-focus-blue);
} }

View file

@ -17,7 +17,7 @@ type ButtonProps = {
isLoading?: boolean; isLoading?: boolean;
onClick?: (e: React.MouseEvent<HTMLButtonElement>) => unknown; onClick?: (e: React.MouseEvent<HTMLButtonElement>) => unknown;
disabled?: boolean; disabled?: boolean;
kind?: 'primary' | 'minimal'; kind?: 'primary' | 'minimal' | 'circular';
className?: string; className?: string;
title?: string; title?: string;
} & ButtonInternalProps; } & ButtonInternalProps;
@ -36,7 +36,7 @@ function Button(props: ButtonProps, ref: React.Ref<HTMLButtonElement>) {
...restProps ...restProps
} = props; } = props;
const internalProps = { children, label, text, start }; const internalProps = { children, label, text, start };
const internalOnClick = useCallback( const internalOnClick = useCallback<React.MouseEventHandler<HTMLButtonElement>>(
(e) => { (e) => {
if (isLoading) return; if (isLoading) return;
onClick && onClick(e); onClick && onClick(e);
@ -45,7 +45,7 @@ function Button(props: ButtonProps, ref: React.Ref<HTMLButtonElement>) {
); );
const btnClassName = cx( const btnClassName = cx(
s0.btn, s0.btn,
{ [s0.minimal]: kind === 'minimal' }, { [s0.minimal]: kind === 'minimal', [s0.circular]: kind === 'circular' },
className className
); );
return ( return (
@ -76,9 +76,7 @@ function ButtonInternal({ children, label, text, start }: ButtonInternalProps) {
return ( return (
<> <>
{start ? ( {start ? (
<span className={s0.btnStart}> <span className={s0.btnStart}>{typeof start === 'function' ? start() : start}</span>
{typeof start === 'function' ? start() : start}
</span>
) : null} ) : null}
{children || label || text} {children || label || text}
</> </>

View file

@ -16,24 +16,20 @@ export function RuleProviderItem({
ruleCount, ruleCount,
apiConfig, apiConfig,
}) { }) {
const [onClickRefreshButton, isRefreshing] = useUpdateRuleProviderItem( const [onClickRefreshButton, isRefreshing] = useUpdateRuleProviderItem(name, apiConfig);
name,
apiConfig
);
const timeAgo = formatDistance(new Date(updatedAt), new Date()); const timeAgo = formatDistance(new Date(updatedAt), new Date());
return ( return (
<div className={s.RuleProviderItem}> <div className={s.RuleProviderItem}>
<span className={s.left}>{idx}</span> <span className={s.left}>{idx}</span>
<div className={s.middle}> <div className={s.middle}>
<SectionNameType name={name} type={`${vehicleType} / ${behavior}`} /> <SectionNameType name={name} type={`${vehicleType} / ${behavior}`} />
<div className={s.gray}> <div className={s.gray}>{ruleCount < 2 ? `${ruleCount} rule` : `${ruleCount} rules`}</div>
{ruleCount < 2 ? `${ruleCount} rule` : `${ruleCount} rules`}
</div>
<small className={s.gray}>Updated {timeAgo} ago</small> <small className={s.gray}>Updated {timeAgo} ago</small>
</div> </div>
<span className={s.refreshButtonWrapper}> <span className={s.refreshButtonWrapper}>
<Button onClick={onClickRefreshButton} disabled={isRefreshing}> <Button onClick={onClickRefreshButton} disabled={isRefreshing} kind="circular">
<RotateIcon isRotating={isRefreshing} /> <RotateIcon isRotating={isRefreshing} />
<span className="visually-hidden">Refresh</span>
</Button> </Button>
</span> </span>
</div> </div>

View file

@ -10,7 +10,7 @@ export function RotateIcon({ isRotating }: { isRotating: boolean }) {
}); });
return ( return (
<span className={cls}> <span className={cls}>
<RotateCw width={16} /> <RotateCw size={16} />
</span> </span>
); );
} }