Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Less aggressive language selection #417

Merged
merged 7 commits into from
Jan 1, 2024
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
88 changes: 0 additions & 88 deletions components/Atoms/LocalizationChangeDialog.tsx

This file was deleted.

64 changes: 64 additions & 0 deletions components/Atoms/LocalizationChangePopup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { Text, useTheme, PrimaryButton, DefaultButton } from '@fluentui/react';
import { semibold } from '../../services/Fonts';
import { useState, useEffect, useContext, CSSProperties } from 'react';
import { useCookies } from 'react-cookie';
import { addDays } from 'services/Utils';
import GlobalContext from 'services/GlobalContext';

const LocalizationChangePopup = () => {
var theme = useTheme();
const [cookies, setCookie] = useCookies();
const date: Date = addDays(new Date(), 90);

const localizationPopup: CSSProperties = {
zIndex: 2,
position: 'fixed',
width: '100%',
bottom: 0,
gap: 20,
backgroundColor: theme.palette.neutralLight,
borderTop: `1px solid ${theme.palette.neutralQuaternary}`,
padding: '20px 15px',
opacity: '92%'
};

const [isDialogOpen, setIsDialogOpen] = useState<boolean>(false);

const { changeLanguage } = useContext(GlobalContext);

const setEnglishLocale = () => {
changeLanguage("en");
setIsDialogOpen(false);
};

useEffect(() => {
const acceptLanguage = window.navigator.languages[0] ?? navigator.language;

if (cookies.isFirstVisit === undefined && acceptLanguage !== "it") {
setIsDialogOpen(true);
}

setCookie("isFirstVisit", false, { path: "/", expires: date });
}, []);

return (
<>
{ isDialogOpen &&
<div style={localizationPopup}>
<div className="d-flex flex-column justify-content-between" style={{ gap: 15 }}>
<div className="d-flex flex-column" style={{ gap: 5 }}>
<Text variant="large" block styles={semibold}>You don't speak Italian?</Text>
</div>

<div className="d-flex flex-row" style={{ gap: 15 }}>
<DefaultButton onClick={() => setIsDialogOpen(false)} text="Rimani in italiano" style={{ padding: 18 }} />
<PrimaryButton onClick={setEnglishLocale} text="Switch to english" style={{ padding: 18 }} />
</div>
</div>
</div>
}
</>
);
};

