mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
#23 cleaned button props
This commit is contained in:
parent
5f57314eec
commit
82aeb7f147
2 changed files with 4 additions and 60 deletions
|
@ -1,18 +1,8 @@
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import React, {
|
import React, { ButtonHTMLAttributes, DetailedHTMLProps, FC, memo, useMemo } from 'react';
|
||||||
ButtonHTMLAttributes,
|
|
||||||
DetailedHTMLProps,
|
|
||||||
FC,
|
|
||||||
createElement,
|
|
||||||
memo,
|
|
||||||
useRef,
|
|
||||||
useEffect,
|
|
||||||
useMemo,
|
|
||||||
} from 'react';
|
|
||||||
import styles from './styles.module.scss';
|
import styles from './styles.module.scss';
|
||||||
import { Icon } from '~/components/input/Icon';
|
import { Icon } from '~/components/input/Icon';
|
||||||
import { IIcon } from '~/redux/types';
|
import { IIcon } from '~/redux/types';
|
||||||
import { usePopper } from 'react-popper';
|
|
||||||
import Tippy from '@tippy.js/react';
|
import Tippy from '@tippy.js/react';
|
||||||
import 'tippy.js/dist/tippy.css';
|
import 'tippy.js/dist/tippy.css';
|
||||||
|
|
||||||
|
@ -24,10 +14,7 @@ type IButtonProps = DetailedHTMLProps<
|
||||||
color?: 'primary' | 'secondary' | 'outline' | 'link' | 'gray';
|
color?: 'primary' | 'secondary' | 'outline' | 'link' | 'gray';
|
||||||
iconLeft?: IIcon;
|
iconLeft?: IIcon;
|
||||||
iconRight?: IIcon;
|
iconRight?: IIcon;
|
||||||
seamless?: boolean;
|
|
||||||
transparent?: boolean;
|
|
||||||
title?: string;
|
title?: string;
|
||||||
is_loading?: boolean;
|
|
||||||
stretchy?: boolean;
|
stretchy?: boolean;
|
||||||
iconOnly?: boolean;
|
iconOnly?: boolean;
|
||||||
label?: string;
|
label?: string;
|
||||||
|
@ -42,9 +29,6 @@ const Button: FC<IButtonProps> = memo(
|
||||||
iconLeft,
|
iconLeft,
|
||||||
iconRight,
|
iconRight,
|
||||||
children,
|
children,
|
||||||
seamless = false,
|
|
||||||
transparent = false,
|
|
||||||
is_loading,
|
|
||||||
title,
|
title,
|
||||||
stretchy,
|
stretchy,
|
||||||
disabled,
|
disabled,
|
||||||
|
@ -57,17 +41,14 @@ const Button: FC<IButtonProps> = memo(
|
||||||
const computedClassName = useMemo(
|
const computedClassName = useMemo(
|
||||||
() =>
|
() =>
|
||||||
classnames(styles.button, className, styles[size], styles[color], {
|
classnames(styles.button, className, styles[size], styles[color], {
|
||||||
seamless,
|
|
||||||
transparent,
|
|
||||||
disabled,
|
disabled,
|
||||||
is_loading,
|
|
||||||
stretchy,
|
stretchy,
|
||||||
icon: ((iconLeft || iconRight) && !title && !children) || iconOnly,
|
icon: ((iconLeft || iconRight) && !title && !children) || iconOnly,
|
||||||
has_icon_left: !!iconLeft,
|
has_icon_left: !!iconLeft,
|
||||||
has_icon_right: !!iconRight,
|
has_icon_right: !!iconRight,
|
||||||
round,
|
round,
|
||||||
}),
|
}),
|
||||||
[seamless, round, disabled, className, is_loading, stretchy, iconLeft, iconRight, size, color]
|
[round, disabled, className, stretchy, iconLeft, iconRight, size, color]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -34,8 +34,6 @@
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
||||||
position: relative;
|
|
||||||
|
|
||||||
filter: grayscale(0);
|
filter: grayscale(0);
|
||||||
|
|
||||||
transition: opacity 0.25s, filter 0.25s, box-shadow 0.25s;
|
transition: opacity 0.25s, filter 0.25s, box-shadow 0.25s;
|
||||||
|
@ -79,24 +77,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&:global(.seamless) {
|
|
||||||
background: transparent;
|
|
||||||
color: black;
|
|
||||||
box-shadow: none;
|
|
||||||
fill: black;
|
|
||||||
stroke: black;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:global(.transparent) {
|
|
||||||
background: transparent;
|
|
||||||
color: white;
|
|
||||||
box-shadow: transparentize(black, 0.5) 0 0 4px;
|
|
||||||
padding: 0;
|
|
||||||
fill: black;
|
|
||||||
stroke: black;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:global(.red) {
|
&:global(.red) {
|
||||||
fill: $red;
|
fill: $red;
|
||||||
stroke: $red;
|
stroke: $red;
|
||||||
|
@ -111,8 +91,6 @@
|
||||||
&:global(.grey) {
|
&:global(.grey) {
|
||||||
background: transparentize(white, 0.9);
|
background: transparentize(white, 0.9);
|
||||||
color: white;
|
color: white;
|
||||||
// background: lighten(white, 0.5);
|
|
||||||
// filter: grayscale(100%);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&:global(.disabled) {
|
&:global(.disabled) {
|
||||||
|
@ -189,6 +167,7 @@
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.mini {
|
.mini {
|
||||||
height: 28px;
|
height: 28px;
|
||||||
border-radius: $radius / 2;
|
border-radius: $radius / 2;
|
||||||
|
@ -197,6 +176,7 @@
|
||||||
border-radius: 14px;
|
border-radius: 14px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.small {
|
.small {
|
||||||
height: 32px;
|
height: 32px;
|
||||||
|
|
||||||
|
@ -251,20 +231,3 @@
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tooltip {
|
|
||||||
padding: 5px 10px;
|
|
||||||
background-color: darken($content_bg, 4%);
|
|
||||||
z-index: 2;
|
|
||||||
border-radius: $input_radius;
|
|
||||||
text-transform: none;
|
|
||||||
touch-action: none;
|
|
||||||
transition: opacity 0.1s;
|
|
||||||
border: 1px solid transparentize(white, 0.9);
|
|
||||||
//visibility: hidden;
|
|
||||||
|
|
||||||
.button:hover & {
|
|
||||||
visibility: visible;
|
|
||||||
font: $font_14_semibold;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue