diff --git a/packages/admin-ui/src/lib/core/src/shared/components/action-bar/action-bar.component.scss b/packages/admin-ui/src/lib/core/src/shared/components/action-bar/action-bar.component.scss index 8171935b8b..e22ac05a4e 100644 --- a/packages/admin-ui/src/lib/core/src/shared/components/action-bar/action-bar.component.scss +++ b/packages/admin-ui/src/lib/core/src/shared/components/action-bar/action-bar.component.scss @@ -1,6 +1,6 @@ @import 'variables'; -:host { +:host, .vdr-action-bar { display: flex; justify-content: space-between; align-items: baseline; diff --git a/packages/admin-ui/src/lib/core/src/shared/components/data-table-2/data-table2.component.ts b/packages/admin-ui/src/lib/core/src/shared/components/data-table-2/data-table2.component.ts index 36f67ff4e3..f8b144d59a 100644 --- a/packages/admin-ui/src/lib/core/src/shared/components/data-table-2/data-table2.component.ts +++ b/packages/admin-ui/src/lib/core/src/shared/components/data-table-2/data-table2.component.ts @@ -42,7 +42,7 @@ import { DataTable2SearchComponent } from './data-table-search.component'; * extend the {@link BaseListComponent} or {@link TypedBaseListComponent} class. * * @example - * ```HTML + * ```html * Optional left content}> + * + * + * ); + * } + * ``` + * + * @docsCategory react-components + */ +export function ActionBar(props: PropsWithChildren<{ leftContent?: ReactNode }>) { + return ( +
+
{props.leftContent}
+
{props.children}
+
+ ); +} diff --git a/packages/admin-ui/src/lib/react/src/react-components/CdsIcon.tsx b/packages/admin-ui/src/lib/react/src/react-components/CdsIcon.tsx new file mode 100644 index 0000000000..a19f3840c6 --- /dev/null +++ b/packages/admin-ui/src/lib/react/src/react-components/CdsIcon.tsx @@ -0,0 +1,53 @@ +import { ClarityIcons } from '@cds/core/icon'; +import { IconShapeTuple } from '@cds/core/icon/interfaces/icon.interfaces'; +import React, { DOMAttributes, useEffect } from 'react'; + +type CustomElement = Partial & { children: any }>; + +export interface CdsIconProps { + shape: string; + size: string | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'; + direction: 'up' | 'down' | 'left' | 'right'; + flip: 'horizontal' | 'vertical'; + solid: boolean; + status: 'info' | 'success' | 'warning' | 'danger'; + inverse: boolean; + badge: 'info' | 'success' | 'warning' | 'danger'; +} + +declare global { + namespace JSX { + interface IntrinsicElements { + ['cds-icon']: CustomElement; + } + } +} + +export function registerCdsIcon(icon: IconShapeTuple) { + ClarityIcons.addIcons(icon); +} + +/** + * @description + * A React wrapper for the Clarity UI icon component. + * + * @example + * ```ts + * import { userIcon } from '@cds/core/icon'; + * import { CdsIcon } from '@vendure/admin-ui/react'; + * + * registerCdsIcon(userIcon); + * export function MyComponent() { + * return ; + * } + * ``` + * + * @docsCategory react-components + */ +export function CdsIcon(props: { icon: IconShapeTuple; className?: string } & Partial) { + const { icon, ...rest } = props; + useEffect(() => { + ClarityIcons.addIcons(icon); + }, [icon]); + return ; +} diff --git a/packages/admin-ui/src/lib/react/src/react-components/FormField.tsx b/packages/admin-ui/src/lib/react/src/react-components/FormField.tsx new file mode 100644 index 0000000000..1ddb3f348a --- /dev/null +++ b/packages/admin-ui/src/lib/react/src/react-components/FormField.tsx @@ -0,0 +1,41 @@ +import React, { PropsWithChildren } from 'react'; + +/** + * @description + * A wrapper around form fields which provides a label, tooltip and error message. + * + * @example + * ```ts + * import { FormField } from '@vendure/admin-ui/react'; + * + * export function MyReactComponent() { + * return ( + * + * + * + * ); + * } + * ``` + * + * @docsCategory react-components + */ +export function FormField( + props: PropsWithChildren<{ + for?: string; + label?: string; + tooltip?: string; + invalid?: boolean; + errorMessage?: string; + }>, +) { + return ( +
+ {props.label && } + {props.tooltip &&
{props.tooltip}
} +
{props.children}
+ {props.errorMessage &&
{props.errorMessage}
} +
+ ); +} diff --git a/packages/admin-ui/src/lib/react/src/react-components/PageBlock.tsx b/packages/admin-ui/src/lib/react/src/react-components/PageBlock.tsx new file mode 100644 index 0000000000..f1b6622c60 --- /dev/null +++ b/packages/admin-ui/src/lib/react/src/react-components/PageBlock.tsx @@ -0,0 +1,24 @@ +import React, { PropsWithChildren } from 'react'; + +/** + * @description + * A container for page content which provides a consistent width and spacing. + * + * @example + * ```ts + * import { PageBlock } from '@vendure/admin-ui/react'; + * + * export function MyComponent() { + * return ( + * + * ... + * + * ); + * } + * ``` + * + * @docsCategory react-components + */ +export function PageBlock(props: PropsWithChildren) { + return
{props.children}
; +} diff --git a/packages/admin-ui/src/lib/react/src/react-components/PageDetailLayout.tsx b/packages/admin-ui/src/lib/react/src/react-components/PageDetailLayout.tsx new file mode 100644 index 0000000000..99b9c4a164 --- /dev/null +++ b/packages/admin-ui/src/lib/react/src/react-components/PageDetailLayout.tsx @@ -0,0 +1,29 @@ +import React, { PropsWithChildren, ReactNode } from 'react'; + +/** + * @description + * A responsive container for detail views with a main content area and an optional sidebar. + * + * @example + * ```ts + * import { PageDetailLayout } from '@vendure/admin-ui/react'; + * + * export function MyComponent() { + * return ( + * Sidebar content}> + *
Main content
+ *
+ * ); + * } + * ``` + * + * @docsCategory react-components + */ +export function PageDetailLayout(props: PropsWithChildren<{ sidebar?: ReactNode }>) { + return ( +
+
{props.children}
+
{props.sidebar}
+
+ ); +}