Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/assets/appearance/dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions src/assets/appearance/light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
104 changes: 104 additions & 0 deletions src/assets/appearance/system.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface SectionProps {
onClose: () => void;
}

const Section = ({ className = '', children, title, onBackButtonClicked, onClose }: SectionProps) => {
const PreferencesSection = ({ className = '', children, title, onBackButtonClicked, onClose }: SectionProps) => {
return (
<div className={`relative w-full rounded-tr-2xl ${className}`}>
<div className="absolute z-50 flex w-full items-center justify-between rounded-tr-2xl p-2.5 pl-6 before:absolute before:inset-0 before:-z-1 before:bg-surface/85 before:backdrop-blur-3xl before:transition-colors">
Expand All @@ -25,7 +25,7 @@ const Section = ({ className = '', children, title, onBackButtonClicked, onClose
</div>
<button
className="flex h-9 w-9 items-center justify-center rounded-md hover:bg-highlight/4 active:bg-highlight/8"
onClick={() => onClose()}
onClick={onClose}
>
<XIcon size={22} />
</button>
Expand All @@ -35,4 +35,4 @@ const Section = ({ className = '', children, title, onBackButtonClicked, onClose
);
};

export default Section;
export default PreferencesSection;
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { CaretLeftIcon } from '@phosphor-icons/react';
import { type ReactNode } from 'react';

interface SectionProps {
className?: string;
children: ReactNode;
title: string;
onBackButtonClicked?: () => void;
}

const PreferenceSectionLayout = ({ className = '', children, title, onBackButtonClicked }: Readonly<SectionProps>) => {
return (
<div className={`${className} space-y-2`}>
<div className="flex flex-row space-x-4 ">
{onBackButtonClicked && (
<button onClick={onBackButtonClicked}>
<div className="text-gray-100">
<CaretLeftIcon size={22} />
</div>
</button>
)}
<span className="text-lg font-medium text-gray-100">{title}</span>
</div>
{children}
</div>
);
};

export default PreferenceSectionLayout;
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { useThemeContext } from '@/context/theme/useThemeContext';
import { useTranslationContext } from '@/i18n';
import appearance_dark from '@/assets/appearance/dark.svg';
import appearance_light from '@/assets/appearance/light.svg';
import appearance_system from '@/assets/appearance/system.svg';
import PreferenceSectionLayout from '../PreferenceSectionLayout';
import ThemeButton from './theme-button';
import type { Theme } from '@/context/theme/types';

const themes = [
{ theme: 'system', img: appearance_system },
{ theme: 'light', img: appearance_light },
{ theme: 'dark', img: appearance_dark },
];

const Appearance = () => {
const { translate } = useTranslationContext();
const { currentTheme, toggleTheme } = useThemeContext();

return (
<PreferenceSectionLayout title={translate('modals.preferences.sections.general.appearance.title')}>
<div className="flex flex-col w-full h-max overflow-x-auto">
<div className="flex flex-row w-max h-max pb-2">
{themes.map((themeInfo) => (
<ThemeButton
key={themeInfo.theme}
theme={themeInfo.theme as Theme}
toggleTheme={toggleTheme}
isSelected={currentTheme === themeInfo.theme}
img={themeInfo.img}
/>
))}
</div>
</div>
</PreferenceSectionLayout>
);
};

export default Appearance;
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type { Theme } from '@/context/theme/types';
import { useTranslationContext } from '@/i18n';

interface ThemeButtonProps {
theme: Theme;
toggleTheme: (theme: Theme) => void;
isSelected: boolean;
img: string;
}

const ThemeButton = ({ theme, toggleTheme, isSelected, img }: ThemeButtonProps) => {
const { translate } = useTranslationContext();

return (
<button
className={'mr-4 flex w-36 flex-col space-y-1 rounded-xl'}
onClick={() => {
toggleTheme(theme);
}}
>
<div
className={`box-border overflow-hidden rounded-xl ${
isSelected
? 'border-2 border-primary outline-4 outline-primary/10 drop-shadow'
: 'border-2 border-transparent'
}`}
>
<img src={img} alt={theme} draggable={false} />
</div>

<span className={`text-sm font-medium ${isSelected ? '' : 'text-gray-50'}`}>
{translate(`modals.preferences.sections.general.appearance.${theme}`)}
</span>
</button>
);
};

export default ThemeButton;
15 changes: 10 additions & 5 deletions src/components/preferences/sections/general/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { useTranslationContext } from '@/i18n';
import Section from '../../components/Section';
import PreferencesSection from '../../components/PreferencesSection';
import Appearance from './components/appearance';

const GeneralSection = ({ onClose }: { onClose: () => void }) => {
const { translate } = useTranslationContext();
return (
<Section className="max-w-2xl" title={translate('modals.preferences.sections.general.title')} onClose={onClose}>
{/* TODO: Add appearance, language and support components */}
<p>{translate('modals.preferences.sections.general.title')}</p>
</Section>
<PreferencesSection
className="max-w-2xl"
title={translate('modals.preferences.sections.general.title')}
onClose={onClose}
>
{/* TODO: Add language and support components */}

Check warning on line 13 in src/components/preferences/sections/general/index.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=internxt_mail-web&issues=AZ0kJVhgYHjTwDlmICjR&open=AZ0kJVhgYHjTwDlmICjR&pullRequest=27
<Appearance />
</PreferencesSection>
);
};

Expand Down
Loading
Loading