mirror of
https://github.com/Nezumi-2711/react-training.git
synced 2026-09-22 20:01:59 +00:00
Update components and constants folder
This commit is contained in:
@@ -1,9 +1,25 @@
|
||||
import styled, { css } from 'styled-components';
|
||||
import styled, { RuleSet, css } from 'styled-components';
|
||||
|
||||
type TButtonStyle = 'primary' | 'secondary';
|
||||
interface IVariations {
|
||||
[key: string]: RuleSet<object>;
|
||||
}
|
||||
|
||||
const variations: IVariations = {
|
||||
primary: css`
|
||||
background-color: var(--primary-color);
|
||||
color: var(--light-text);
|
||||
`,
|
||||
secondary: css`
|
||||
background-color: var(--secondary-btn-color);
|
||||
`,
|
||||
danger: css`
|
||||
background-color: var(--danger-btn-color);
|
||||
color: var(--light-text);
|
||||
`,
|
||||
} as const;
|
||||
|
||||
interface IButtonStyle {
|
||||
styled?: TButtonStyle;
|
||||
variations?: keyof typeof variations;
|
||||
}
|
||||
|
||||
const Button = styled.button<IButtonStyle>`
|
||||
@@ -16,22 +32,16 @@ const Button = styled.button<IButtonStyle>`
|
||||
|
||||
border-radius: var(--radius-md);
|
||||
|
||||
${(props) =>
|
||||
props.styled === 'primary' &&
|
||||
css`
|
||||
background-color: var(--primary-color);
|
||||
color: var(--light-text);
|
||||
`}
|
||||
${(props) => variations[props.variations!]}
|
||||
|
||||
${(props) =>
|
||||
props.styled === 'secondary' &&
|
||||
css`
|
||||
background-color: var(--secondary-btn-color);
|
||||
`}
|
||||
&:disabled,
|
||||
&[disabled] {
|
||||
cursor: no-drop;
|
||||
}
|
||||
`;
|
||||
|
||||
Button.defaultProps = {
|
||||
styled: 'primary',
|
||||
variations: 'primary',
|
||||
};
|
||||
|
||||
export default Button;
|
||||
|
||||
Reference in New Issue
Block a user