|
| 1 | +import type { ReactElement } from 'react'; |
| 2 | +import React from 'react'; |
| 3 | +import { useAuthContext } from '../../contexts/AuthContext'; |
| 4 | +import { useConditionalFeature } from '../../hooks/useConditionalFeature'; |
| 5 | +import { featurePostSignupWidget } from '../../lib/featureManagement'; |
| 6 | +import { AuthTriggers } from '../../lib/auth'; |
| 7 | +import { ButtonSize, ButtonVariant } from '../buttons/Button'; |
| 8 | +import AuthOptions from '../auth/AuthOptions'; |
| 9 | +import { AuthDisplay } from '../auth/common'; |
| 10 | + |
| 11 | +const gradientStyle: React.CSSProperties = { |
| 12 | + backgroundImage: |
| 13 | + 'linear-gradient(90deg, var(--theme-accent-cabbage-default) 0%, var(--theme-accent-onion-default) 30%, var(--theme-accent-water-default) 60%, var(--theme-accent-cabbage-default) 100%)', |
| 14 | + backgroundSize: '200% auto', |
| 15 | + animation: 'post-signup-gradient-shift 10s ease-in-out infinite', |
| 16 | + WebkitBackgroundClip: 'text', |
| 17 | + backgroundClip: 'text', |
| 18 | + color: 'transparent', |
| 19 | +}; |
| 20 | + |
| 21 | +export function PostSignupWidget(): ReactElement | null { |
| 22 | + const { user, isAuthReady, showLogin } = useAuthContext(); |
| 23 | + const shouldEvaluate = isAuthReady && !user; |
| 24 | + const { value: isEnabled } = useConditionalFeature({ |
| 25 | + feature: featurePostSignupWidget, |
| 26 | + shouldEvaluate, |
| 27 | + }); |
| 28 | + |
| 29 | + if (!shouldEvaluate || !isEnabled) { |
| 30 | + return null; |
| 31 | + } |
| 32 | + |
| 33 | + return ( |
| 34 | + <div className="flex flex-col rounded-16 border border-border-subtlest-tertiary p-4"> |
| 35 | + <style> |
| 36 | + {`@keyframes post-signup-gradient-shift { |
| 37 | + 0% { background-position: 0% 50%; } |
| 38 | + 50% { background-position: 100% 50%; } |
| 39 | + 100% { background-position: 0% 50%; } |
| 40 | + }`} |
| 41 | + </style> |
| 42 | + <h3 className="font-bold typo-title3" style={gradientStyle}> |
| 43 | + Want your personalized dev feed? |
| 44 | + </h3> |
| 45 | + <p className="mt-2 text-text-tertiary typo-footnote"> |
| 46 | + Millions of developers rely on daily.dev for tech news, tools, and |
| 47 | + discussions that actually matter. |
| 48 | + </p> |
| 49 | + <div className="mt-4"> |
| 50 | + <AuthOptions |
| 51 | + ignoreMessages |
| 52 | + formRef={null as unknown as React.MutableRefObject<HTMLFormElement>} |
| 53 | + trigger={AuthTriggers.PostPage} |
| 54 | + simplified |
| 55 | + defaultDisplay={AuthDisplay.OnboardingSignup} |
| 56 | + forceDefaultDisplay |
| 57 | + className={{ |
| 58 | + onboardingSignup: '!gap-3', |
| 59 | + }} |
| 60 | + onAuthStateUpdate={(props) => { |
| 61 | + showLogin({ |
| 62 | + trigger: AuthTriggers.Onboarding, |
| 63 | + options: { isLogin: true, formValues: props }, |
| 64 | + }); |
| 65 | + }} |
| 66 | + onboardingSignupButton={{ |
| 67 | + variant: ButtonVariant.Primary, |
| 68 | + size: ButtonSize.Medium, |
| 69 | + }} |
| 70 | + hideLoginLink |
| 71 | + compact |
| 72 | + /> |
| 73 | + </div> |
| 74 | + </div> |
| 75 | + ); |
| 76 | +} |
0 commit comments