diff --git a/packages/canon/.storybook/preview.tsx b/packages/canon/.storybook/preview.tsx index 0588d75c0a..fbc319ccea 100644 --- a/packages/canon/.storybook/preview.tsx +++ b/packages/canon/.storybook/preview.tsx @@ -29,43 +29,43 @@ const preview: Preview = { }, viewport: { viewports: { - xs: { - name: 'XSmall', + initial: { + name: 'Initial', styles: { width: '320px', height: '100%', }, }, - small: { - name: 'Small', + xs: { + name: 'Extra Small', styles: { width: '640px', height: '100%', }, }, - medium: { - name: 'Medium', + sm: { + name: 'Small', styles: { width: '768px', height: '100%', }, }, - large: { - name: 'Large', + md: { + name: 'Medium', styles: { width: '1024px', height: '100%', }, }, - xlarge: { - name: 'XLarge', + lg: { + name: 'Large', styles: { width: '1280px', height: '100%', }, }, - '2xl': { - name: '2XL', + xl: { + name: 'Extra Large', styles: { width: '1536px', height: '100%', diff --git a/packages/canon/report.api.md b/packages/canon/report.api.md index 0c8abe0cc1..8899f6ad45 100644 --- a/packages/canon/report.api.md +++ b/packages/canon/report.api.md @@ -68,7 +68,7 @@ export interface BoxProps extends UtilityProps { } // @public (undocumented) -export type Breakpoint = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'; +export type Breakpoint = 'initial' | 'xs' | 'sm' | 'md' | 'lg' | 'xl'; // @public (undocumented) export const Button: React_2.ForwardRefExoticComponent< @@ -101,12 +101,6 @@ export interface ButtonProps { // @public (undocumented) export interface CanonContextProps { - // (undocumented) - breakpoint: Breakpoint; - // (undocumented) - getResponsiveValue: ( - value: string | Partial>, - ) => string; // (undocumented) icons: IconMap; } diff --git a/packages/canon/src/components/Button/Button.stories.tsx b/packages/canon/src/components/Button/Button.stories.tsx index 728098970c..8661dc927d 100644 --- a/packages/canon/src/components/Button/Button.stories.tsx +++ b/packages/canon/src/components/Button/Button.stories.tsx @@ -114,7 +114,7 @@ export const Responsive: Story = { args: { children: 'Button', variant: { - xs: 'primary', + initial: 'primary', sm: 'secondary', md: 'tertiary', }, diff --git a/packages/canon/src/components/Button/Button.tsx b/packages/canon/src/components/Button/Button.tsx index 2e2371f82a..c44d81dc15 100644 --- a/packages/canon/src/components/Button/Button.tsx +++ b/packages/canon/src/components/Button/Button.tsx @@ -18,9 +18,10 @@ import React, { forwardRef } from 'react'; import { Icon } from '../Icon'; -import { ButtonProps } from './types'; -import { useCanon } from '../../contexts/canon'; import clsx from 'clsx'; +import { useResponsiveValue } from '../../hooks/useResponsiveValue'; + +import type { ButtonProps } from './types'; /** @public */ export const Button = forwardRef( @@ -37,11 +38,9 @@ export const Button = forwardRef( ...rest } = props; - const { getResponsiveValue } = useCanon(); - // Get the responsive value for the variant - const responsiveSize = getResponsiveValue(size); - const responsiveVariant = getResponsiveValue(variant); + const responsiveSize = useResponsiveValue(size); + const responsiveVariant = useResponsiveValue(variant); return (