Skip to content

Commit

Permalink
feat: legg til nytt compact-API og deprecate det eksisterende
Browse files Browse the repository at this point in the history
  • Loading branch information
wkillerud committed Sep 7, 2022
1 parent 45db6c2 commit 47c0f5d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion packages/core/src/components/Label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ import { WithChildren } from "../types";
export interface LabelProps extends WithChildren {
id?: string;
variant?: LabelVariant;
/**
* Skal bare brukes i informasjonstette applikasjoner.
* @default false
*/
compact?: boolean;
/**
* @default false
* @deprecated Bruk compact
*/
forceCompact?: boolean;
srOnly?: boolean;
standAlone?: boolean;
Expand All @@ -15,6 +24,7 @@ export interface LabelProps extends WithChildren {

export const Label: FC<LabelProps> = ({
variant = "small",
compact,
forceCompact,
srOnly,
children,
Expand All @@ -25,7 +35,7 @@ export const Label: FC<LabelProps> = ({
}) => {
const labelClassNames = classNames("jkl-label", className, {
[`jkl-label--${variant}`]: variant,
"jkl-label--compact": forceCompact,
"jkl-label--compact": compact || forceCompact,
"jkl-label--sr-only": srOnly,
});

Expand Down
12 changes: 11 additions & 1 deletion packages/core/src/components/SupportLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ export interface SupportLabelProps {
id: string;
helpLabel?: string;
errorLabel?: string;
/**
* Skal bare brukes i informasjonstette applikasjoner.
* @default false
*/
compact?: boolean;
/**
* @default false
* @deprecated Bruk compact
*/
forceCompact?: boolean;
className?: string;
srOnly?: boolean;
Expand All @@ -45,6 +54,7 @@ export const SupportLabel: FC<SupportLabelProps> = ({
id,
helpLabel,
errorLabel,
compact,
forceCompact,
className,
srOnly,
Expand All @@ -54,7 +64,7 @@ export const SupportLabel: FC<SupportLabelProps> = ({

const componentClassName = hasLabel
? cn("jkl-form-support-label", className, {
"jkl-form-support-label--compact": forceCompact,
"jkl-form-support-label--compact": compact || forceCompact,
"jkl-form-support-label--error": errorLabel,
"jkl-form-support-label--help": !errorLabel,
"jkl-form-support-label--sr-only": srOnly,
Expand Down

0 comments on commit 47c0f5d

Please sign in to comment.