export default LocalizationChangePopup;
13 changes: 6 additions & 7 deletions components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const Footer = () => {

return (
<>
{clientRender && <footer style={{ backgroundColor: appTheme.palette.neutralQuaternaryAlt, borderTop: '1px solid', borderColor: appTheme.palette.neutralLight }} className="pt-5 pb-5">
<footer style={{ backgroundColor: appTheme.palette.neutralQuaternaryAlt, borderTop: '1px solid', borderColor: appTheme.palette.neutralLight }} className="pt-5 pb-5">
<Container style={{ width: '100%', color: appTheme.palette.neutralSecondary }}>

<Row className="mb-4">
Expand Down Expand Up @@ -134,7 +134,7 @@ const Footer = () => {
</Col>

<Col xl={3} lg={2} md={3} sm={12} xs={12}>
<div className="mb-2">
{ clientRender && <div className="mb-2">
<Toggle
label={locale?.settingsPanel.changeTheme}
onText={locale?.settingsPanel.darkTheme}
Expand All @@ -143,9 +143,9 @@ const Footer = () => {
onChange={() => changeTheme(theme)}
theme={appTheme}
/>
</div>
</div> }

<div className="mb-2 language-selector">
{ clientRender && <div className="mb-2 language-selector">
<Label>{locale?.settingsPanel.selectLanguage}</Label>
<Text
variant="medium"
Expand All @@ -164,14 +164,14 @@ const Footer = () => {
>
ENG
</Text>
</div>
</div> }
</Col>

<Col xl={3} lg={4} md={6} sm={12} xs={12}>
<div>
<Text variant="medium" styles={semibold}>{locale?.settingsPanel.selectColor}</Text>
</div>
<SwatchColorPicker selectedId={palette} columnCount={7} cellShape={'square'} colorCells={colorCells} onColorChanged={(id) => { changePalette(id!); }} />
{ clientRender && <SwatchColorPicker selectedId={palette} columnCount={7} cellShape={'square'} colorCells={colorCells} onColorChanged={(id) => { changePalette(id!); }} /> }
</Col>

</Row>
Expand Down Expand Up @@ -211,7 +211,6 @@ const Footer = () => {

</Container>
</footer>
}
</>
);
};
Expand Down
30 changes: 22 additions & 8 deletions components/Header/HeaderMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const HeaderMenu = () => {
var theme = useTheme();
const locale = LocalizationService.strings();
const router = useRouter();

const { isPolicyAccepted, togglePolicyDialog } = useContext(GlobalContext);
const [isOpen, { setTrue: openPanel, setFalse: dismissPanel }] = useBoolean(false);

Expand All @@ -43,7 +44,8 @@ const HeaderMenu = () => {
const pivotStyles: Partial<IPivotStyles> = {
root: {
color: theme.palette.neutralPrimary,
fontSize: FontSizes.size24
fontSize: FontSizes.size24,
height: 44
}
};

Expand Down Expand Up @@ -93,7 +95,11 @@ const HeaderMenu = () => {
dismissPanel();
};

const dropdownOptions: IDropdownOption[] = Object.values(ItemsKeys).map(x => ({ key: x, text: texts.get(x)! }));
const getHref = (item: ItemsKeys) => {
return item;
};

const dropdownOptions: Array<IDropdownOption> = Object.values(ItemsKeys).map(x => ({ key: x, text: texts.get(x)! }));

return (
<div className="header-menu">
Expand All @@ -107,7 +113,14 @@ const HeaderMenu = () => {
theme={theme}
overflowBehavior={'menu'}
>
{Object.values(ItemsKeys).map((x, _i) => <PivotItem headerText={texts.get(x)} itemKey={x} key={x} />)}
{Object.values(ItemsKeys).map((x, _i) => (
<PivotItem
headerButtonProps={{ href: x === "home" ? "/" : `/${getHref(x)}` }}
headerText={texts.get(x)}
itemKey={x}
key={x}
/>
) )}
</Pivot>
</div>

Expand Down Expand Up @@ -136,14 +149,15 @@ const HeaderMenu = () => {

<div className="mb-3">
{dropdownOptions.map((x, i) =>
<div
className="menu-item mb-2 pr-4 pl-4 pt-1 pb-2"
onClick={() => handleDropdownValueChange(x)}
<a
href={`/${x.key === "home" ? "" : getHref(x.key as ItemsKeys)}`}
className="d-flex text-decoration-none menu-item mb-2 pr-4 pl-4 pt-1 pb-2"
onClick={(e) => { preventDefault(e); handleDropdownValueChange(x) }}
key={i}
style={{ backgroundColor: (x.key === selectedKey) || (selectedKey as string === "" && x.key === "home") ? theme.palette.neutralLighter : 'none', borderRadius: 25 }}
>
<Text variant="xLarge">{x.text}</Text>
</div>
</a>
)}
</div>

Expand All @@ -155,7 +169,7 @@ const HeaderMenu = () => {

<div className="mb-3">
<div style={cardStyle}>
<Link href={preventVisibleHref(isPolicyAccepted, "https://t.me/unimichat")} onClick={(e) => preventDefault(e, isPolicyAccepted) && togglePolicyDialog()} className="text-decoration-none">
<Link href={preventVisibleHref(isPolicyAccepted, "https://t.me/unimichat")} onClick={(e: any) => preventDefault(e, isPolicyAccepted) && togglePolicyDialog()} className="text-decoration-none">
<Text variant="medium" style={{ color: "#fcfcfc" }}>{locale?.sidebar.mainGroup} <Icon iconName="ChevronRightMed" style={{ fontSize: 10 }} /></Text>
</Link>
</div>
Expand Down
2 changes: 1 addition & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Head from 'next/head';
import Header from "../components/Header/Header";
import Footer from "../components/Footer/Footer";
import PrivacyPolicyDialog from 'components/Atoms/PrivacyPolicyDialog';
import LocalizationChangeDialog from 'components/Atoms/LocalizationChangeDialog';
import LocalizationChangeDialog from 'components/Atoms/LocalizationChangePopup';
import LocalizationService from 'services/LocalizationService';

/**
Expand Down
12 changes: 6 additions & 6 deletions styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ section {
flex-grow: 1;
}

/* Fix the visualization bug on some ugly browsers like Mozilla Night Basalmici Version */
span {
font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif !important;
}

h1,h2,h3,h4,h5,h6 {
margin: 0;
padding: 0;
Expand Down Expand Up @@ -329,6 +324,10 @@ svg {
}
}

.ms-Pivot-overflowMenuButton {
top: -16px; // Fix issue on Fluent UI pivot component with hrefs
}

/* Fix SearchBox visualization for small height displays */
@media only screen and (max-height: 900px) {
#SuggestionContainer .ms-Callout-main {
Expand Down Expand Up @@ -430,6 +429,7 @@ footer .ms-Label {
}
}

/* Chip shimmers */
.chip-shimmer {
position: relative;
overflow: hidden;
Expand Down Expand Up @@ -462,4 +462,4 @@ footer .ms-Label {
rgba(255, 255, 255, 0.2) 40%,
transparent 60%,
transparent 100%);
}
}
Loading