From 696f049d73a7b8fd81da3f6e7f243ff8a6e7bce9 Mon Sep 17 00:00:00 2001 From: Sven van de Scheur Date: Thu, 25 Jan 2024 10:09:31 +0100 Subject: [PATCH] :sparkles: #24 - feat: add paginator component --- src/components/button/button.scss | 49 ++++- src/components/button/button.tsx | 9 +- src/components/form/input/input.tsx | 4 +- src/components/form/select/select.scss | 4 + src/components/form/select/select.tsx | 38 ++-- src/components/icon/icon.scss | 18 ++ src/components/icon/icon.tsx | 33 +++- src/components/index.ts | 1 + src/components/paginator/index.ts | 1 + src/components/paginator/paginator.scss | 7 + .../paginator/paginator.stories.tsx | 136 +++++++++++++ src/components/paginator/paginator.tsx | 185 ++++++++++++++++++ src/lib/i18n/formatMessage.ts | 22 +++ src/settings/_style.scss | 2 + 14 files changed, 478 insertions(+), 31 deletions(-) create mode 100644 src/components/paginator/index.ts create mode 100644 src/components/paginator/paginator.scss create mode 100644 src/components/paginator/paginator.stories.tsx create mode 100644 src/components/paginator/paginator.tsx create mode 100644 src/lib/i18n/formatMessage.ts diff --git a/src/components/button/button.scss b/src/components/button/button.scss index 3d6db4d7..e3810e3e 100644 --- a/src/components/button/button.scss +++ b/src/components/button/button.scss @@ -1,34 +1,52 @@ -@use '../../settings/style'; +@use "../../settings/style"; .mykn-button { --mykn-button-color-background: var(--theme-color-primary-800); --mykn-button-color-shadow: var(--theme-shade-1000); --mykn-button-color-text: var(--theme-shade-0); + --mykn-button-height: auto; + --mykn-button-width: auto; --mykn-button-offset: 0px; + --mykn-button-padding-v: var(--spacing-v-s); + --mykn-button-padding-h: var(--spacing-h-s); align-items: center; appearance: none; margin: 0; - padding: var(--spacing-v-s) var(--spacing-h-s); + padding: var(--mykn-button-padding-v) var(--mykn-button-padding-h); background-color: var(--mykn-button-color-background); border: 1px solid var(--mykn-button-color-border); border-radius: 4px; - box-shadow: 0 calc(var(--mykn-button-offset) * -1) var(--mykn-button-color-shadow); + box-shadow: 0 calc(var(--mykn-button-offset) * -1) + var(--mykn-button-color-shadow); box-sizing: border-box; color: var(--mykn-button-color-text); cursor: pointer; display: inline-flex; flex-wrap: wrap; gap: 0.5em; + height: var(--mykn-button-height); font-family: Inter, sans-serif; font-size: var(--typography-font-size-body-s); justify-content: center; line-height: var(--typography-line-height-body-s); text-align: center; text-decoration: none; - transition: all var(--animation-duration-fast) var(--animation-timing-function); + transition: all var(--animation-duration-fast) + var(--animation-timing-function); transform: translateY(var(--mykn-button-offset)); + width: var(--mykn-button-width); + &--square { + --mykn-button-height: calc( + var(--typography-line-height-body-s) + 2 * var(--spacing-v-s) + ); + --mykn-button-width: calc( + var(--typography-line-height-body-s) + 2 * var(--spacing-v-s) + ); + --mykn-button-padding-v: 0; + --mykn-button-padding-h: 0; + } &--variant-primary { &:focus, @@ -37,13 +55,32 @@ --mykn-button-offset: -2px; } - &[aria-expanded=true], + &[aria-expanded="true"], &:active { --mykn-button-color-background: var(--theme-color-primary-800); --mykn-button-offset: 0px; } } + &--variant-outline { + --mykn-button-color-background: transparent; + --mykn-button-color-border: var(--theme-shade-700); + --mykn-button-color-shadow: currentColor; + --mykn-button-color-text: var(--typography-color-body); + + &:focus, + &:hover { + --mykn-button-color-background: var(--theme-color-primary-200); + --mykn-button-offset: -2px; + } + + &[aria-expanded="true"], + &:active { + --mykn-button-color-background: var(--typography-color-background); + --mykn-button-offset: 0px; + } + } + &--variant-transparent { --mykn-button-color-background: transparent; --mykn-button-color-shadow: currentColor; @@ -55,7 +92,7 @@ --mykn-button-offset: -2px; } - &[aria-expanded=true], + &[aria-expanded="true"], &:active { --mykn-button-color-background: var(--typography-color-background); --mykn-button-offset: 0px; diff --git a/src/components/button/button.tsx b/src/components/button/button.tsx index f5ad249f..fe53c65c 100644 --- a/src/components/button/button.tsx +++ b/src/components/button/button.tsx @@ -4,7 +4,8 @@ import React, { LegacyRef } from "react"; import "./button.scss"; type BaseButtonProps = { - variant?: "primary" | "transparent"; + square?: boolean; + variant?: "primary" | "outline" | "transparent"; }; export type ButtonProps = React.ButtonHTMLAttributes & @@ -20,11 +21,13 @@ export type ButtonLinkProps = React.AnchorHTMLAttributes & * @constructor */ export const Button = React.forwardRef( - ({ variant = "primary", ...props }, ref) => { + ({ square = false, variant = "primary", ...props }, ref) => { return ( + + + {labelLoading && ( +