TagSpaces is an offline, open source, document manager with tagging support
chore: refactoring the PRO teaser
Ilian Sapundshievf9827eaf59bf
diff --git a/src/renderer/components/ProTeaser.tsx b/src/renderer/components/ProTeaser.tsxindex 33a7f1bbd..91b548f58 100644--- a/src/renderer/components/ProTeaser.tsx+++ b/src/renderer/components/ProTeaser.tsx@@ -21,16 +21,117 @@ import TsButton from '-/components/TsButton';import TsIconButton from '-/components/TsIconButton';import { useProTeaserDialogContext } from '-/components/dialogs/hooks/useProTeaserDialogContext';import { openURLExternally } from '-/services/utils-io';+import { keyframes } from '@emotion/react';+import AccountTreeTwoToneIcon from '@mui/icons-material/AccountTreeTwoTone';+import AutoAwesomeTwoToneIcon from '@mui/icons-material/AutoAwesomeTwoTone';+import CalendarMonthTwoToneIcon from '@mui/icons-material/CalendarMonthTwoTone';import CameraTwoToneIcon from '@mui/icons-material/CameraTwoTone';+import DescriptionTwoToneIcon from '@mui/icons-material/DescriptionTwoTone';+import FolderTwoToneIcon from '@mui/icons-material/FolderTwoTone';+import HistoryTwoToneIcon from '@mui/icons-material/HistoryTwoTone';import MapTwoToneIcon from '@mui/icons-material/MapTwoTone';import ViewKanbanTwoToneIcon from '@mui/icons-material/ViewKanbanTwoTone';-import { Box, ButtonGroup } from '@mui/material';+import { Box, ButtonGroup, SvgIconTypeMap } from '@mui/material';import CardActions from '@mui/material/CardActions';import CardContent from '@mui/material/CardContent';+import { OverridableComponent } from '@mui/material/OverridableComponent';import Typography from '@mui/material/Typography';import Links from 'assets/links';+import { useState } from 'react';import { useTranslation } from 'react-i18next';+const floatAnim = keyframes`+ 0% { transform: translateY(0px) scale(1); }+ 50% { transform: translateY(-7px) scale(1.15); }+ 100% { transform: translateY(0px) scale(1); }+`;++const PRO_ADS_STORAGE_KEY = 'tsProTeaserAdIndex';++interface ProAd {+ slideId: string;+ Icon: OverridableComponent<SvgIconTypeMap>;+ color: string;+ headlineKey: string;+ subtextKey: string;+}++const proAds: ProAd[] = [+ {+ slideId: 'kanban',+ Icon: ViewKanbanTwoToneIcon,+ color: '#a466aa',+ headlineKey: 'core:proTeaserKanbanHeadline',+ subtextKey: 'core:proTeaserKanbanSubtext',+ },+ {+ slideId: 'gallery',+ Icon: CameraTwoToneIcon,+ color: '#f7901e',+ headlineKey: 'core:proTeaserGalleryHeadline',+ subtextKey: 'core:proTeaserGallerySubtext',+ },+ {+ slideId: 'mapique',+ Icon: MapTwoToneIcon,+ color: '#33b5be',+ headlineKey: 'core:proTeaserMapiqueHeadline',+ subtextKey: 'core:proTeaserMapiqueSubtext',+ },+ {+ slideId: 'folderviz',+ Icon: AccountTreeTwoToneIcon,+ color: '#6aaa44',+ headlineKey: 'core:proTeaserFoldervizHeadline',+ subtextKey: 'core:proTeaserFoldervizSubtext',+ },+ {+ slideId: 'calendar',+ Icon: CalendarMonthTwoToneIcon,+ color: '#e57373',+ headlineKey: 'core:proTeaserCalendarHeadline',+ subtextKey: 'core:proTeaserCalendarSubtext',+ },+ {+ slideId: 'ai',+ Icon: AutoAwesomeTwoToneIcon,+ color: '#7c4dff',+ headlineKey: 'core:proTeaserAiHeadline',+ subtextKey: 'core:proTeaserAiSubtext',+ },+ {+ slideId: 'annotation',+ Icon: DescriptionTwoToneIcon,+ color: '#0288d1',+ headlineKey: 'core:proTeaserAnnotationHeadline',+ subtextKey: 'core:proTeaserAnnotationSubtext',+ },+ {+ slideId: 'revisions',+ Icon: HistoryTwoToneIcon,+ color: '#795548',+ headlineKey: 'core:proTeaserRevisionsHeadline',+ subtextKey: 'core:proTeaserRevisionsSubtext',+ },+ {+ slideId: 'folderColor',+ Icon: FolderTwoToneIcon,+ color: '#ff8f00',+ headlineKey: 'core:proTeaserFolderColorHeadline',+ subtextKey: 'core:proTeaserFolderColorSubtext',+ },+];++function getNextAdIndex(): number {+ const stored = parseInt(+ localStorage.getItem(PRO_ADS_STORAGE_KEY) ?? '-1',+ 10,+ );+ const next = (stored + 1) % proAds.length;+ localStorage.setItem(PRO_ADS_STORAGE_KEY, String(next));+ return next;+}+interface Props {setShowTeaserBanner: (teaserVisibility: boolean) => void;}@@ -38,10 +139,23 @@ interface Props {function ProTeaser(props: Props) {const { setShowTeaserBanner } = props;const { openProTeaserDialog } = useProTeaserDialogContext();-const { t } = useTranslation();++ const [adIndex] = useState<number>(getNextAdIndex);+ const ad = proAds[adIndex];+ const { Icon } = ad;+return (- <Box sx={{ display: 'block', marginBottom: 0 }}>+ <Box+ sx={{+ display: 'block',+ marginBottom: 0,+ '&:hover .pro-teaser-icon': {+ animation: `${floatAnim} 1.2s ease-in-out infinite`,+ filter: `drop-shadow(0 0 6px ${ad.color}99)`,+ },+ }}+ ><CardContentsx={{paddingLeft: '5px',@@ -53,7 +167,6 @@ function ProTeaser(props: Props) {}}><Typography variant="caption" sx={{ textTransform: 'lowercase' }}>- {t('core:achieveMore')}<TsIconButtonsx={{ right: '5px', position: 'absolute' }}size="small"@@ -67,46 +180,62 @@ function ProTeaser(props: Props) {<CloseDialogIcon fontSize="small" /></TsIconButton></Typography>- <br /><divrole="button"- onClick={() => openProTeaserDialog()}- style={{- cursor: 'pointer',- }}+ onClick={() => openProTeaserDialog(ad.slideId)}+ style={{ cursor: 'pointer' }}>- <b>TagSpaces Pro</b>- <br />- <ViewKanbanTwoToneIcon+ <Icon+ className="pro-teaser-icon"sx={{- fontSize: '50px',- color: '#a466aa',+ fontSize: '44px',+ color: ad.color,+ mt: '2px',+ mb: '-4px',+ transition: 'filter 0.3s ease, color 0.3s ease',}}/>- <CameraTwoToneIcon sx={{ fontSize: '50px', color: '#f7901e' }} />- <MapTwoToneIcon sx={{ fontSize: '50px', color: '#33b5be' }} />+ <Typography+ variant="body2"+ sx={{ fontWeight: 'bold', lineHeight: 1.2 }}+ >+ {t(ad.headlineKey)}+ </Typography>+ <Typography variant="caption" sx={{ color: 'text.secondary' }}>+ {t(ad.subtextKey)}+ </Typography></div></CardContent><CardActionssx={{flexDirection: 'row',justifyContent: 'center',- marginTop: '-10px',+ marginTop: '2px',}}><ButtonGroup><TsButton- sx={{ borderTopRightRadius: 0, borderBottomRightRadius: 0 }}+ sx={{+ borderTopRightRadius: 0,+ borderBottomRightRadius: 0,+ fontWeight: 300,+ }}+ variant="text"onClick={(event: any) => {event.preventDefault();event.stopPropagation();- openProTeaserDialog();+ openProTeaserDialog(ad.slideId);}}>{t('showMeMore')}</TsButton><TsButton- sx={{ borderTopLeftRadius: 0, borderBottomLeftRadius: 0 }}+ sx={{+ borderTopLeftRadius: 0,+ borderBottomLeftRadius: 0,+ fontWeight: 300,+ }}+ variant="text"onClick={(event: any) => {event.preventDefault();event.stopPropagation();diff --git a/src/renderer/components/dialogs/ProTeaserDialog.tsx b/src/renderer/components/dialogs/ProTeaserDialog.tsxindex 8ca10a296..8e3d15cb4 100644--- a/src/renderer/components/dialogs/ProTeaserDialog.tsx+++ b/src/renderer/components/dialogs/ProTeaserDialog.tsx@@ -22,7 +22,7 @@ import TsButton from '-/components/TsButton';import TsDialogTitle from '-/components/dialogs/components/TsDialogTitle';import { getProTeaserSlides } from '-/content/ProTeaserSlides';import { openURLExternally } from '-/services/utils-io';-import { Box } from '@mui/material';+import { Box, ButtonGroup } from '@mui/material';import Dialog from '@mui/material/Dialog';import DialogContent from '@mui/material/DialogContent';import Paper from '@mui/material/Paper';@@ -131,23 +131,25 @@ function Slide(props: SlideProps) {)}<br /><Box sx={{ whiteSpace: 'nowrap' }}>- <TsButton- onClick={() => {- openURLExternally(Links.links.productsOverview, true);- }}- >- {t('core:compareAndUpgrade')}- </TsButton>- {ctaTitle && (+ <ButtonGroup><TsButtononClick={() => {- openURLExternally(ctaURL, true);+ openURLExternally(Links.links.productsOverview, true);}}- sx={{ marginLeft: AppConfig.defaultSpaceBetweenButtons }}>- {ctaTitle}+ {t('core:compareAndUpgrade')}</TsButton>- )}+ {ctaTitle && (+ <TsButton+ onClick={() => {+ openURLExternally(ctaURL, true);+ }}+ sx={{ marginLeft: AppConfig.defaultSpaceBetweenButtons }}+ >+ {ctaTitle}+ </TsButton>+ )}+ </ButtonGroup></Box></Box></Box>diff --git a/src/renderer/locales/en_US/core.json b/src/renderer/locales/en_US/core.jsonindex b8b0ee655..39cfe8cfc 100644--- a/src/renderer/locales/en_US/core.json+++ b/src/renderer/locales/en_US/core.json@@ -1182,5 +1182,23 @@"fridayAbbr": "Fri","saturdayAbbr": "Sat","sundayAbbr": "Sun",+ "proTeaserKanbanHeadline": "Organize tasks visually",+ "proTeaserKanbanSubtext": "Kanban board for your files",+ "proTeaserGalleryHeadline": "Browse files as a gallery",+ "proTeaserGallerySubtext": "Thumbnail view for images & videos",+ "proTeaserMapiqueHeadline": "Tag files with location",+ "proTeaserMapiqueSubtext": "View geo-tagged files on a map",+ "proTeaserFoldervizHeadline": "Visualize your folder structure",+ "proTeaserFoldervizSubtext": "Tag graphs, tree maps & more",+ "proTeaserCalendarHeadline": "See your files in time",+ "proTeaserCalendarSubtext": "Browse files by date on a calendar",+ "proTeaserAiHeadline": "AI-powered file analysis",+ "proTeaserAiSubtext": "Summarize, tag, and extract insights",+ "proTeaserAnnotationHeadline": "Annotate any file or folder",+ "proTeaserAnnotationSubtext": "Add rich descriptions & links",+ "proTeaserRevisionsHeadline": "Never lose your work",+ "proTeaserRevisionsSubtext": "File revisions & auto-save",+ "proTeaserFolderColorHeadline": "Color-code your folders",+ "proTeaserFolderColorSubtext": "Custom colors & backgrounds","-": "-"}