From c59eeed7e0e09424f2c2b0b08d736c9301c6cc5e 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 | 38 ++- 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 | 234 ++++++++++++++++++ src/lib/i18n/formatMessage.ts | 22 ++ src/settings/_style.scss | 2 + 14 files changed, 521 insertions(+), 26 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 76350e5f..c3e89c3f 100644 --- a/src/components/button/button.scss +++ b/src/components/button/button.scss @@ -4,12 +4,16 @@ --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: var(--border-radus-m); @@ -21,6 +25,7 @@ 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; @@ -30,6 +35,18 @@ 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, @@ -45,6 +62,25 @@ } } + &--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; 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 && ( +