5180 fichiers 38.5 Mo 0 téléchargements 304 vues mis à jour il y a 6 heures ui
LoginWidgetSlot.tsx 2.1 Ko Télécharger le fichier
import { FC, useRef } from 'react';
import { useDraggableLoginWindow } from '../hooks/useDraggableLoginWindow';
import { BaseButton } from '../../../common/BaseButton';
import { NativeTextTree } from '../../../common/native-text/NativeTextTree';
import { resolveNewsLink } from '../utils/news';

interface LoginWidgetSlotProps {
    slotKey: string;
    type: string;
    image: string;
    title: string;
    description: string;
    buttonText: string;
    buttonLink: string;
    dragHint: string;
}

export const LoginWidgetSlot: FC<LoginWidgetSlotProps> = ({ slotKey, type, image, title, description, buttonText, buttonLink, dragHint }) => {
    const rootRef = useRef<HTMLDivElement>(null);
    const { style, dragging, handleProps } = useDraggableLoginWindow(`widget.${slotKey}`, rootRef);

    return (
        <NativeTextTree>
            <div
                className={`login-widget-slot login-drag-handle${dragging ? ' is-dragging' : ''}`}
                data-widget-type={type}
                ref={rootRef}
                style={style}
                title={dragHint}
                {...handleProps}
            >
                {image && <img className="login-widget-image" src={image} alt="" draggable={false} />}
                <div className="login-widget-content">
                    <div className="login-widget-title">{title}</div>
                    {description && <div className="login-widget-description">{description}</div>}
                    {buttonText && (
                        <BaseButton
                            type="button"
                            className="login-widget-button"
                            onClick={() => {
                                // The link comes from the CMS: only a web URL or a path on this site is followed.
                                const target = resolveNewsLink(buttonLink);
                                if (target) window.location.href = target;
                            }}
                        >
                            {buttonText}
                        </BaseButton>
                    )}
                </div>
            </div>
        </NativeTextTree>
    );
};
15Sujets
1Dépôts
20Membres
2En ligne
Profile
Inscrit
Dernière visite
Messages
0
Votes positifs
0
Votes négatifs
0

Nous utilisons des cookies pour assurer le bon fonctionnement du site et améliorer votre expérience. en savoir plus

Autoriser