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

fix: misc fixes from Telegram feedback #84

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f1e1681
style(TopControls): refactor and better mobile support
lorenzocorallo Apr 23, 2023
50c258c
Merge branch 'main' into revision
lorenzocorallo Apr 23, 2023
1fabd26
style(Home): fix DSA-info indent
lorenzocorallo Apr 23, 2023
08f678c
chore(deps): update i18n packages
lorenzocorallo Apr 23, 2023
2131512
feat(i18n): translate save instructions on results page
lorenzocorallo Apr 23, 2023
4343dac
fix(i18n): replace DSA with PSD in en.json
lorenzocorallo Apr 23, 2023
3fec2b5
fix: remove code for previous debug
lorenzocorallo Apr 23, 2023
6aea593
chore: remove unused style
lorenzocorallo Apr 24, 2023
ce32cdd
fix(Header): hide i18n switch during the test
lorenzocorallo Apr 24, 2023
196f91a
fix(i18n): unify related translations using Trans component
lorenzocorallo Apr 24, 2023
b1a90c9
style: adjust icons and page layout of results PDF
lorenzocorallo Apr 24, 2023
4e55b34
fix(deps): update react-to-print to fix a Firefox-related bug
lorenzocorallo Apr 24, 2023
ebab67a
style: add Wrapper to Results page
lorenzocorallo Apr 24, 2023
74aabda
chore(i18n): update it.json
lorenzocorallo Apr 24, 2023
921d7b1
feat(i18n): add screenshots in English for Firefox instructions
lorenzocorallo Apr 24, 2023
0f2cdc6
fix(RecapBar): replace href (causing page reload) with css cursor:poi…
lorenzocorallo Apr 24, 2023
e745d5a
fix(i18n): crop src/static/firefox_3_en.png
lorenzocorallo Apr 24, 2023
ed21b33
style(Button): add cursor pointer
lorenzocorallo Apr 25, 2023
ae65ced
style: fix PDF style on Firefox Android
lorenzocorallo Apr 25, 2023
d00e527
style(Results): fix overflow-x on mobile (caused by score table)
lorenzocorallo Apr 25, 2023
def153e
chore(i18n): add visual hierarchy to results translations
lorenzocorallo Apr 25, 2023
b1e3a04
style(Footer): add max-width
lorenzocorallo Apr 25, 2023
f5034ee
style(Wrapper): remove duplicate margin
lorenzocorallo Apr 25, 2023
d7007be
style(About): restyle using two-col layout
lorenzocorallo Apr 25, 2023
d093c2a
Merge branch 'main' into revision
lorenzocorallo Apr 25, 2023
abc8b39
fix(i18n): fix structure of it.json (based on en.json)
lorenzocorallo Apr 26, 2023
7bced54
chore(i18n): update locales
lorenzocorallo Apr 26, 2023
68665ae
style(Footer): fix overflow
lorenzocorallo Apr 26, 2023
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
46 changes: 26 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"gh-pages": "^3.2.3",
"google-spreadsheet": "^3.1.15",
"googleapis": "^39.2.0",
"i18next": "^22.4.13",
"i18next": "^22.4.15",
"i18next-browser-languagedetector": "^7.0.1",
"mkdirp": "^1.0.4",
"prettier": "^2.4.1",
Expand All @@ -50,7 +50,7 @@
"react-router-dom": "^6.10.0",
"react-scripts": "4.0.3",
"react-timer-hook": "^3.0.5",
"react-to-print": "^2.14.0",
"react-to-print": "^2.14.12",
"rimraf": "^3.0.2",
"ts-node": "^10.3.0",
"ts-prune": "^0.10.1",
Expand Down
17 changes: 9 additions & 8 deletions src/components/ExtendCorrection/ExtendedCorrection.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,29 @@
}

@media print {
@page {
size: A4;
margin: 20mm !important;
}
html,
body {
height: initial !important;
overflow: initial !important;
-webkit-print-color-adjust: exact;
print-color-adjust: exact;
}
}

@media print {
}
.page-break {
margin-top: 1rem;
display: block;
page-break-before: always;
page-break-before: always !important;
}
.print-only {
display: block;
}
.print-only li {
page-break-inside: avoid;
}
div {
break-inside: avoid;
}
Expand All @@ -34,7 +39,3 @@
}
}

@page {
size: auto;
margin: 20mm !important;
}
108 changes: 67 additions & 41 deletions src/components/ExtendCorrection/ExtendedCorrection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ import DocumentHeader from './DocumentHeader'
import firefoxImg1 from '../../static/firefox_1.png'
import firefoxImg2 from '../../static/firefox_2.png'
import firefoxImg3 from '../../static/firefox_3.png'
import firefoxImg2En from '../../static/firefox_2_en.png'
import firefoxImg3En from '../../static/firefox_3_en.png'
import Question from '../Util/Question'
import { Trans, useTranslation } from 'react-i18next'

