diff --git a/.changeset/afraid-eagles-enjoy.md b/.changeset/afraid-eagles-enjoy.md new file mode 100644 index 0000000..9f2239a --- /dev/null +++ b/.changeset/afraid-eagles-enjoy.md @@ -0,0 +1,5 @@ +--- +"@saleor/apps-ui": minor +--- + +Added SemanticChip component that wraps MacawUI Chip with semantic variants: error, warning, success & default diff --git a/.changeset/new-readers-teach.md b/.changeset/new-readers-teach.md new file mode 100644 index 0000000..d1b2030 --- /dev/null +++ b/.changeset/new-readers-teach.md @@ -0,0 +1,5 @@ +--- +"saleor-app-search": minor +--- + +Replaced custom Chip implementation with SemanticChip from shared package diff --git a/apps/search/package.json b/apps/search/package.json index d4410e8..3a46385 100644 --- a/apps/search/package.json +++ b/apps/search/package.json @@ -19,7 +19,8 @@ "@hookform/resolvers": "^3.1.0", "@saleor/app-sdk": "0.37.3", "@saleor/apps-shared": "workspace:*", - "@saleor/macaw-ui": "0.8.0-pre.84", + "@saleor/apps-ui": "workspace:*", + "@saleor/macaw-ui": "^0.8.0-pre.84", "@sentry/nextjs": "^7.46.0", "@types/debug": "^4.1.7", "@urql/exchange-auth": "^1.0.0", diff --git a/apps/search/src/components/WebhooksStatus.tsx b/apps/search/src/components/WebhooksStatus.tsx index f461abf..8b7a24c 100644 --- a/apps/search/src/components/WebhooksStatus.tsx +++ b/apps/search/src/components/WebhooksStatus.tsx @@ -1,6 +1,7 @@ import { Accordion, Box, Chip, Text } from "@saleor/macaw-ui/next"; import { EventDeliveryStatusEnum } from "../../generated/graphql"; import { useWebhooksStatus } from "../lib/useWebhooksStatus"; +import { SemanticChip } from "@saleor/apps-ui"; export const WebhooksStatus = () => { const { data: webhooksData } = useWebhooksStatus(); @@ -38,23 +39,15 @@ export const WebhooksStatus = () => { alignItems={"center"} > {webhook.asyncEvents[0].name} - - - {webhook.isActive ? "Active" : "Disabled"} - - + {webhook.isActive ? ( + + ACTIVE + + ) : ( + + DISABLED + + )} diff --git a/packages/ui/index.ts b/packages/ui/index.ts index dcf5e6f..795ca82 100644 --- a/packages/ui/index.ts +++ b/packages/ui/index.ts @@ -1,3 +1 @@ -/* - * * export components from here - */ +export * from "./src/semantic-chip"; diff --git a/packages/ui/src/semantic-chip.tsx b/packages/ui/src/semantic-chip.tsx new file mode 100644 index 0000000..1a2c136 --- /dev/null +++ b/packages/ui/src/semantic-chip.tsx @@ -0,0 +1,53 @@ +import { BoxProps, Chip, ChipProps, Text, TextProps } from "@saleor/macaw-ui/next"; + +const colorPropsBorderMapping: Record = { + default: "neutralSubdued", + warning: "criticalDefault", + error: "criticalDefault", + success: "neutralDefault", +}; + +const colorPropsTextMapping: Record = { + default: "textNeutralPlain", + warning: "textCriticalDefault", + error: "textCriticalDefault", + success: "text2Decorative", +}; + +const colorPropsBgMapping: Record = { + default: "surfaceNeutralHighlight", + warning: "surfaceNeutralHighlight", + error: "surfaceCriticalSubdued", + success: "decorativeSurfaceSubdued2", +}; + +interface ChipTextProps extends ChipProps { + variant?: "default" | "warning" | "error" | "success"; + innerTextProps?: TextProps; +} + +export const SemanticChip = ({ + variant = "default", + children, + size, + innerTextProps, + ...props +}: ChipTextProps) => { + return ( + + + {children} + + + ); +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 83404c7..9660d4d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1233,8 +1233,11 @@ importers: '@saleor/apps-shared': specifier: workspace:* version: link:../../packages/shared + '@saleor/apps-ui': + specifier: workspace:* + version: link:../../packages/ui '@saleor/macaw-ui': - specifier: 0.8.0-pre.84 + specifier: ^0.8.0-pre.84 version: 0.8.0-pre.84(@types/react@18.0.38)(react-dom@18.2.0)(react@18.2.0) '@sentry/nextjs': specifier: ^7.46.0