diff --git a/gradle/changelog/cardtags_added.yaml b/gradle/changelog/cardtags_added.yaml new file mode 100644 index 0000000000..68b83d94f3 --- /dev/null +++ b/gradle/changelog/cardtags_added.yaml @@ -0,0 +1,2 @@ +- type: added + description: Cardtags can now be colored according to 3 distinct styles diff --git a/scm-ui/ui-layout/src/card/CardDetail.tsx b/scm-ui/ui-layout/src/card/CardDetail.tsx index 4c051fb49f..d1cb918da3 100644 --- a/scm-ui/ui-layout/src/card/CardDetail.tsx +++ b/scm-ui/ui-layout/src/card/CardDetail.tsx @@ -27,10 +27,27 @@ import classNames from "classnames"; import { useGeneratedId } from "@scm-manager/ui-components"; import styled from "styled-components"; +export const CardVariants = { + LIGHT: "light", + INFO: "info", +} as const; + +type CardVariant = typeof CardVariants[keyof typeof CardVariants]; + +const createCardVariantClasses = (variant?: string | undefined) => + classNames({ + "is-light": variant === "light" || !variant, + "is-info": variant === "info", + }); + type CardDetailProps = HTMLAttributes & { children: ReactNode | ((props: { labelId: string }) => ReactNode); }; +type CardVariantProps = { + cardVariant?: CardVariant; +}; + /** * @beta * @since 2.46.0 @@ -62,9 +79,13 @@ export const CardDetailLabel = React.forwardRef>( +export const CardDetailTag = React.forwardRef & CardVariantProps>( ({ children, className, ...props }, ref) => ( - + {children} )