Skip to content

Commit

Permalink
Merge pull request #264 from web3ui/feat/button-transparent-bg
Browse files Browse the repository at this point in the history
feat: Add transparent button, without hover effect
  • Loading branch information
dani69654 authored Mar 10, 2022
2 parents 29c0a35 + a3061f8 commit 60df703
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
11 changes: 9 additions & 2 deletions src/components/Button/Button.styles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import styled from 'styled-components';
import type { ButtonProps } from './types';

import { initialStyles, isLoadingMode } from './styles/inititalStyles';
import {
hoverEffect,
initialStyles,
isLoadingMode,
transparent,
} from './styles/inititalStyles';
import {
primary,
regular,
Expand Down Expand Up @@ -32,6 +36,7 @@ type TStyleProps = Pick<
| 'isFullWidth'
| 'isLoading'
| 'radius'
| 'isTransparent'
>;

const getThemeStyles = (theme: string) => {
Expand Down Expand Up @@ -113,4 +118,6 @@ export const ButtonStyled = styled.button<TStyleProps>`
${(p) => p.isLoading && isLoadingMode}
${(p) => p.radius && `border-radius: ${p.radius}px`}
${(p) => (p.isTransparent ? transparent : hoverEffect)}
`;
2 changes: 2 additions & 0 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ const Button: React.FC<ButtonProps> = ({
type = 'button',
loadingProps,
radius,
isTransparent = false,
}: ButtonProps) => {
return (
<ButtonStyled
isTransparent={isTransparent}
color={color}
data-testid="test-button"
disabled={disabled || isLoading}
Expand Down
18 changes: 12 additions & 6 deletions src/components/Button/styles/inititalStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ export const initialStyles = css`
z-index: 0;
}
:hover {
:after {
background-color: ${getShade('dark', 10)};
}
}
:active {
border-color: ${color.blue};
}
Expand All @@ -66,3 +60,15 @@ export const isLoadingMode = css`
margin-left: 12px;
}
`;

export const hoverEffect = css`
:hover {
:after {
background-color: ${getShade('dark', 10)};
}
}
`;

export const transparent = css`
background-color: transparent;
`;
5 changes: 5 additions & 0 deletions src/components/Button/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,9 @@ export interface ButtonProps {
* Border radius prop, allows a button to have a custom border radius
*/
radius?: number;

/**
* The background color is set to `transparent` and the hover effect is disabled
*/
isTransparent?: boolean;
}

0 comments on commit 60df703

Please sign in to comment.