const IMG_WIDTH = 320
const styles = StyleSheet.create({
collapsible: {
display: 'flex',
flexDirection: 'column',
padding: '15px',
gap: '10px'
},
doc: {},
printButton: {
display: 'inline-flex',
alignItems: 'center',
Expand All @@ -39,23 +41,32 @@ const styles = StyleSheet.create({
textAlign: 'center'
},
li: {
margin: '10px'
margin: '10px',
display: 'block'
},
ul: {
listStyleType: 'none'
},
ol: {
paddingLeft: 20
paddingLeft: 20,
maxWidth: IMG_WIDTH,
margin: '0 auto',
textAlign: 'left',
gap: 10
},
img: {
marginTop: 5,
marginBottom: 10,
maxWidth: 320,
maxWidth: IMG_WIDTH,
width: '100%',
height: 'auto',
objectFit: 'cover'
},
nowrap: { whiteSpace: 'nowrap' }
nowrap: { whiteSpace: 'nowrap' },
printDoc: {
maxWidth: '210mm',
margin: '0 auto'
}
})

// using 'other' as fallback because
Expand Down Expand Up @@ -101,7 +112,7 @@ export default function ExtendedCorrection(props: ExtendedCorrectionProps) {
<ReactToPrint
documentTitle={getTitle()}
content={() => ref.current}
trigger={() => <Button label={t('results.saveBtn')} />}
trigger={() => <Button label={t('results.btn.save')} />}
onAfterPrint={props.onSave}
/>
</div>
Expand Down Expand Up @@ -144,28 +155,33 @@ const PrintDocument = forwardRef<HTMLDivElement, ExtendedCorrectionProps>(
)

return (
<div className="print-only" ref={ref} style={styles.doc}>
<div className="print-only" ref={ref} style={styles.printDoc}>
<div style={docStyles.firstPage}>
<DocumentHeader />
<p style={styles.centered}>
<Trans i18n={i18n} values={{ date: date.date, time: date.time }}>
results.pdfTitle
results.pdf.title
</Trans>
</p>
{resultTable}
<p>
{t('results.pdfInfo1')}
<a
href={links.telegramPreparazioneTOL}
target="_blank"
rel="noreferrer noopener"
style={styles.link}
<Trans
i18n={i18n}
components={{
tg: (
<a
href={links.telegramPreparazioneTOL}
target="_blank"
rel="noreferrer noopener"
style={styles.link}
/>
)
}}
>
{t('results.tgGroup')}
</a>
!
results.pdf.info.1
</Trans>
</p>
<p>{t('results.pdfInfo2')}</p>
<p>{t('results.pdf.info.2')}</p>
</div>
{(Object.entries(questions) as [Section, IQuestion[]][])
.sort((a, b) => sectionInfo[a[0]].order - sectionInfo[b[0]].order)
Expand Down Expand Up @@ -193,44 +209,54 @@ const PrintDocument = forwardRef<HTMLDivElement, ExtendedCorrectionProps>(
PrintDocument.displayName = 'Document'

function FirefoxInstructions() {
const { t, i18n } = useTranslation()
return (
<div className="do-not-print">
<h3>Salva i tuoi risultati</h3>
<p>Il tuo browser (Firefox Android) non supporta la stampa automatica.</p>
<p>Per salvare i risultati segui questi passaggi: </p>
<h3>{t('results.save.title')}</h3>
<p>{t('results.save.firefox.body.1')}</p>
<p>{t('results.save.firefox.body.2')}</p>
<ol style={styles.ol}>
<li>Apri il menu di Firefox</li>
<li>{t('results.save.firefox.li.1')}</li>
<img src={firefoxImg1} style={styles.img} />

<li>Premi il tasto per condividere</li>
<img src={firefoxImg2} style={styles.img} />
<li>{t('results.save.firefox.li.2')}</li>
<img
src={i18n.language.startsWith('en') ? firefoxImg2En : firefoxImg2}
style={styles.img}
/>

<li>Nel menu che si apre, premi su "Salva come PDF"</li>
<img src={firefoxImg3} style={styles.img} />
<li>{t('results.save.firefox.li.3')}</li>
<img
src={i18n.language.startsWith('en') ? firefoxImg3En : firefoxImg3}
style={styles.img}
/>
</ol>
</div>
)
}

function FallbackInstructions() {
const { t, i18n } = useTranslation()
return (
<div className="do-not-print">
<h3>Salva i tuoi risultati</h3>
<p>
Per il tuo browser non è supportata la stampa automatica del PDF con i
risultati.
</p>
<p>
Puoi provare ad utilizzare la funzione "Sala come PDF" del tuo browser
che potrebbe essere nel menu di condivisione oppure nel menu principale
del browser.
</p>
<h3>{t('results.save.title')}</h3>
<p>{t('results.save.fallback.1')}</p>
<p>{t('results.save.fallback.2')}</p>
<p>
Ti invitiamo a segnalare il tuo browser{' '}
<a href="https://github.com/PoliNetworkOrg/TheTOLProject/issues/35">
qui
</a>{' '}
in modo da poter risolvere il problema{' '}
<Trans
i18n={i18n}
components={{
issue: (
<a
href="https://github.com/PoliNetworkOrg/TheTOLProject/issues/35"
rel="noreferrer noopener"
target="_blank"
/>
)
}}
>
results.save.fallback.3
</Trans>
</p>
</div>
)
Expand Down
7 changes: 4 additions & 3 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ const styles = StyleSheet.create({
container: {
display: 'flex',
justifyContent: 'space-between',
paddingInline: '15em',
margin: '15px',
margin: '15px auto',
fontSize: '10pt',
color: theme.softBlack
color: theme.softBlack,
width: '100%',
maxWidth: 900
},
link: {
display: 'flex',
Expand Down
Loading