mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-01-21 23:12:11 +01:00
Card Tag Variants
CardDetailTags can now be styled according to 3 distinct styles, info, info-light and light
This commit is contained in:
2
gradle/changelog/cardtags_added.yaml
Normal file
2
gradle/changelog/cardtags_added.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
- type: added
|
||||
description: Cardtags can now be colored according to 3 distinct styles
|
||||
@@ -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<HTMLSpanElement> & {
|
||||
children: ReactNode | ((props: { labelId: string }) => ReactNode);
|
||||
};
|
||||
|
||||
type CardVariantProps = {
|
||||
cardVariant?: CardVariant;
|
||||
};
|
||||
|
||||
/**
|
||||
* @beta
|
||||
* @since 2.46.0
|
||||
@@ -62,9 +79,13 @@ export const CardDetailLabel = React.forwardRef<HTMLSpanElement, HTMLAttributes<
|
||||
* @beta
|
||||
* @since 2.46.0
|
||||
*/
|
||||
export const CardDetailTag = React.forwardRef<HTMLSpanElement, HTMLAttributes<HTMLSpanElement>>(
|
||||
export const CardDetailTag = React.forwardRef<HTMLSpanElement, HTMLAttributes<HTMLSpanElement> & CardVariantProps>(
|
||||
({ children, className, ...props }, ref) => (
|
||||
<span {...props} className={classNames("tag is-rounded is-light", className)} ref={ref}>
|
||||
<span
|
||||
{...props}
|
||||
className={classNames("tag is-rounded", createCardVariantClasses(props.cardVariant), className)}
|
||||
ref={ref}
|
||||
>
|
||||
{children}
|
||||
</span>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user