✨(react) add button sizes
Add two sizes for the Button component: small and medium. They are present on the new delivered sketches concerning pagination but dont exists yet.
This commit is contained in:
@@ -4,17 +4,31 @@
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
transition: background-color var(--c--theme--transitions--duration) var(--c--theme--transitions--ease-out);
|
||||
|
||||
padding: 0 var(--c--theme--spacings--s);
|
||||
|
||||
height: var(--c--components--button--height);
|
||||
border-radius: var(--c--components--button--border-radius);
|
||||
font-size: var(--c--components--button--font-size);
|
||||
font-weight: var(--c--components--button--font-weight);
|
||||
|
||||
&--medium {
|
||||
height: var(--c--components--button--medium-height);
|
||||
font-size: var(--c--components--button--medium-font-size);
|
||||
padding: 0 var(--c--theme--spacings--s);
|
||||
|
||||
&.c__button--icon-only {
|
||||
width: var(--c--components--button--medium-height);
|
||||
}
|
||||
}
|
||||
|
||||
&--small {
|
||||
height: var(--c--components--button--small-height);
|
||||
font-size: var(--c--components--button--small-font-size);
|
||||
padding: 0 0.75rem;
|
||||
|
||||
&.c__button--icon-only {
|
||||
width: var(--c--components--button--small-height);
|
||||
}
|
||||
}
|
||||
|
||||
&--icon-only {
|
||||
padding: 0;
|
||||
width: var(--c--components--button--height);
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
@@ -41,6 +55,10 @@
|
||||
&:active, &.c__button--active {
|
||||
background-color: var(--c--theme--colors--primary-500);
|
||||
}
|
||||
|
||||
&[disabled] {
|
||||
background-color: var(--c--theme--colors--greyscale-200);
|
||||
}
|
||||
}
|
||||
|
||||
&--secondary {
|
||||
@@ -54,6 +72,10 @@
|
||||
&:active, &.c__button--active {
|
||||
background-color: var(--c--theme--colors--secondary-500);
|
||||
}
|
||||
|
||||
&[disabled] {
|
||||
background-color: var(--c--theme--colors--greyscale-200);
|
||||
}
|
||||
}
|
||||
|
||||
&--tertiary {
|
||||
@@ -62,12 +84,17 @@
|
||||
|
||||
&:hover {
|
||||
color: var(--c--theme--colors--greyscale-900);
|
||||
background-color: var(--c--theme--colors--greyscale-100);
|
||||
}
|
||||
|
||||
&:active, &.c__button--active {
|
||||
color: var(--c--theme--colors--greyscale-800);
|
||||
background-color: var(--c--theme--colors--greyscale-200);
|
||||
}
|
||||
|
||||
&[disabled] {
|
||||
background-color: transparent;
|
||||
}
|
||||
}
|
||||
|
||||
&--danger {
|
||||
@@ -81,11 +108,14 @@
|
||||
&:active {
|
||||
background-color: var(--c--theme--colors--danger-500);
|
||||
}
|
||||
|
||||
&[disabled] {
|
||||
background-color: var(--c--theme--colors--greyscale-200);
|
||||
}
|
||||
}
|
||||
|
||||
&[disabled] {
|
||||
cursor: not-allowed;
|
||||
background-color: var(--c--theme--colors--greyscale-200);
|
||||
color: var(--c--theme--colors--greyscale-400);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { act, render, screen, waitFor } from "@testing-library/react";
|
||||
import React from "react";
|
||||
import { buildTheme, loadTokens } from "tests/Theme";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { buildTheme, loadTokens } from "tests/Theme";
|
||||
import { Button } from "./index";
|
||||
|
||||
describe("<Button/>", () => {
|
||||
|
||||
@@ -5,6 +5,11 @@ import { Button } from "./index";
|
||||
export default {
|
||||
title: "Components/Button",
|
||||
component: Button,
|
||||
argTypes: {
|
||||
disabled: {
|
||||
control: "boolean",
|
||||
},
|
||||
},
|
||||
} as ComponentMeta<typeof Button>;
|
||||
|
||||
const Template: ComponentStory<typeof Button> = (args) => <Button {...args} />;
|
||||
@@ -40,6 +45,13 @@ Danger.args = {
|
||||
color: "danger",
|
||||
};
|
||||
|
||||
export const Small = Template.bind({});
|
||||
Small.args = {
|
||||
children: "Primary",
|
||||
color: "primary",
|
||||
size: "small",
|
||||
};
|
||||
|
||||
export const IconLeft = Template.bind({});
|
||||
IconLeft.args = {
|
||||
children: "Icon",
|
||||
|
||||
@@ -2,6 +2,7 @@ import React, { ButtonHTMLAttributes, ReactNode } from "react";
|
||||
|
||||
interface Props extends ButtonHTMLAttributes<HTMLButtonElement> {
|
||||
color?: "primary" | "secondary" | "tertiary" | "danger";
|
||||
size?: "medium" | "small";
|
||||
icon?: ReactNode;
|
||||
iconPosition?: "left" | "right";
|
||||
active?: boolean;
|
||||
@@ -10,12 +11,13 @@ interface Props extends ButtonHTMLAttributes<HTMLButtonElement> {
|
||||
export const Button = ({
|
||||
children,
|
||||
color = "primary",
|
||||
size = "medium",
|
||||
iconPosition = "left",
|
||||
icon,
|
||||
active,
|
||||
...props
|
||||
}: Props) => {
|
||||
const classes = ["c__button", "c__button--" + color];
|
||||
const classes = ["c__button", "c__button--" + color, "c__button--" + size];
|
||||
if (icon && children) {
|
||||
classes.push("c__button--with-icon--" + iconPosition);
|
||||
}
|
||||
|
||||
@@ -3,8 +3,10 @@ import { DefaultTokens } from "@openfun/cunningham-tokens";
|
||||
export const tokens = (defaults: DefaultTokens) => {
|
||||
return {
|
||||
"border-radius": "2px",
|
||||
height: "48px",
|
||||
"font-size": defaults.theme.font.sizes.l,
|
||||
"medium-height": "48px",
|
||||
"small-height": "32px",
|
||||
"medium-font-size": defaults.theme.font.sizes.l,
|
||||
"small-font-size": defaults.theme.font.sizes.m,
|
||||
"font-weight": defaults.theme.font.weights.medium,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -97,7 +97,9 @@
|
||||
--c--theme--transitions--ease-in-out: cubic-bezier(0.76, 0, 0.24, 1);
|
||||
--c--theme--transitions--duration: 200ms;
|
||||
--c--components--button--border-radius: 2px;
|
||||
--c--components--button--height: 48px;
|
||||
--c--components--button--font-size: 1rem;
|
||||
--c--components--button--medium-height: 48px;
|
||||
--c--components--button--small-height: 32px;
|
||||
--c--components--button--medium-font-size: 1rem;
|
||||
--c--components--button--small-font-size: 0.8125rem;
|
||||
--c--components--button--font-weight: 400;
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
export const tokens = {"theme":{"colors":{"primary-text":"#FFFFFF","primary-100":"#EBF2FC","primary-200":"#8CB5EA","primary-300":"#5894E1","primary-400":"#377FDB","primary-500":"#055FD2","primary-600":"#0556BF","primary-700":"#044395","primary-800":"#033474","primary-900":"#022858","secondary-text":"#555F6B","secondary-100":"#F2F7FC","secondary-200":"#EBF3FA","secondary-300":"#E2EEF8","secondary-400":"#DDEAF7","secondary-500":"#D4E5F5","secondary-600":"#C1D0DF","secondary-700":"#97A3AE","secondary-800":"#757E87","secondary-900":"#596067","greyscale-000":"#FFFFFF","greyscale-100":"#FAFAFB","greyscale-200":"#F3F4F4","greyscale-300":"#E7E8EA","greyscale-400":"#C2C6CA","greyscale-500":"#9EA3AA","greyscale-600":"#79818A","greyscale-700":"#555F6B","greyscale-800":"#303C4B","greyscale-900":"#0C1A2B","success-text":"#FFFFFF","success-100":"#EFFCD3","success-200":"#DBFAA9","success-300":"#BEF27C","success-400":"#A0E659","success-500":"#76D628","success-600":"#5AB81D","success-700":"#419A14","success-800":"#2C7C0C","success-900":"#1D6607","info-text":"#FFFFFF","info-100":"#EBF2FC","info-200":"#8CB5EA","info-300":"#5894E1","info-400":"#377FDB","info-500":"#055FD2","info-600":"#0556BF","info-700":"#044395","info-800":"#033474","info-900":"#022858","warning-text":"#FFFFFF","warning-100":"#FFF8CD","warning-200":"#FFEF9B","warning-300":"#FFE469","warning-400":"#FFDA43","warning-500":"#FFC805","warning-600":"#DBA603","warning-700":"#B78702","warning-800":"#936901","warning-900":"#7A5400","danger-text":"#FFFFFF","danger-100":"#F4B0B0","danger-200":"#EE8A8A","danger-300":"#E65454","danger-400":"#E13333","danger-500":"#DA0000","danger-600":"#C60000","danger-700":"#9B0000","danger-800":"#780000","danger-900":"#5C0000"},"font":{"sizes":{"h1":"1.75rem","h2":"1.375rem","h3":"1.125rem;","h4":"0.8125rem","h5":"0.625rem","h6":"0.5rem","l":"1rem","m":"0.8125rem","s":"0.6875rem"},"weights":{"thin":100,"regular":300,"medium":400,"bold":500,"extrabold":700,"black":900},"families":{"base":"Roboto","accent":"Roboto"}},"spacings":{"xl":"4rem","l":"3rem","b":"1.625rem","s":"1rem","t":"0.5rem","st":"0.25rem"},"transitions":{"ease-in":"cubic-bezier(0.5, 0, 0.75, 0)","ease-out":"cubic-bezier(0.25, 1, 0.5, 1)","ease-in-out":"cubic-bezier(0.76, 0, 0.24, 1)","duration":"200ms"}},"components":{"button":{"border-radius":"2px","height":"48px","font-size":"1rem","font-weight":400}}};
|
||||
export const tokens = {"theme":{"colors":{"primary-text":"#FFFFFF","primary-100":"#EBF2FC","primary-200":"#8CB5EA","primary-300":"#5894E1","primary-400":"#377FDB","primary-500":"#055FD2","primary-600":"#0556BF","primary-700":"#044395","primary-800":"#033474","primary-900":"#022858","secondary-text":"#555F6B","secondary-100":"#F2F7FC","secondary-200":"#EBF3FA","secondary-300":"#E2EEF8","secondary-400":"#DDEAF7","secondary-500":"#D4E5F5","secondary-600":"#C1D0DF","secondary-700":"#97A3AE","secondary-800":"#757E87","secondary-900":"#596067","greyscale-000":"#FFFFFF","greyscale-100":"#FAFAFB","greyscale-200":"#F3F4F4","greyscale-300":"#E7E8EA","greyscale-400":"#C2C6CA","greyscale-500":"#9EA3AA","greyscale-600":"#79818A","greyscale-700":"#555F6B","greyscale-800":"#303C4B","greyscale-900":"#0C1A2B","success-text":"#FFFFFF","success-100":"#EFFCD3","success-200":"#DBFAA9","success-300":"#BEF27C","success-400":"#A0E659","success-500":"#76D628","success-600":"#5AB81D","success-700":"#419A14","success-800":"#2C7C0C","success-900":"#1D6607","info-text":"#FFFFFF","info-100":"#EBF2FC","info-200":"#8CB5EA","info-300":"#5894E1","info-400":"#377FDB","info-500":"#055FD2","info-600":"#0556BF","info-700":"#044395","info-800":"#033474","info-900":"#022858","warning-text":"#FFFFFF","warning-100":"#FFF8CD","warning-200":"#FFEF9B","warning-300":"#FFE469","warning-400":"#FFDA43","warning-500":"#FFC805","warning-600":"#DBA603","warning-700":"#B78702","warning-800":"#936901","warning-900":"#7A5400","danger-text":"#FFFFFF","danger-100":"#F4B0B0","danger-200":"#EE8A8A","danger-300":"#E65454","danger-400":"#E13333","danger-500":"#DA0000","danger-600":"#C60000","danger-700":"#9B0000","danger-800":"#780000","danger-900":"#5C0000"},"font":{"sizes":{"h1":"1.75rem","h2":"1.375rem","h3":"1.125rem;","h4":"0.8125rem","h5":"0.625rem","h6":"0.5rem","l":"1rem","m":"0.8125rem","s":"0.6875rem"},"weights":{"thin":100,"regular":300,"medium":400,"bold":500,"extrabold":700,"black":900},"families":{"base":"Roboto","accent":"Roboto"}},"spacings":{"xl":"4rem","l":"3rem","b":"1.625rem","s":"1rem","t":"0.5rem","st":"0.25rem"},"transitions":{"ease-in":"cubic-bezier(0.5, 0, 0.75, 0)","ease-out":"cubic-bezier(0.25, 1, 0.5, 1)","ease-in-out":"cubic-bezier(0.76, 0, 0.24, 1)","duration":"200ms"}},"components":{"button":{"border-radius":"2px","medium-height":"48px","small-height":"32px","medium-font-size":"1rem","small-font-size":"0.8125rem","font-weight":400}}};
|
||||
@@ -1 +1 @@
|
||||
export const tokens = {"theme":{"colors":{"primary-text":"#FFFFFF","primary-100":"#EBF2FC","primary-200":"#8CB5EA","primary-300":"#5894E1","primary-400":"#377FDB","primary-500":"#055FD2","primary-600":"#0556BF","primary-700":"#044395","primary-800":"#033474","primary-900":"#022858","secondary-text":"#555F6B","secondary-100":"#F2F7FC","secondary-200":"#EBF3FA","secondary-300":"#E2EEF8","secondary-400":"#DDEAF7","secondary-500":"#D4E5F5","secondary-600":"#C1D0DF","secondary-700":"#97A3AE","secondary-800":"#757E87","secondary-900":"#596067","greyscale-000":"#FFFFFF","greyscale-100":"#FAFAFB","greyscale-200":"#F3F4F4","greyscale-300":"#E7E8EA","greyscale-400":"#C2C6CA","greyscale-500":"#9EA3AA","greyscale-600":"#79818A","greyscale-700":"#555F6B","greyscale-800":"#303C4B","greyscale-900":"#0C1A2B","success-text":"#FFFFFF","success-100":"#EFFCD3","success-200":"#DBFAA9","success-300":"#BEF27C","success-400":"#A0E659","success-500":"#76D628","success-600":"#5AB81D","success-700":"#419A14","success-800":"#2C7C0C","success-900":"#1D6607","info-text":"#FFFFFF","info-100":"#EBF2FC","info-200":"#8CB5EA","info-300":"#5894E1","info-400":"#377FDB","info-500":"#055FD2","info-600":"#0556BF","info-700":"#044395","info-800":"#033474","info-900":"#022858","warning-text":"#FFFFFF","warning-100":"#FFF8CD","warning-200":"#FFEF9B","warning-300":"#FFE469","warning-400":"#FFDA43","warning-500":"#FFC805","warning-600":"#DBA603","warning-700":"#B78702","warning-800":"#936901","warning-900":"#7A5400","danger-text":"#FFFFFF","danger-100":"#F4B0B0","danger-200":"#EE8A8A","danger-300":"#E65454","danger-400":"#E13333","danger-500":"#DA0000","danger-600":"#C60000","danger-700":"#9B0000","danger-800":"#780000","danger-900":"#5C0000"},"font":{"sizes":{"h1":"1.75rem","h2":"1.375rem","h3":"1.125rem;","h4":"0.8125rem","h5":"0.625rem","h6":"0.5rem","l":"1rem","m":"0.8125rem","s":"0.6875rem"},"weights":{"thin":100,"regular":300,"medium":400,"bold":500,"extrabold":700,"black":900},"families":{"base":"Roboto","accent":"Roboto"}},"spacings":{"xl":"4rem","l":"3rem","b":"1.625rem","s":"1rem","t":"0.5rem","st":"0.25rem"},"transitions":{"ease-in":"cubic-bezier(0.5, 0, 0.75, 0)","ease-out":"cubic-bezier(0.25, 1, 0.5, 1)","ease-in-out":"cubic-bezier(0.76, 0, 0.24, 1)","duration":"200ms"}},"components":{"button":{"border-radius":"2px","height":"48px","font-size":"1rem","font-weight":400}}};
|
||||
export const tokens = {"theme":{"colors":{"primary-text":"#FFFFFF","primary-100":"#EBF2FC","primary-200":"#8CB5EA","primary-300":"#5894E1","primary-400":"#377FDB","primary-500":"#055FD2","primary-600":"#0556BF","primary-700":"#044395","primary-800":"#033474","primary-900":"#022858","secondary-text":"#555F6B","secondary-100":"#F2F7FC","secondary-200":"#EBF3FA","secondary-300":"#E2EEF8","secondary-400":"#DDEAF7","secondary-500":"#D4E5F5","secondary-600":"#C1D0DF","secondary-700":"#97A3AE","secondary-800":"#757E87","secondary-900":"#596067","greyscale-000":"#FFFFFF","greyscale-100":"#FAFAFB","greyscale-200":"#F3F4F4","greyscale-300":"#E7E8EA","greyscale-400":"#C2C6CA","greyscale-500":"#9EA3AA","greyscale-600":"#79818A","greyscale-700":"#555F6B","greyscale-800":"#303C4B","greyscale-900":"#0C1A2B","success-text":"#FFFFFF","success-100":"#EFFCD3","success-200":"#DBFAA9","success-300":"#BEF27C","success-400":"#A0E659","success-500":"#76D628","success-600":"#5AB81D","success-700":"#419A14","success-800":"#2C7C0C","success-900":"#1D6607","info-text":"#FFFFFF","info-100":"#EBF2FC","info-200":"#8CB5EA","info-300":"#5894E1","info-400":"#377FDB","info-500":"#055FD2","info-600":"#0556BF","info-700":"#044395","info-800":"#033474","info-900":"#022858","warning-text":"#FFFFFF","warning-100":"#FFF8CD","warning-200":"#FFEF9B","warning-300":"#FFE469","warning-400":"#FFDA43","warning-500":"#FFC805","warning-600":"#DBA603","warning-700":"#B78702","warning-800":"#936901","warning-900":"#7A5400","danger-text":"#FFFFFF","danger-100":"#F4B0B0","danger-200":"#EE8A8A","danger-300":"#E65454","danger-400":"#E13333","danger-500":"#DA0000","danger-600":"#C60000","danger-700":"#9B0000","danger-800":"#780000","danger-900":"#5C0000"},"font":{"sizes":{"h1":"1.75rem","h2":"1.375rem","h3":"1.125rem;","h4":"0.8125rem","h5":"0.625rem","h6":"0.5rem","l":"1rem","m":"0.8125rem","s":"0.6875rem"},"weights":{"thin":100,"regular":300,"medium":400,"bold":500,"extrabold":700,"black":900},"families":{"base":"Roboto","accent":"Roboto"}},"spacings":{"xl":"4rem","l":"3rem","b":"1.625rem","s":"1rem","t":"0.5rem","st":"0.25rem"},"transitions":{"ease-in":"cubic-bezier(0.5, 0, 0.75, 0)","ease-out":"cubic-bezier(0.25, 1, 0.5, 1)","ease-in-out":"cubic-bezier(0.76, 0, 0.24, 1)","duration":"200ms"}},"components":{"button":{"border-radius":"2px","medium-height":"48px","small-height":"32px","medium-font-size":"1rem","small-font-size":"0.8125rem","font-weight":400}}};
|
||||
Reference in New Issue
Block a user