From b5a700b32f6a0aa3c0b8942601397690f2529245 Mon Sep 17 00:00:00 2001 From: Charles de Dreuille Date: Mon, 23 Jun 2025 17:46:31 +0100 Subject: [PATCH] Update Signed-off-by: Charles de Dreuille --- .../src/components/RadioGroup/RadioGroup.tsx | 15 +- .../src/components/ScrollArea/ScrollArea.tsx | 73 +++++--- .../canon/src/components/Select/Select.tsx | 30 ++-- .../canon/src/components/Switch/Switch.tsx | 7 +- packages/canon/src/components/Table/Table.tsx | 81 ++++++--- .../components/Table/TableCell/TableCell.tsx | 11 +- .../Table/TableCellLink/TableCellLink.tsx | 41 +++-- .../TableCellProfile/TableCellProfile.tsx | 67 ++++---- .../Table/TableCellText/TableCellText.tsx | 33 ++-- packages/canon/src/components/Tabs/Tabs.tsx | 79 +++++---- packages/canon/src/components/Text/Text.tsx | 19 +-- .../src/components/TextField/TextField.tsx | 21 ++- .../canon/src/components/Tooltip/Tooltip.tsx | 103 ++++++----- .../canon/src/utils/componentDefinitions.ts | 161 ++++++++---------- 14 files changed, 416 insertions(+), 325 deletions(-) diff --git a/packages/canon/src/components/RadioGroup/RadioGroup.tsx b/packages/canon/src/components/RadioGroup/RadioGroup.tsx index d1d7451a92..4363477c1a 100644 --- a/packages/canon/src/components/RadioGroup/RadioGroup.tsx +++ b/packages/canon/src/components/RadioGroup/RadioGroup.tsx @@ -22,6 +22,7 @@ import { import clsx from 'clsx'; import { FieldLabel } from '../FieldLabel'; import { FieldError } from '../FieldError'; +import { useStyles } from '../../hooks/useStyles'; import type { RadioGroupProps, RadioProps } from './types'; @@ -40,6 +41,8 @@ export const RadioGroup = forwardRef( ...rest } = props; + const { classNames } = useStyles('RadioGroup'); + useEffect(() => { if (!label && !ariaLabel && !ariaLabelledBy) { console.warn( @@ -54,7 +57,7 @@ export const RadioGroup = forwardRef( return ( ( secondaryLabel={secondaryLabelText} description={description} /> -
{children}
+
{children}
); @@ -78,8 +81,14 @@ RadioGroup.displayName = 'RadioGroup'; export const Radio = forwardRef((props, ref) => { const { className, ...rest } = props; + const { classNames } = useStyles('RadioGroup'); + return ( - + ); }); diff --git a/packages/canon/src/components/ScrollArea/ScrollArea.tsx b/packages/canon/src/components/ScrollArea/ScrollArea.tsx index e96e76c29b..44722fbd12 100644 --- a/packages/canon/src/components/ScrollArea/ScrollArea.tsx +++ b/packages/canon/src/components/ScrollArea/ScrollArea.tsx @@ -17,53 +17,70 @@ import { forwardRef } from 'react'; import { ScrollArea as ScrollAreaPrimitive } from '@base-ui-components/react/scroll-area'; import clsx from 'clsx'; +import { useStyles } from '../../hooks/useStyles'; const ScrollAreaRoot = forwardRef< React.ElementRef, React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); +>(({ className, ...props }, ref) => { + const { classNames } = useStyles('ScrollArea'); + + return ( + + ); +}); ScrollAreaRoot.displayName = ScrollAreaPrimitive.Root.displayName; const ScrollAreaViewport = forwardRef< React.ElementRef, React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); +>(({ className, ...props }, ref) => { + const { classNames } = useStyles('ScrollArea'); + + return ( + + ); +}); ScrollAreaViewport.displayName = ScrollAreaPrimitive.Viewport.displayName; const ScrollAreaScrollbar = forwardRef< React.ElementRef, React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); +>(({ className, ...props }, ref) => { + const { classNames } = useStyles('ScrollArea'); + + return ( + + ); +}); ScrollAreaScrollbar.displayName = ScrollAreaPrimitive.Scrollbar.displayName; const ScrollAreaThumb = forwardRef< React.ElementRef, React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); +>(({ className, ...props }, ref) => { + const { classNames } = useStyles('ScrollArea'); + + return ( + + ); +}); ScrollAreaThumb.displayName = ScrollAreaPrimitive.Thumb.displayName; /** @public */ diff --git a/packages/canon/src/components/Select/Select.tsx b/packages/canon/src/components/Select/Select.tsx index 3f25ac26de..7710d8d587 100644 --- a/packages/canon/src/components/Select/Select.tsx +++ b/packages/canon/src/components/Select/Select.tsx @@ -21,6 +21,7 @@ import clsx from 'clsx'; import './Select.styles.css'; import { SelectProps } from './types'; import { useResponsiveValue } from '../../hooks/useResponsiveValue'; +import { useStyles } from '../../hooks/useStyles'; /** @public */ export const Select = forwardRef((props, ref) => { @@ -37,8 +38,7 @@ export const Select = forwardRef((props, ref) => { ...rest } = props; - // Get the responsive value for the variant - const responsiveSize = useResponsiveValue(size); + const { classNames, dataAttributes } = useStyles('Select'); // Generate unique IDs for accessibility const selectId = useId(); @@ -58,7 +58,7 @@ export const Select = forwardRef((props, ref) => { ); return ( -
+
{label && (