diff --git a/src/app-components/Text/DisplayText.tsx b/src/app-components/Text/DisplayText.tsx index 3cf5b63167..3424740fec 100644 --- a/src/app-components/Text/DisplayText.tsx +++ b/src/app-components/Text/DisplayText.tsx @@ -9,15 +9,8 @@ interface TextProps { labelId?: string; } -export const DisplayText = ({ value, iconUrl, iconAltText, labelId }: TextProps) => ( +export const DisplayText = ({ value, labelId }: Pick) => ( <> - {iconUrl && ( - {iconAltText} - )} {labelId && {value}} {!labelId && {value}} diff --git a/src/components/label/Label.tsx b/src/components/label/Label.tsx index e4a2f862ad..5597c7b7e6 100644 --- a/src/components/label/Label.tsx +++ b/src/components/label/Label.tsx @@ -24,6 +24,7 @@ export type LabelProps = PropsWithChildren<{ className?: string; overrideId?: string; textResourceBindings?: ExprResolved; + labelPrefix?: React.ReactNode; }> & DesignsystemetLabelProps; @@ -47,6 +48,7 @@ export function LabelInner(props: LabelInnerProps) { renderLabelAs, className, textResourceBindings: overriddenTrb, + labelPrefix, ...designsystemetLabelProps } = props; @@ -67,7 +69,12 @@ export function LabelInner(props: LabelInnerProps) { const labelId = getLabelId(id); const labelContentProps: LabelContentProps = { id, - label: textResourceBindings.title, + label: ( + <> + {labelPrefix} + {textResourceBindings.title} + + ), description: textResourceBindings.description, help: textResourceBindings.help, required, diff --git a/src/layout/Text/TextComponent.tsx b/src/layout/Text/TextComponent.tsx index 6b4da3c876..9ea6450966 100644 --- a/src/layout/Text/TextComponent.tsx +++ b/src/layout/Text/TextComponent.tsx @@ -15,8 +15,26 @@ export const TextComponent = ({ baseComponentId }: PropsFromGenericComponent<'Te const direction = _direction ?? 'horizontal'; const { langAsString } = useLanguage(); + const iconElement = icon && ( + {textResourceBindings?.title + ); + if (!textResourceBindings?.title) { - return ; + return ( +
+ {iconElement} + +
+ ); } return ( @@ -25,6 +43,7 @@ export const TextComponent = ({ baseComponentId }: PropsFromGenericComponent<'Te label={{ baseComponentId, renderLabelAs: 'span', + labelPrefix: iconElement, className: cn( classes.label, classes.textComponent, @@ -34,8 +53,6 @@ export const TextComponent = ({ baseComponentId }: PropsFromGenericComponent<'Te >