Skip to content

Commit

Permalink
Add support for link type to Button Component
Browse files Browse the repository at this point in the history
  • Loading branch information
th3c0d3br34ker committed Sep 22, 2023
1 parent 2ec8464 commit 67f53d8
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions packages/desktop-client/src/components/common/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,25 @@ const linkButtonHoverStyles = {
boxShadow: 'none',
};

const _getBorder = (type, typeWithDisabled) => {
if (type === 'bare' || type === 'link') {
return 'none';
} else {
return '1px solid ' + borderColor[typeWithDisabled];
}
};

const _getPadding = type => {
switch (type) {
case 'bare':
return '5px';
case 'link':
return '0';
default:
return '5px 10px';
}
};

const Button = forwardRef<HTMLButtonElement, ButtonProps>(
(
{
Expand Down Expand Up @@ -128,14 +147,13 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>(
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0,
padding: type === 'bare' ? '5px' : '5px 10px',
padding: _getPadding(type),
margin: 0,
overflow: 'hidden',
display: 'flex',
display: type === 'link' ? 'inline' : 'flex',
borderRadius: 4,
backgroundColor: backgroundColor[typeWithDisabled],
border:
type === 'bare' ? 'none' : '1px solid ' + borderColor[typeWithDisabled],
border: _getBorder(type, typeWithDisabled),
color: color || textColor[typeWithDisabled],
transition: 'box-shadow .25s',
WebkitAppRegion: 'no-drag',
Expand Down

0 comments on commit 67f53d8

Please sign in to comment.