diff --git a/packages/canon/docs/components/IconLibrary/IconLibrary.tsx b/packages/canon/docs/components/IconLibrary/IconLibrary.tsx index e32f4c08a4..1d517f7a98 100644 --- a/packages/canon/docs/components/IconLibrary/IconLibrary.tsx +++ b/packages/canon/docs/components/IconLibrary/IconLibrary.tsx @@ -16,15 +16,15 @@ import React from 'react'; import { Icon } from '@backstage/canon'; import type { IconNames } from '@backstage/canon'; -import { defaultIcons } from '../../../src/components/Icon/icons'; +import { icons } from '../../../src/components/Icon/icons'; import { Text } from '../Text/Text'; export const IconLibrary = () => { - const icons = Object.keys(defaultIcons); + const iconsList = Object.keys(icons); return (
- {icons.map(icon => ( + {iconsList.map(icon => (
diff --git a/packages/canon/report.api.md b/packages/canon/report.api.md index e725d0ac8b..fc1f773b4b 100644 --- a/packages/canon/report.api.md +++ b/packages/canon/report.api.md @@ -5,9 +5,11 @@ ```ts /// +import type { CSSProperties } from 'react'; import { ForwardRefExoticComponent } from 'react'; import { default as React_2 } from 'react'; import * as React_3 from 'react'; +import { ReactNode } from 'react'; import { RefAttributes } from 'react'; // @public (undocumented) @@ -84,6 +86,8 @@ export interface ButtonProps { // (undocumented) size?: 'small' | 'medium' | Partial>; // (undocumented) + style?: React.CSSProperties; + // (undocumented) variant?: | 'primary' | 'secondary' @@ -91,6 +95,29 @@ export interface ButtonProps { | Partial>; } +// @public (undocumented) +export interface CanonContextProps { + // (undocumented) + breakpoint: Breakpoint; + // (undocumented) + getResponsiveValue: ( + value: string | Partial>, + ) => string; + // (undocumented) + icons: IconMap; +} + +// @public (undocumented) +export const CanonProvider: (props: CanonProviderProps) => React_2.JSX.Element; + +// @public (undocumented) +export interface CanonProviderProps { + // (undocumented) + children?: ReactNode; + // (undocumented) + overrides?: Partial>; +} + // @public (undocumented) export const Checkbox: React_2.ForwardRefExoticComponent< CheckboxProps & React_2.RefAttributes @@ -200,6 +227,33 @@ export interface GridProps extends SpaceProps { style?: React.CSSProperties; } +// @public (undocumented) +export const Heading: React_2.ForwardRefExoticComponent< + HeadingProps & React_2.RefAttributes +>; + +// @public (undocumented) +export interface HeadingProps { + // (undocumented) + as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'; + // (undocumented) + children: React.ReactNode; + // (undocumented) + variant?: + | 'display' + | 'title1' + | 'title2' + | 'title3' + | 'title4' + | 'title5' + | Partial< + Record< + Breakpoint, + 'display' | 'title1' | 'title2' | 'title3' | 'title4' | 'title5' + > + >; +} + // @public (undocumented) export const Icon: (props: IconProps) => React_2.JSX.Element; @@ -222,8 +276,11 @@ export type IconNames = | 'chevronRight' | 'chevronUp' | 'cloud' + | 'externalLink' | 'heart' + | 'moon' | 'plus' + | 'sun' | 'trash'; // @public (undocumented) @@ -232,6 +289,9 @@ export type IconProps = { size?: number; }; +// @public (undocumented) +export const icons: IconMap; + // @public (undocumented) export const Inline: ForwardRefExoticComponent< InlineProps & RefAttributes @@ -374,6 +434,32 @@ export const TableRow: React_3.ForwardRefExoticComponent< React_3.RefAttributes >; +// @public (undocumented) +const Text_2: React_2.ForwardRefExoticComponent< + TextProps & React_2.RefAttributes +>; +export { Text_2 as Text }; + +// @public (undocumented) +export interface TextProps { + // (undocumented) + children: ReactNode; + // (undocumented) + style?: CSSProperties; + // (undocumented) + variant?: + | 'subtitle' + | 'body' + | 'caption' + | 'label' + | Partial>; + // (undocumented) + weight?: 'regular' | 'bold' | Partial>; +} + +// @public (undocumented) +export const useCanon: () => CanonContextProps; + // @public (undocumented) export interface UtilityProps extends SpaceProps { // (undocumented) diff --git a/packages/canon/src/components/Box/Box.stories.tsx b/packages/canon/src/components/Box/Box.stories.tsx index bd4e597fa0..d11f9fbab7 100644 --- a/packages/canon/src/components/Box/Box.stories.tsx +++ b/packages/canon/src/components/Box/Box.stories.tsx @@ -40,22 +40,28 @@ const meta = { export default meta; type Story = StoryObj; -export const Basic: Story = { +export const Default: Story = { args: { style: { - background: '#1f47ff', - color: 'white', - padding: '4px 8px', + width: '64px', + height: '64px', + background: '#eaf2fd', borderRadius: '4px', + border: '1px solid #2563eb', + color: '#2563eb', + backgroundImage: + 'url("data:image/svg+xml,%3Csvg%20width%3D%226%22%20height%3D%226%22%20viewBox%3D%220%200%206%206%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%3E%3Cg%20fill%3D%22%232563eb%22%20fill-opacity%3D%220.3%22%20fill-rule%3D%22evenodd%22%3E%3Cpath%20d%3D%22M5%200h1L0%206V5zM6%205v1H5z%22/%3E%3C/g%3E%3C/svg%3E")', }, - children: 'Basic Box', }, }; export const Display: Story = { args: { style: { - ...Basic.args?.style, + ...Default.args?.style, + width: 'auto', + height: 'auto', + padding: '8px', }, }, render: args => ( @@ -84,7 +90,10 @@ export const Display: Story = { export const FlexDirection: Story = { args: { style: { - ...Basic.args?.style, + ...Default.args?.style, + width: 'auto', + height: 'auto', + padding: '8px', }, display: 'flex', gap: 'xs', @@ -110,8 +119,10 @@ export const FlexDirection: Story = { export const JustifyContent: Story = { args: { style: { - ...Basic.args?.style, + ...Default.args?.style, width: '200px', + height: 'auto', + padding: '8px', }, display: 'flex', gap: 'xs', @@ -153,9 +164,10 @@ export const JustifyContent: Story = { export const AlignItems: Story = { args: { style: { - ...Basic.args?.style, + ...Default.args?.style, width: '200px', height: '100px', + padding: '8px', }, display: 'flex', gap: 'xs', @@ -289,8 +301,10 @@ export const Margin: Story = { export const FlexWrap: Story = { args: { style: { - ...Basic.args?.style, + ...Default.args?.style, width: '200px', + height: 'auto', + padding: '8px', }, display: 'flex', gap: 'xs', @@ -328,11 +342,14 @@ export const FlexWrap: Story = { export const BorderRadius: Story = { args: { style: { - background: '#1f47ff', - color: 'white', - padding: '4px 8px', width: '64px', height: '64px', + background: '#eaf2fd', + border: '1px solid #2563eb', + color: '#2563eb', + backgroundImage: + 'url("data:image/svg+xml,%3Csvg%20width%3D%226%22%20height%3D%226%22%20viewBox%3D%220%200%206%206%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%3E%3Cg%20fill%3D%22%232563eb%22%20fill-opacity%3D%220.3%22%20fill-rule%3D%22evenodd%22%3E%3Cpath%20d%3D%22M5%200h1L0%206V5zM6%205v1H5z%22/%3E%3C/g%3E%3C/svg%3E")', + padding: '4px 8px', }, display: 'flex', alignItems: 'center', diff --git a/packages/canon/src/components/Button/Button.stories.tsx b/packages/canon/src/components/Button/Button.stories.tsx index c921efa6f2..728098970c 100644 --- a/packages/canon/src/components/Button/Button.stories.tsx +++ b/packages/canon/src/components/Button/Button.stories.tsx @@ -19,13 +19,12 @@ import type { Meta, StoryObj } from '@storybook/react'; import { Button } from './Button'; import { Inline } from '../Inline'; import { Stack } from '../Stack'; +import { Text } from '../Text'; +import { ButtonProps } from './types'; const meta = { title: 'Components/Button', component: Button, - parameters: { - layout: 'centered', - }, argTypes: { size: { control: 'select', @@ -40,12 +39,6 @@ const meta = { export default meta; type Story = StoryObj; -export const Primary: Story = { - args: { - children: 'Primary button', - }, -}; - export const Variants: Story = { args: { children: 'Button', @@ -59,9 +52,15 @@ export const Variants: Story = { }, render: () => ( - - - + + + ), }; @@ -125,3 +124,47 @@ export const Responsive: Story = { }, }, }; + +const variants: string[] = ['primary', 'secondary', 'tertiary']; + +export const Playground: Story = { + args: { + children: 'Button', + }, + render: () => ( + + {variants.map(variant => ( + + {variant} + {['small', 'medium'].map(size => ( + + + + + + ))} + + ))} + + ), +}; diff --git a/packages/canon/src/components/Button/Button.tsx b/packages/canon/src/components/Button/Button.tsx index 4c06e93214..a186aada39 100644 --- a/packages/canon/src/components/Button/Button.tsx +++ b/packages/canon/src/components/Button/Button.tsx @@ -31,6 +31,8 @@ export const Button = forwardRef( iconStart, iconEnd, children, + style, + ...rest } = props; const { getResponsiveValue } = useCanon(); @@ -41,7 +43,7 @@ export const Button = forwardRef( return (