-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: firefox extension permission ui (#3864)
- Loading branch information
Showing
11 changed files
with
287 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
packages/extension/src/permission/FirefoxPermission.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import React, { ReactElement } from 'react'; | ||
import DailyDevLogo from '@dailydotdev/shared/src/components/Logo'; | ||
import { | ||
Typography, | ||
TypographyColor, | ||
TypographyTag, | ||
TypographyType, | ||
} from '@dailydotdev/shared/src/components/typography/Typography'; | ||
import { | ||
Button, | ||
ButtonVariant, | ||
} from '@dailydotdev/shared/src/components/buttons/Button'; | ||
import { VIcon } from '@dailydotdev/shared/src/components/icons'; | ||
import { cloudinaryFeedBgLaptop } from '@dailydotdev/shared/src/lib/image'; | ||
import { | ||
onboardingUrl, | ||
privacyPolicy, | ||
} from '@dailydotdev/shared/src/lib/constants'; | ||
import { useRouter } from 'next/router'; | ||
import { FirefoxPermissionType } from '@dailydotdev/shared/src/lib/cookie'; | ||
import { anchorDefaultRel } from '@dailydotdev/shared/src/lib/strings'; | ||
import { FirefoxPermissionItem } from './FirefoxPermissionItem'; | ||
import { FirefoxPermissionContainer } from './common'; | ||
|
||
interface FirefoxPermissionProps { | ||
onUpdate(permission: FirefoxPermissionType): Promise<void>; | ||
} | ||
|
||
export function FirefoxPermission({ | ||
onUpdate, | ||
}: FirefoxPermissionProps): ReactElement { | ||
const router = useRouter(); | ||
|
||
const onAccept = async () => { | ||
await onUpdate(FirefoxPermissionType.Accepted); | ||
await router.push(onboardingUrl); | ||
}; | ||
|
||
return ( | ||
<FirefoxPermissionContainer> | ||
<img | ||
src={cloudinaryFeedBgLaptop} | ||
alt="a glowing background" | ||
className="pointer-events-none absolute -top-10 -z-1 select-none" | ||
/> | ||
<span className="absolute top-0 py-6"> | ||
<DailyDevLogo /> | ||
</span> | ||
<div className="flex w-full max-w-[33rem] flex-col gap-2 rounded-10 bg-surface-float p-4"> | ||
<Typography tag={TypographyTag.H1} type={TypographyType.Title3} bold> | ||
Additional permissions needed | ||
</Typography> | ||
<Typography | ||
type={TypographyType.Callout} | ||
color={TypographyColor.Tertiary} | ||
> | ||
Ready to go? 🟢 Give us the green signal by accepting the permissions | ||
below. Enhance your daily.dev experience with personalized content and | ||
connect with fellow developers. | ||
</Typography> | ||
<FirefoxPermissionItem | ||
className="mt-2" | ||
title="Ads pixel tracking" | ||
description="Enable pixel tracking for fewer, non-intrusive ads, helping us in keeping the experience free and relevant." | ||
icon="📢" | ||
/> | ||
<FirefoxPermissionItem | ||
title="Analytics data" | ||
description="Allow us to capture analytics data to understand your preferences and personalize content for you." | ||
icon="📊" | ||
/> | ||
<Typography | ||
tag={TypographyTag.Link} | ||
className="my-4 text-center" | ||
color={TypographyColor.Link} | ||
type={TypographyType.Subhead} | ||
href={privacyPolicy} | ||
target="_blank" | ||
rel={anchorDefaultRel} | ||
> | ||
Full permission document | ||
</Typography> | ||
<Button | ||
className="w-full" | ||
icon={<VIcon />} | ||
variant={ButtonVariant.Primary} | ||
onClick={onAccept} | ||
> | ||
Accept | ||
</Button> | ||
<Button | ||
className="mt-1 w-full" | ||
variant={ButtonVariant.Float} | ||
onClick={() => onUpdate(FirefoxPermissionType.Declined)} | ||
> | ||
Decline | ||
</Button> | ||
</div> | ||
</FirefoxPermissionContainer> | ||
); | ||
} |
70 changes: 70 additions & 0 deletions
70
packages/extension/src/permission/FirefoxPermissionDeclined.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React, { ReactElement } from 'react'; | ||
import { | ||
cloudinaryFeedBgLaptop, | ||
cloudinaryGenericErrorDark, | ||
} from '@dailydotdev/shared/src/lib/image'; | ||
import { | ||
Typography, | ||
TypographyColor, | ||
TypographyTag, | ||
TypographyType, | ||
} from '@dailydotdev/shared/src/components/typography/Typography'; | ||
import { webappUrl } from '@dailydotdev/shared/src/lib/constants'; | ||
import { anchorDefaultRel } from '@dailydotdev/shared/src/lib/strings'; | ||
import { FirefoxPermissionContainer } from './common'; | ||
|
||
interface FirefoxPermissionDeclinedProps { | ||
onGoBack(): void; | ||
} | ||
|
||
export function FirefoxPermissionDeclined({ | ||
onGoBack, | ||
}: FirefoxPermissionDeclinedProps): ReactElement { | ||
return ( | ||
<FirefoxPermissionContainer> | ||
<img | ||
src={cloudinaryFeedBgLaptop} | ||
alt="a glowing background" | ||
className="pointer-events-none absolute -top-10 -z-1 select-none" | ||
/> | ||
<div className="flex w-full max-w-[35rem] flex-col items-center gap-4"> | ||
<span className="h-36 max-w-[16.25rem]"> | ||
<img src={cloudinaryGenericErrorDark} alt="You declined (FML)" /> | ||
</span> | ||
<Typography | ||
tag={TypographyTag.H1} | ||
type={TypographyType.LargeTitle} | ||
bold | ||
> | ||
You declined. | ||
</Typography> | ||
<Typography | ||
color={TypographyColor.Secondary} | ||
tag={TypographyTag.H1} | ||
type={TypographyType.Body} | ||
className="text-center" | ||
> | ||
We understand your choice, but just so you know, we’ll need those | ||
permissions to deliver any content. Without them, it’s like trying to | ||
code without a keyboard! | ||
</Typography> | ||
<Typography | ||
color={TypographyColor.Secondary} | ||
tag={TypographyTag.H1} | ||
type={TypographyType.Body} | ||
className="text-center" | ||
> | ||
You can{' '} | ||
<button type="button" className="text-text-link" onClick={onGoBack}> | ||
go back | ||
</button>{' '} | ||
and accept the required permissions or use our{' '} | ||
<a className="text-text-link" href={webappUrl} rel={anchorDefaultRel}> | ||
web app | ||
</a>{' '} | ||
instead. | ||
</Typography> | ||
</div> | ||
</FirefoxPermissionContainer> | ||
); | ||
} |
48 changes: 48 additions & 0 deletions
48
packages/extension/src/permission/FirefoxPermissionItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, { ReactElement, ReactNode } from 'react'; | ||
import classNames from 'classnames'; | ||
import { | ||
Typography, | ||
TypographyColor, | ||
TypographyTag, | ||
TypographyType, | ||
} from '@dailydotdev/shared/src/components/typography/Typography'; | ||
|
||
interface FirefoxPermissionItemProps { | ||
title: string; | ||
description: string; | ||
icon: ReactNode; | ||
className?: string; | ||
} | ||
|
||
export function FirefoxPermissionItem({ | ||
title, | ||
description, | ||
icon, | ||
className, | ||
}: FirefoxPermissionItemProps): ReactElement { | ||
return ( | ||
<div | ||
className={classNames( | ||
'flex flex-row gap-3 border-b border-border-subtlest-tertiary px-4 py-2', | ||
className, | ||
)} | ||
> | ||
<Typography type={TypographyType.LargeTitle}>{icon}</Typography> | ||
<div className="flex flex-1 flex-col gap-2 break-words"> | ||
<Typography | ||
tag={TypographyTag.H3} | ||
type={TypographyType.Callout} | ||
color={TypographyColor.Secondary} | ||
> | ||
{title} | ||
</Typography> | ||
<Typography | ||
type={TypographyType.Subhead} | ||
color={TypographyColor.Tertiary} | ||
> | ||
{description} | ||
</Typography> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import classed from '@dailydotdev/shared/src/lib/classed'; | ||
|
||
export const FirefoxPermissionContainer = classed( | ||
'div', | ||
'fixed inset-0 flex h-screen w-screen flex-1 flex-col justify-center items-center', | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.