Skip to content

Commit

Permalink
Merge branch 'MI-746-gifting-plus' into fix-gift-feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
sshanzel authored Feb 7, 2025
2 parents 5a6d438 + 0964d51 commit 09ef44b
Show file tree
Hide file tree
Showing 69 changed files with 1,564 additions and 386 deletions.
2 changes: 1 addition & 1 deletion packages/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "extension",
"version": "3.36.11",
"version": "3.36.12",
"scripts": {
"dev:chrome": "cross-env NODE_ENV=development cross-env TARGET_BROWSER=chrome webpack --watch",
"dev:firefox": "cross-env NODE_ENV=development cross-env TARGET_BROWSER=firefox webpack --watch",
Expand Down
5 changes: 0 additions & 5 deletions packages/shared/src/components/auth/RegistrationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import ConditionalWrapper from '../ConditionalWrapper';
import AuthContainer from './AuthContainer';
import { onValidateHandles } from '../../hooks/useProfileForm';
import ExperienceLevelDropdown from '../profile/ExperienceLevelDropdown';
import { LanguageDropdown } from '../profile/LanguageDropdown';
import Alert, { AlertType } from '../widgets/Alert';
import { isDevelopment } from '../../lib/constants';

Expand Down Expand Up @@ -296,10 +295,6 @@ const RegistrationForm = ({
}
saveHintSpace
/>
<LanguageDropdown
className={{ container: 'w-full' }}
name="traits.language"
/>
<span className="border-b border-border-subtlest-tertiary pb-4 text-text-secondary typo-subhead">
Your email will be used to send you product and community updates
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import ConditionalWrapper from '../ConditionalWrapper';
import type { SignBackProvider } from '../../hooks/auth/useSignBack';
import { useSignBack } from '../../hooks/auth/useSignBack';
import ExperienceLevelDropdown from '../profile/ExperienceLevelDropdown';
import { LanguageDropdown } from '../profile/LanguageDropdown';

export interface SocialRegistrationFormProps extends AuthFormProps {
className?: string;
Expand Down Expand Up @@ -258,7 +257,6 @@ export const SocialRegistrationForm = ({
hint={experienceLevelHint}
saveHintSpace
/>
<LanguageDropdown className={{ container: 'w-full' }} name="language" />
<span className="border-b border-border-subtlest-tertiary pb-4 text-text-secondary typo-subhead">
Your email will be used to send you product and community updates
</span>
Expand Down
12 changes: 10 additions & 2 deletions packages/shared/src/components/buttons/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,16 @@ export const useGetIconWithSize = (
className: classNames(
icon.props.className,
!iconOnly && 'text-base',
!iconOnly && iconPosition === ButtonIconPosition.Left && '-ml-2 mr-1',
!iconOnly && iconPosition === ButtonIconPosition.Right && '-mr-2 ml-1',
!iconOnly && iconPosition === ButtonIconPosition.Left && 'mr-1',
!iconOnly &&
!icon.props?.size &&
iconPosition === ButtonIconPosition.Left &&
'-ml-2',
!iconOnly && iconPosition === ButtonIconPosition.Right && 'ml-1',
!iconOnly &&
!icon.props?.size &&
iconPosition === ButtonIconPosition.Right &&
'-mr-2',
),
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ export default function ShowMoreContent({

return (
<div className={className}>
<p className="select-text break-words typo-body">
<p
className="select-text break-words typo-body"
data-testid="tldr-container"
>
{contentPrefix}
{getContent()}{' '}
{displayShowMoreLink() && (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import React from 'react';
import type { ReactElement } from 'react';
import {
Typography,
TypographyColor,
TypographyTag,
TypographyType,
} from '../../../typography/Typography';
import { PlusUser } from '../../../PlusUser';
import { LogEvent, Origin, TargetId } from '../../../../lib/log';
import { Button, ButtonSize, ButtonVariant } from '../../../buttons/Button';
import { plusUrl } from '../../../../lib/constants';
import { DevPlusIcon } from '../../../icons';
import { usePlusSubscription, useToastNotification } from '../../../../hooks';
import { usePromptsQuery } from '../../../../hooks/prompt/usePromptsQuery';
import { FilterCheckbox } from '../../../fields/FilterCheckbox';
import { useSettingsContext } from '../../../../contexts/SettingsContext';
import { labels } from '../../../../lib';
import { useLogContext } from '../../../../contexts/LogContext';
import { useFeedSettingsEditContext } from '../FeedSettingsEditContext';
import { SimpleTooltip } from '../../../tooltips';
import ConditionalWrapper from '../../../ConditionalWrapper';

export const SmartPrompts = (): ReactElement => {
const { editFeedSettings } = useFeedSettingsEditContext();
const { isPlus, logSubscriptionEvent } = usePlusSubscription();
const { displayToast } = useToastNotification();
const { logEvent } = useLogContext();
const { flags, updatePromptFlag } = useSettingsContext();
const { prompt: promptFlags } = flags;
const { data: prompts, isLoading } = usePromptsQuery();

return (
<section className="flex flex-col gap-4" aria-busy={isLoading}>
<div className="flex flex-col">
<div className="mb-1 flex items-center gap-2">
<Typography
tag={TypographyTag.H3}
color={TypographyColor.Primary}
type={TypographyType.Body}
bold
>
Smart Prompts
</Typography>
<PlusUser />
</div>
<Typography
className="pr-24"
color={TypographyColor.Tertiary}
type={TypographyType.Callout}
>
Level up how you interact with posts using AI-powered prompts. Extract
insights, refine content, or run custom instructions to get more out
of every post in one click.
</Typography>
</div>

<div className="flex flex-col gap-2">
{prompts?.map(({ id, label, description }) => (
<ConditionalWrapper
condition={!isPlus}
key={`w-${id}`}
wrapper={(child) => {
return (
<SimpleTooltip
container={{
className: 'max-w-70 text-center typo-subhead',
}}
content="Upgrade to Plus to unlock Smart Prompts."
>
<div className="w-fit">{child as ReactElement}</div>
</SimpleTooltip>
);
}}
>
<FilterCheckbox
key={id}
name={`prompt-${id}`}
checked={promptFlags?.[id] ?? true}
description={description}
disabled={!isPlus}
onToggleCallback={() => {
const newState = !promptFlags?.[id] || false;
editFeedSettings(() => updatePromptFlag(id, newState));
displayToast(
labels.feed.settings.globalPreferenceNotice.smartPrompt,
);

logEvent({
event_name: LogEvent.ToggleSmartPrompts,
target_type: id,
target_id: newState ? TargetId.On : TargetId.Off,
extra: JSON.stringify({
origin: Origin.Settings,
}),
});
}}
descriptionClassName="text-text-tertiary"
>
<Typography bold>{label}</Typography>
</FilterCheckbox>
</ConditionalWrapper>
))}
</div>
{!isPlus && (
<Button
className="w-fit"
tag="a"
type="button"
variant={ButtonVariant.Primary}
size={ButtonSize.Medium}
href={plusUrl}
icon={<DevPlusIcon className="text-action-plus-default" />}
onClick={() => {
logSubscriptionEvent({
event_name: LogEvent.UpgradeSubscription,
target_id: TargetId.ClickbaitShield,
});
}}
>
Upgrade to Plus
</Button>
)}
</section>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import { Divider } from '../../../utilities';
import { Switch } from '../../../fields/Switch';
import { labels } from '../../../../lib';
import { SmartPrompts } from '../components/SmartPrompts';

export const FeedSettingsAISection = (): ReactElement => {
const { isPlus, logSubscriptionEvent } = usePlusSubscription();
Expand All @@ -38,6 +39,39 @@ export const FeedSettingsAISection = (): ReactElement => {

return (
<>
<section className="flex flex-col gap-4" aria-busy={isLoading}>
<div className="flex flex-col">
<Typography
tag={TypographyTag.H3}
color={TypographyColor.Primary}
type={TypographyType.Body}
bold
className="mb-1"
>
Preferred language
</Typography>
<Typography
color={TypographyColor.Tertiary}
type={TypographyType.Callout}
>
Choose your preferred language for the post titles on the feed
</Typography>
</div>
<LanguageDropdown
className={{ container: 'w-full max-w-60' }}
name="language"
defaultValue={user.language}
onChange={(value) => {
onLanguageChange(value);

displayToast(
labels.feed.settings.globalPreferenceNotice.contentLanguage,
);
}}
icon={null}
/>
</section>
<Divider className="bg-border-subtlest-tertiary" />
<section className="flex flex-col gap-4" aria-busy={isLoading}>
<div className="flex flex-col">
<div className="mb-1 flex items-center gap-2">
Expand Down Expand Up @@ -127,38 +161,7 @@ export const FeedSettingsAISection = (): ReactElement => {
)}
</section>
<Divider className="bg-border-subtlest-tertiary" />
<section className="flex flex-col gap-4" aria-busy={isLoading}>
<div className="flex flex-col">
<Typography
tag={TypographyTag.H3}
color={TypographyColor.Primary}
type={TypographyType.Body}
bold
className="mb-1"
>
Preferred language
</Typography>
<Typography
color={TypographyColor.Tertiary}
type={TypographyType.Callout}
>
Choose your preferred language for the post titles on the feed
</Typography>
</div>
<LanguageDropdown
className={{ container: 'w-full max-w-60' }}
name="language"
defaultValue={user.language}
onChange={(value) => {
onLanguageChange(value);

displayToast(
labels.feed.settings.globalPreferenceNotice.contentLanguage,
);
}}
icon={null}
/>
</section>
<SmartPrompts />
</>
);
};
10 changes: 10 additions & 0 deletions packages/shared/src/components/icons/CustomPrompt/filled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions packages/shared/src/components/icons/CustomPrompt/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { ReactElement } from 'react';
import React from 'react';
import type { IconProps } from '../../Icon';
import Icon from '../../Icon';
import OutlinedIcon from './outlined.svg';
import FilledIcon from './filled.svg';

export const CustomPromptIcon = (props: IconProps): ReactElement => (
<Icon {...props} IconPrimary={OutlinedIcon} IconSecondary={FilledIcon} />
);
10 changes: 10 additions & 0 deletions packages/shared/src/components/icons/CustomPrompt/outlined.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions packages/shared/src/components/icons/EditPrompt/filled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions packages/shared/src/components/icons/EditPrompt/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { ReactElement } from 'react';
import React from 'react';
import type { IconProps } from '../../Icon';
import Icon from '../../Icon';
import OutlinedIcon from './outlined.svg';
import FilledIcon from './filled.svg';

export const EditPromptIcon = (props: IconProps): ReactElement => (
<Icon {...props} IconPrimary={OutlinedIcon} IconSecondary={FilledIcon} />
);
4 changes: 4 additions & 0 deletions packages/shared/src/components/icons/EditPrompt/outlined.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 09ef44b

Please sign in to comment.