File tree 5 files changed +47
-0
lines changed
5 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ import { MacroIngress } from './ingress/MacroIngress';
28
28
import { MacroAlertBox } from './alert-box/MacroAlertBox' ;
29
29
import { MacroSaksbehandlingstid } from './saksbehandlingstid/MacroSaksbehandlingstid' ;
30
30
import { MacroPayoutDates } from './payout-dates/MacroPayoutDates' ;
31
+ import { MacroConsentBannerLink } from './consent-banner-link/MacroConsentBannerLink' ;
31
32
32
33
const macroComponents : {
33
34
[ key in MacroType ] : React . FunctionComponent < MacroPropsCommon > ;
@@ -37,6 +38,7 @@ const macroComponents: {
37
38
[ MacroType . ButtonBlue ] : MacroButton ,
38
39
[ MacroType . Saksbehandlingstid ] : MacroSaksbehandlingstid ,
39
40
[ MacroType . ChatbotLink ] : MacroChatbotLink ,
41
+ [ MacroType . ConsentBannerLink ] : MacroConsentBannerLink ,
40
42
[ MacroType . ChevronLinkExternal ] : MacroChevronLinkExternal ,
41
43
[ MacroType . ChevronLinkInternal ] : MacroChevronLinkInternal ,
42
44
[ MacroType . Fotnote ] : MacroFotnote ,
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import { LenkeInline } from 'components/_common/lenke/lenkeInline/LenkeInline' ;
3
+ import { Button } from 'components/_common/button/Button' ;
4
+ import { MacroConsentBannerLinkProps } from 'types/macro-props/consent-banner-link' ;
5
+
6
+ type ExtraProps = {
7
+ variant ?: 'secondary' ;
8
+ } ;
9
+
10
+ export const MacroConsentBannerLink = ( { config } : MacroConsentBannerLinkProps ) => {
11
+ if ( ! config ?. consent_banner_link ) {
12
+ return null ;
13
+ }
14
+
15
+ const { text, presentation = 'link' } = config . consent_banner_link ;
16
+
17
+ const Element = presentation === 'link' ? LenkeInline : Button ;
18
+ const extraProps : ExtraProps = presentation === 'link' ? { } : { variant : 'secondary' } ;
19
+
20
+ return (
21
+ < Element
22
+ href = { '/' }
23
+ onClick = { ( e ) => {
24
+ e . preventDefault ( ) ;
25
+ window . webStorageController ?. showConsentBanner ( ) ;
26
+ } }
27
+ { ...extraProps }
28
+ >
29
+ { text }
30
+ </ Element >
31
+ ) ;
32
+ } ;
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ export enum MacroType {
3
3
Button = 'button' ,
4
4
ButtonBlue = 'button-blue' ,
5
5
ChatbotLink = 'chatbot-link' ,
6
+ ConsentBannerLink = 'consent-banner-link' ,
6
7
ChevronLinkInternal = 'chevron-link-internal' ,
7
8
ChevronLinkExternal = 'chevron-link-external' ,
8
9
Fotnote = 'fotnote' ,
Original file line number Diff line number Diff line change
1
+ import { MacroPropsCommon , MacroType } from './_macros-common' ;
2
+
3
+ export interface MacroConsentBannerLinkProps extends MacroPropsCommon {
4
+ name : MacroType . ChevronLinkExternal ;
5
+ config : {
6
+ consent_banner_link : {
7
+ text : string ;
8
+ presentation : 'button' | 'link' ;
9
+ } ;
10
+ } ;
11
+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ declare global {
10
10
destroy : ( widgetId : string , deleteElement ?: boolean ) => any ;
11
11
widgets : ( widgetId : string ) => any ;
12
12
} ;
13
+ webStorageController : any ;
13
14
}
14
15
15
16
interface WindowEventMap {
You can’t perform that action at this time.
0 commit comments