Skip to content

Commit

Permalink
chore(settings): add list of mandatory experiences (#87)
Browse files Browse the repository at this point in the history
* chore(settings): add list of mandatory experiences

* chore(docs): update goals
  • Loading branch information
onetdev authored Nov 1, 2024
1 parent 8468fa5 commit 1e90eea
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 115 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"class",
"cx",
"iteratorClassName",
"listClassName",
"localStyles.*"
],
"yaml.schemas": {
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ The main idea is to gather the most annoying features of modern websites in one
- [ ] Add holiday related (Halloween, Christmass, Easter) small animated images that follow the mouse cursor
- [ ] Push elements to navigation stack so that when the user tries to navigate back it will stay on the page
- [ ] Fake advertisements (won free phone)
- [ ] Add disabled experience toggle for Auth related pages
</details>

<details>
<summary>Completed</summary>

- [x] Add disabled mandatory experience checkboxes to settings
- [x] DILF advertisement and landing page
- [x] Sticky video player that obscures page visibility
- [x] Newsletter modal that appears when the user leaves the screen or scrolls down a bit
- [x] Fake search page that:
Expand Down
13 changes: 10 additions & 3 deletions public/locales/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,29 @@
"locationPermission": "Location permission"
},
"experienceFlags": {
"title": "Optional experience",
"gifts": {
"flaps": "Background ad flaps",
"oneByOne": "One by one ad blocks"
},
"title": "Experience",
"contentPaywall": "Content paywall",
"deadPixel": "Dead pixel",
"exitPrompt": "Exit prompt",
"mockChat": "Mock chat",
"newsletterModal": "Newsletter modal",
"mockChat": "Bubble chat",
"newsletterModal": "Newsletter popup modal",
"notifications": "Notifications",
"pageTitleInactiveArrayPaged": "Alternative title when tab is inactive",
"searchDelay": "Fake search delay",
"wheelOfFortune": "Wheel of fortune",
"stickyVideo": "Sticky video"
},
"mandatoryExperienceFlags": {
"title": "Mandatory experience",
"impossibleLogin": "Impossible login",
"impossibleRegistration": "Impossible registration",
"impossiblePasswordReminder": "Impossible password reminder",
"unreasonableContent": "Unreasonable content"
},
"runtime": {
"title": "About this session",
"disclaimer": "These values reset every single visit and acts as a bit of debug info.",
Expand Down
210 changes: 112 additions & 98 deletions src/features/settings/components/ExperienceSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,111 +8,125 @@ import Button from '@/components/atoms/Button';
import FormCheckbox from '@/components/atoms/Checkbox';
import { useExperienceFlagsStore } from '@/state/experience_flags';

const ExperienceSettings: FunctionComponent = () => {
type ExperienceSettingsProps = {
className?: string;
listClassName?: string;
};

const ExperienceSettings: FunctionComponent<ExperienceSettingsProps> = ({
className = '',
listClassName = '',
}) => {
const experience = useExperienceFlagsStore();
const { t } = useTranslation(['settings', 'common']);

const onPageTitleInactiveArrayPagedChange = (value: boolean) =>
experience.setPageTitle({ inactiveArrayPaged: value });

return (
<SettingsBlock title={t('settings:section.experienceFlags.title')}>
<SettingsBlockRow
label={t('settings:section.experienceFlags.gifts.flaps')}>
<FormCheckbox
name="gift_flaps"
checked={experience.gifts.flaps}
onValueChange={(flaps) => experience.setGifts({ flaps })}
/>
</SettingsBlockRow>
<SettingsBlockRow
label={t('settings:section.experienceFlags.gifts.oneByOne')}>
<FormCheckbox
name="gift_flaps"
checked={experience.gifts.oneByOne}
onValueChange={(oneByOne) => experience.setGifts({ oneByOne })}
/>
</SettingsBlockRow>
<SettingsBlockRow
label={t('settings:section.experienceFlags.contentPaywall')}>
<FormCheckbox
name="content_paywall"
checked={experience.contentPaywall}
onValueChange={experience.setContentPaywall}
/>
</SettingsBlockRow>
<SettingsBlockRow label={t('settings:section.experienceFlags.deadPixel')}>
<FormCheckbox
name="dead_pixel"
checked={experience.deadPixel}
onValueChange={experience.setDeadPixel}
/>
</SettingsBlockRow>
<SettingsBlockRow
label={t('settings:section.experienceFlags.exitPrompt')}>
<FormCheckbox
name="exit_prompt"
checked={experience.exitPrompt}
onValueChange={experience.setExitPrompt}
/>
</SettingsBlockRow>
<SettingsBlockRow label={t('settings:section.experienceFlags.mockChat')}>
<FormCheckbox
name="mock_chat"
checked={experience.mockChat}
onValueChange={experience.setMockChat}
/>
</SettingsBlockRow>
<SettingsBlockRow
label={t('settings:section.experienceFlags.newsletterModal')}>
<FormCheckbox
name="newsletter"
checked={experience.newsletterModal}
onValueChange={experience.setNewsletterModal}
/>
</SettingsBlockRow>
<SettingsBlockRow
label={t('settings:section.experienceFlags.notifications')}>
<FormCheckbox
name="notifications"
checked={experience.notifications}
onValueChange={experience.setNotifications}
/>
</SettingsBlockRow>
<SettingsBlockRow
label={t(
'settings:section.experienceFlags.pageTitleInactiveArrayPaged',
)}>
<FormCheckbox
name="page_title_inactive_array_paged"
checked={experience.pageTitle.inactiveArrayPaged}
onValueChange={onPageTitleInactiveArrayPagedChange}
/>
</SettingsBlockRow>
<SettingsBlockRow
label={t('settings:section.experienceFlags.searchDelay')}>
<FormCheckbox
name="search_delay"
checked={experience.searchDelay}
onValueChange={experience.setSearchDelay}
/>
</SettingsBlockRow>
<SettingsBlockRow
label={t('settings:section.experienceFlags.stickyVideo')}>
<FormCheckbox
name="sticky_video"
checked={experience.stickyVideo}
onValueChange={experience.setStickyVideo}
/>
</SettingsBlockRow>
<SettingsBlockRow
label={t('settings:section.experienceFlags.wheelOfFortune')}>
<FormCheckbox
name="wheel_of_fortune"
checked={experience.wheelOfFortune}
onValueChange={experience.setWheelOfFortune}
/>
</SettingsBlockRow>
<SettingsBlock
title={t('settings:section.experienceFlags.title')}
className={className}>
<div className={listClassName}>
<SettingsBlockRow
label={t('settings:section.experienceFlags.gifts.flaps')}>
<FormCheckbox
name="gift_flaps"
checked={experience.gifts.flaps}
onValueChange={(flaps) => experience.setGifts({ flaps })}
/>
</SettingsBlockRow>
<SettingsBlockRow
label={t('settings:section.experienceFlags.gifts.oneByOne')}>
<FormCheckbox
name="gift_flaps"
checked={experience.gifts.oneByOne}
onValueChange={(oneByOne) => experience.setGifts({ oneByOne })}
/>
</SettingsBlockRow>
<SettingsBlockRow
label={t('settings:section.experienceFlags.contentPaywall')}>
<FormCheckbox
name="content_paywall"
checked={experience.contentPaywall}
onValueChange={experience.setContentPaywall}
/>
</SettingsBlockRow>
<SettingsBlockRow
label={t('settings:section.experienceFlags.deadPixel')}>
<FormCheckbox
name="dead_pixel"
checked={experience.deadPixel}
onValueChange={experience.setDeadPixel}
/>
</SettingsBlockRow>
<SettingsBlockRow
label={t('settings:section.experienceFlags.exitPrompt')}>
<FormCheckbox
name="exit_prompt"
checked={experience.exitPrompt}
onValueChange={experience.setExitPrompt}
/>
</SettingsBlockRow>
<SettingsBlockRow
label={t('settings:section.experienceFlags.mockChat')}>
<FormCheckbox
name="mock_chat"
checked={experience.mockChat}
onValueChange={experience.setMockChat}
/>
</SettingsBlockRow>
<SettingsBlockRow
label={t('settings:section.experienceFlags.newsletterModal')}>
<FormCheckbox
name="newsletter"
checked={experience.newsletterModal}
onValueChange={experience.setNewsletterModal}
/>
</SettingsBlockRow>
<SettingsBlockRow
label={t('settings:section.experienceFlags.notifications')}>
<FormCheckbox
name="notifications"
checked={experience.notifications}
onValueChange={experience.setNotifications}
/>
</SettingsBlockRow>
<SettingsBlockRow
label={t(
'settings:section.experienceFlags.pageTitleInactiveArrayPaged',
)}>
<FormCheckbox
name="page_title_inactive_array_paged"
checked={experience.pageTitle.inactiveArrayPaged}
onValueChange={onPageTitleInactiveArrayPagedChange}
/>
</SettingsBlockRow>
<SettingsBlockRow
label={t('settings:section.experienceFlags.searchDelay')}>
<FormCheckbox
name="search_delay"
checked={experience.searchDelay}
onValueChange={experience.setSearchDelay}
/>
</SettingsBlockRow>
<SettingsBlockRow
label={t('settings:section.experienceFlags.stickyVideo')}>
<FormCheckbox
name="sticky_video"
checked={experience.stickyVideo}
onValueChange={experience.setStickyVideo}
/>
</SettingsBlockRow>
<SettingsBlockRow
label={t('settings:section.experienceFlags.wheelOfFortune')}>
<FormCheckbox
name="wheel_of_fortune"
checked={experience.wheelOfFortune}
onValueChange={experience.setWheelOfFortune}
/>
</SettingsBlockRow>
</div>
<div className="flex gap-3">
<Button
className="mt-6"
Expand Down
43 changes: 43 additions & 0 deletions src/features/settings/components/MandatoryExperienceSettings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { useTranslation } from 'next-i18next';
import { FunctionComponent } from 'react';

import SettingsBlock from './SettingsBlock';
import SettingsBlockRow from './SettingsBlockRow';

import FormCheckbox from '@/components/atoms/Checkbox';

const MandatoryExperienceSettings: FunctionComponent = () => {
const { t } = useTranslation(['settings', 'common']);
return (
<SettingsBlock title={t('settings:section.mandatoryExperienceFlags.title')}>
<SettingsBlockRow
label={t(
'settings:section.mandatoryExperienceFlags.unreasonableContent',
)}>
<FormCheckbox name="unreasonable_content" checked={true} disabled />
</SettingsBlockRow>
<SettingsBlockRow
label={t('settings:section.mandatoryExperienceFlags.impossibleLogin')}>
<FormCheckbox name="impossible_login" checked={true} disabled />
</SettingsBlockRow>
<SettingsBlockRow
label={t(
'settings:section.mandatoryExperienceFlags.impossibleRegistration',
)}>
<FormCheckbox name="impossible_registration" checked={true} disabled />
</SettingsBlockRow>
<SettingsBlockRow
label={t(
'settings:section.mandatoryExperienceFlags.impossiblePasswordReminder',
)}>
<FormCheckbox
name="impossible_password_reminder"
checked={true}
disabled
/>
</SettingsBlockRow>
</SettingsBlock>
);
};

export default MandatoryExperienceSettings;
16 changes: 12 additions & 4 deletions src/features/settings/components/SettingsBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import { FunctionComponent, PropsWithChildren } from 'react';

const SettingsBlock: FunctionComponent<
PropsWithChildren<{ title: string }>
> = ({ title, children }) => {
export type SettingsBlockProps = PropsWithChildren<{
className?: string;
title: string;
}>;

const SettingsBlock: FunctionComponent<SettingsBlockProps> = ({
children,
className = '',
title,
}) => {
return (
<div className="rounded-md border border-on-surface bg-surface-alt p-5">
<div
className={`rounded-md border border-on-surface bg-surface-alt p-5 ${className}`}>
<h2 className="m-0 mb-5">{title}</h2>
<div className="flex flex-col gap-1">{children}</div>
</div>
Expand Down
19 changes: 14 additions & 5 deletions src/features/settings/components/SettingsBlockRow.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
import { FunctionComponent, PropsWithChildren } from 'react';

const SettingsBlockRow: FunctionComponent<
PropsWithChildren<{ label: string }>
> = ({ label, children }) => {
export type SettingsBlockRowProps = PropsWithChildren<{
label: string;
reverse?: boolean;
}>;

const SettingsBlockRow: FunctionComponent<SettingsBlockRowProps> = ({
label,
children,
reverse = false,
}) => {
return (
<div>
<label className="flex items-center justify-between">
<span>{label}</span>
<label
data-reverse={reverse.toString()}
className="flex items-center gap-3 data-[reverse=true]:flex-row-reverse data-[reverse=true]:justify-between">
{children}
<span>{label}</span>
</label>
</div>
);
Expand Down
6 changes: 4 additions & 2 deletions src/features/settings/components/UserGrantsSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ const UserGrantsSettings: FunctionComponent = () => {
</small>
<br />
<SettingsBlockRow
label={t('settings:section.userGrants.notificationPermission')}>
label={t('settings:section.userGrants.notificationPermission')}
reverse>
{`${grant.permission.notification || t('common:status.notSet')}`}
</SettingsBlockRow>
<SettingsBlockRow
label={t('settings:section.userGrants.locationPermission')}>
label={t('settings:section.userGrants.locationPermission')}
reverse>
{`${grant.permission.location || t('common:status.notSet')}`}
</SettingsBlockRow>
</SettingsBlock>
Expand Down
3 changes: 2 additions & 1 deletion src/features/settings/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { default as ExperienceSettings } from './components/ExperienceSettings';
export { default as UserGrantsSettings } from './components/UserGrantsSettings';
export { default as PreferencesSettings } from './components/PreferencesSettings';
export { default as RuntimeSettings } from './components/RuntimeSettings';
export { default as UserGrantsSettings } from './components/UserGrantsSettings';
export { default as MandatoryExperienceSettings } from './components/MandatoryExperienceSettings';
Loading

0 comments on commit 1e90eea

Please sign in to comment.