Skip to content

Commit

Permalink
Make all Button sizes responsive
Browse files Browse the repository at this point in the history
  • Loading branch information
olmoh committed Jan 17, 2025
1 parent 6256fe6 commit f568e79
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function InfoButton({ title, message, children, ...props }: InfoB
message={message}
type={ModalAlertType.info}
buttons={[
<Button key="back" size="full" onClick={hide}>
<Button key="back" onClick={hide}>
{messages.gettext('Got it!')}
</Button>,
]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function ConnectButton(props: Partial<Parameters<typeof Button>[0]>) {
}, [connectTunnel]);

return (
<Button variant="success" size="full" onClick={onConnect} {...props}>
<Button variant="success" onClick={onConnect} {...props}>
{messages.pgettext('tunnel-control', 'Connect')}
</Button>
);
Expand All @@ -51,7 +51,7 @@ function DisconnectButton() {
const displayAsCancel = tunnelState !== 'connected';

return (
<Button variant="destructive" size="full" onClick={onDisconnect}>
<Button variant="destructive" onClick={onDisconnect}>
{displayAsCancel ? messages.gettext('Cancel') : messages.gettext('Disconnect')}
</Button>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useCallback, useMemo } from 'react';
import { sprintf } from 'sprintf-js';
import styled from 'styled-components';

import { ICustomList } from '../../../shared/daemon-rpc-types';
import { messages, relayLocations } from '../../../shared/gettext';
Expand Down Expand Up @@ -111,6 +112,10 @@ function getRelayName(
}
}

const StyledReconnectButton = styled(Button)({
minWidth: '40px',
});

function ReconnectButton(props: ButtonProps) {
const { reconnectTunnel } = useAppContext();

Expand All @@ -124,8 +129,12 @@ function ReconnectButton(props: ButtonProps) {
}, [reconnectTunnel]);

return (
<Button onClick={onReconnect} size="tiny" aria-label={messages.gettext('Reconnect')} {...props}>
<StyledReconnectButton
onClick={onReconnect}
size="auto"
aria-label={messages.gettext('Reconnect')}
{...props}>
<ImageView height={24} width={24} source="icon-reload" tintColor="white" />
</Button>
</StyledReconnectButton>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ export const ChangelogView = () => {
</NavigationScrollbars>
</NavigationContainer>
</SettingsContainer>
<StyledFooter $alignItems="center" $justifyContent="center">
<StyledFooter
$padding={{ horizontal: Spacings.spacing6 }}
$alignItems="center"
$justifyContent="center">
<Button
onClick={openDownloadLink}
trailing={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { BodySmallSemiBold } from '../typography';

export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
variant?: 'primary' | 'success' | 'destructive';
size?: 'tiny' | 'small' | 'regular' | 'full' | '1/2';
size?: 'auto' | 'full' | '1/2';
leading?: React.ReactNode;
trailing?: React.ReactNode;
}
Expand All @@ -32,9 +32,7 @@ const variants = {
} as const;

const sizes = {
tiny: '44px',
small: '60px',
regular: '272px',
auto: 'auto',
full: '100%',
'1/2': '50%',
};
Expand All @@ -44,6 +42,7 @@ const StyledButton = styled.button({

minHeight: '32px',
borderRadius: Radius.radius4,
minWidth: '60px',
width: 'var(--size)',
background: 'var(--background)',
'&:not(:disabled):hover': {
Expand All @@ -60,16 +59,7 @@ const StyledButton = styled.button({

export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
(
{
variant = 'primary',
size = 'regular',
leading,
trailing,
children,
disabled,
style,
...props
},
{ variant = 'primary', size = 'full', leading, trailing, children, disabled, style, ...props },
ref,
) => {
const styles = variants[variant];
Expand Down

0 comments on commit f568e79

Please sign in to comment.