From 603c7dd2bfbdf91b5cdfc01ba2e7d0c3e545ecfe Mon Sep 17 00:00:00 2001 From: Christian Andolf Date: Fri, 13 Jun 2025 16:23:11 +0200 Subject: [PATCH 1/2] fix: make use of design system label component in select minor tweaks to make sure input and select behaves consistently --- .../lib/components/Input/input.module.css | 6 ++-- .../lib/components/Label/Label.tsx | 9 ++++- .../lib/components/Label/label.module.css | 33 +++++++++---------- .../lib/components/Label/variants.ts | 3 ++ .../lib/components/Select/Select.tsx | 14 ++++---- .../lib/components/Select/SelectFilter.tsx | 17 ++++------ .../lib/components/Select/select.module.css | 14 ++++---- 7 files changed, 50 insertions(+), 46 deletions(-) diff --git a/packages/design-system/lib/components/Input/input.module.css b/packages/design-system/lib/components/Input/input.module.css index 97add50c7..295aed7a9 100644 --- a/packages/design-system/lib/components/Input/input.module.css +++ b/packages/design-system/lib/components/Input/input.module.css @@ -6,7 +6,7 @@ display: grid; min-width: 0; /* allow shrinkage */ height: 56px; - padding: var(--Space-x15); + padding: 0 var(--Space-x15); box-sizing: border-box; cursor: text; @@ -43,7 +43,7 @@ &:focus, &:placeholder-shown, &[value]:not([value='']) { - height: 18px; + height: 24px; outline: none; } @@ -54,7 +54,7 @@ @media (hover: hover) { .input:active:not(:disabled) { - height: 18px; + height: 24px; outline: none; } } diff --git a/packages/design-system/lib/components/Label/Label.tsx b/packages/design-system/lib/components/Label/Label.tsx index 9ee9c896e..70dd9aee3 100644 --- a/packages/design-system/lib/components/Label/Label.tsx +++ b/packages/design-system/lib/components/Label/Label.tsx @@ -2,11 +2,18 @@ import { labelVariants } from './variants' import type { LabelProps } from './types' -export function Label({ children, className, required, size }: LabelProps) { +export function Label({ + children, + className, + selected, + required, + size, +}: LabelProps) { const classNames = labelVariants({ className, size, required, + selected, }) return {children} diff --git a/packages/design-system/lib/components/Label/label.module.css b/packages/design-system/lib/components/Label/label.module.css index 6f3c4049a..385d2f5c6 100644 --- a/packages/design-system/lib/components/Label/label.module.css +++ b/packages/design-system/lib/components/Label/label.module.css @@ -43,23 +43,22 @@ content: ' *'; } -input:focus, -input:placeholder-shown, -input[value]:not([value='']), -textarea:focus, -textarea:placeholder-shown, -textarea[value]:not([value='']) { - & ~ .label { - font-family: var(--Label-Font-family), var(--Label-Font-fallback); - font-size: var(--Label-Size); - font-weight: var(--Label-Font-weight); - letter-spacing: var(--Label-Letter-spacing); - text-transform: unset; - line-height: 1.5; - text-decoration: none; +input:focus ~ .label, +input:placeholder-shown ~ .label, +input[value]:not([value='']) ~ .label, +textarea:focus ~ .label, +textarea:placeholder-shown ~ .label, +textarea[value]:not([value='']) ~ .label, +.selected { + font-family: var(--Label-Font-family), var(--Label-Font-fallback); + font-size: var(--Label-Size); + font-weight: var(--Label-Font-weight); + letter-spacing: var(--Label-Letter-spacing); + text-transform: unset; + line-height: 1.5; + text-decoration: none; - margin-bottom: var(--Space-x05); - } + margin-bottom: var(--Space-x025); } input:disabled, @@ -79,7 +78,7 @@ textarea:disabled { line-height: 1.5; text-decoration: none; - margin-bottom: var(--Space-x05); + margin-bottom: var(--Space-x025); } } diff --git a/packages/design-system/lib/components/Label/variants.ts b/packages/design-system/lib/components/Label/variants.ts index ee28aab93..53162bc49 100644 --- a/packages/design-system/lib/components/Label/variants.ts +++ b/packages/design-system/lib/components/Label/variants.ts @@ -12,6 +12,9 @@ export const labelVariants = cva(styles.label, { required: { true: styles.required, }, + selected: { + true: styles.selected, + }, }, defaultVariants: { size: 'regular', diff --git a/packages/design-system/lib/components/Select/Select.tsx b/packages/design-system/lib/components/Select/Select.tsx index 409b6d9de..92e574798 100644 --- a/packages/design-system/lib/components/Select/Select.tsx +++ b/packages/design-system/lib/components/Select/Select.tsx @@ -16,6 +16,7 @@ import type { SelectProps, SelectFilterProps } from './types' import styles from './select.module.css' import { useState } from 'react' +import { Label } from '../Label' export function Select({ name, @@ -64,15 +65,12 @@ export function Select({ {({ selectedText }) => { return ( <> - - {label} - + {label} + {selectedText} diff --git a/packages/design-system/lib/components/Select/SelectFilter.tsx b/packages/design-system/lib/components/Select/SelectFilter.tsx index 7c80e1b4a..bb958efa1 100644 --- a/packages/design-system/lib/components/Select/SelectFilter.tsx +++ b/packages/design-system/lib/components/Select/SelectFilter.tsx @@ -7,7 +7,7 @@ import { Key, ListBox, Popover, - Label, + Label as AriaLabel, ComboBoxStateContext, } from 'react-aria-components' import { @@ -26,6 +26,7 @@ import { SelectItem } from './SelectItem' import type { SelectFilterProps } from './types' import styles from './select.module.css' +import { Label } from '../Label' /** * ComboBoxInner @@ -124,7 +125,7 @@ export function SelectFilter({ {...props} > - +