Skip to content

Personnaliser les boutons pour qu'ils ressemblent à ceux d'Amazon #2

@shouze

Description

@shouze

👉 ça se passe par ici :

export const theme = {
name: "default",
colors: {
primary: "#161616",
secondary: "#AFFAD6",
lightText: "#FFFFFF",
darkText: "#000000",
},
font: {
heading: "Raleway",
body: "Cabin",
},
};

import React from "react";
import styled from "styled-components";
interface Props {
children?: React.ReactNode;
className?: string;
onClickFunction?: React.MouseEventHandler<HTMLButtonElement>;
isClicked?: boolean;
}
const Button = (props: Props) => {
return (
<StyledButton
className={props.className}
onClick={props.onClickFunction}
isClicked={props.isClicked}
>
{props.children}
</StyledButton>
);
};
export default Button;
const StyledButton = styled.button<Props>`
border: none;
background-color: ${(props) =>
props.isClicked
? props.theme.colors.secondary
: props.theme.colors.primary};
color: ${(props) => props.theme.colors.lightText};
transition: background-color 0.2s ease;
padding: 10px 20px;
`;

import React from "react";
import styled from "styled-components";
interface Props {
className?: string;
children?: React.ReactNode;
onClickFunction: React.MouseEventHandler<HTMLButtonElement>;
disabled?: boolean;
}
const CTA = (props: Props) => {
return (
<StyledButton
className={props.className}
onClick={props.onClickFunction}
disabled={props.disabled}
>
{props.children}
</StyledButton>
);
};
export default CTA;
const StyledButton = styled.button`
width: 100%;
padding: 16px 20px;
border: none;
background: ${(props) => props.theme.colors.secondary};
color: ${(props) => props.theme.colors.darkText};
&:disabled {
opacity: 0.4;
background: lightgrey;
}
`;

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions