Skip to content

Commit

Permalink
Privacy mode: instead of blurring, use an illegible font (#3376)
Browse files Browse the repository at this point in the history
  • Loading branch information
olets committed Sep 6, 2024
1 parent fca1bcc commit 49b25c0
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 23 deletions.
1 change: 1 addition & 0 deletions packages/desktop-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"build"
],
"devDependencies": {
"@fontsource/redacted-script": "^5.0.21",
"@juggle/resize-observer": "^3.4.0",
"@playwright/test": "1.41.1",
"@react-aria/focus": "^3.16.0",
Expand Down
23 changes: 10 additions & 13 deletions packages/desktop-client/src/components/PrivacyFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ export function ConditionalPrivacyFilter({

type PrivacyFilterProps = ComponentPropsWithRef<typeof View> & {
activationFilters?: (boolean | (() => boolean))[];
blurIntensity?: number;
lineHeight?: number;
};
export function PrivacyFilter({
activationFilters,
blurIntensity,
lineHeight,
children,
...props
}: PrivacyFilterProps) {
Expand All @@ -63,29 +63,26 @@ export function PrivacyFilter({
typeof value === 'boolean' ? value : value(),
));

const blurAmount = blurIntensity != null ? `${blurIntensity}px` : '3px';
const privacyLineHeight = lineHeight != null ? lineHeight : 'inherit';

return !activate ? (
<>{Children.toArray(children)}</>
) : (
<BlurredOverlay blurIntensity={blurAmount} {...props}>
<PrivacyOverlay lineHeight={privacyLineHeight} {...props}>
{children}
</BlurredOverlay>
</PrivacyOverlay>
);
}

function BlurredOverlay({ blurIntensity, children, ...props }) {
function PrivacyOverlay({ lineHeight, children, ...props }) {
const [hovered, setHovered] = useState(false);
const onHover = useCallback(() => setHovered(true), [setHovered]);
const onHoverEnd = useCallback(() => setHovered(false), [setHovered]);

const blurStyle = {
const privacyStyle = {
...(!hovered && {
filter: `blur(${blurIntensity})`,
WebkitFilter: `blur(${blurIntensity})`,
// To fix blur performance issue in Safari.
// https://graffino.com/til/CjT2jrcLHP-how-to-fix-filter-blur-performance-issue-in-safari
transform: `translate3d(0, 0, 0)`,
fontFamily: 'Redacted Script',
lineHeight: lineHeight

Check warning on line 85 in packages/desktop-client/src/components/PrivacyFilter.tsx

View workflow job for this annotation

GitHub Actions / lint

Expected property shorthand

Check warning on line 85 in packages/desktop-client/src/components/PrivacyFilter.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
}),
};

Expand All @@ -95,7 +92,7 @@ function BlurredOverlay({ blurIntensity, children, ...props }) {
<View
style={{
display: style?.display ? style.display : 'inline-flex',
...blurStyle,
...privacyStyle,
...style,
}}
onPointerEnter={onHover}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export function Balances({
: theme.pageTextSubdued,
})}
privacyFilter={{
blurIntensity: 5,
lineHeight: 1.22,
}}
/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function Saved({ projected, style }: SavedProps) {
},
])}`}
>
<PrivacyFilter blurIntensity={7}>
<PrivacyFilter>

Check warning on line 88 in packages/desktop-client/src/components/budget/report/budgetsummary/Saved.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `⏎············{format(saved,·'financial')}⏎··········` with `{format(saved,·'financial')}`
{format(saved, 'financial')}
</PrivacyFilter>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function ToBudgetAmount({
offset={3}
triggerProps={{ isDisabled: isTotalsListTooltipDisabled }}
>
<PrivacyFilter blurIntensity={7}>
<PrivacyFilter lineHeight={1.2}>
<Block
onClick={onClick}
data-cellname={sheetName}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export function ReportSummary({
fontWeight: 800,
}}
>
<PrivacyFilter blurIntensity={7}>
<PrivacyFilter>

Check warning on line 120 in packages/desktop-client/src/components/reports/ReportSummary.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `⏎············{amountToCurrency(data[balanceTypeOp])}⏎··········` with `{amountToCurrency(data[balanceTypeOp])}`
{amountToCurrency(data[balanceTypeOp])}
</PrivacyFilter>
</Text>
Expand Down Expand Up @@ -154,7 +154,7 @@ export function ReportSummary({
fontWeight: 800,
}}
>
<PrivacyFilter blurIntensity={7}>
<PrivacyFilter>
{!isNaN(average) && integerToCurrency(Math.round(average))}
</PrivacyFilter>
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ export function CustomReport() {
left={<Block>{balanceType}:</Block>}
right={
<Text>
<PrivacyFilter blurIntensity={5}>
<PrivacyFilter>
{amountToCurrency(data[balanceTypeOp])}
</PrivacyFilter>
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export function NetWorth() {
<View
style={{ ...styles.largeText, fontWeight: 400, marginBottom: 5 }}
>
<PrivacyFilter blurIntensity={5}>
<PrivacyFilter>

Check warning on line 138 in packages/desktop-client/src/components/reports/reports/NetWorth.jsx

View workflow job for this annotation

GitHub Actions / lint

Replace `⏎··············{integerToCurrency(data.netWorth)}⏎············` with `{integerToCurrency(data.netWorth)}`
{integerToCurrency(data.netWorth)}
</PrivacyFilter>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ export function Spending() {
}
right={
<Text style={{ fontWeight: 600 }}>
<PrivacyFilter blurIntensity={5}>
<PrivacyFilter>
{amountToCurrency(
Math.abs(
data.intervalData[todayDay][
Expand All @@ -374,7 +374,7 @@ export function Spending() {
}
right={
<Text style={{ fontWeight: 600 }}>
<PrivacyFilter blurIntensity={5}>
<PrivacyFilter>
{amountToCurrency(
Math.abs(
data.intervalData[todayDay][
Expand All @@ -400,7 +400,7 @@ export function Spending() {
}
right={
<Text style={{ fontWeight: 600 }}>
<PrivacyFilter blurIntensity={5}>
<PrivacyFilter>
{amountToCurrency(
Math.abs(data.intervalData[todayDay].average),
)}
Expand Down
2 changes: 2 additions & 0 deletions packages/desktop-client/src/fonts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
$inter-font-path: '../../../node_modules/inter-ui/Inter (web)'
);
@include variable.default;

@import "@fontsource/redacted-script";
6 changes: 6 additions & 0 deletions upcoming-release-notes/3377.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [olets]
---

Privacy mode: instead of blurring, use an illegible font (#3376)
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@actual-app/web@workspace:packages/desktop-client"
dependencies:
"@fontsource/redacted-script": "npm:^5.0.21"
"@juggle/resize-observer": "npm:^3.4.0"
"@playwright/test": "npm:1.41.1"
"@react-aria/focus": "npm:^3.16.0"
Expand Down Expand Up @@ -1857,6 +1858,13 @@ __metadata:
languageName: node
linkType: hard

"@fontsource/redacted-script@npm:^5.0.21":
version: 5.0.21
resolution: "@fontsource/redacted-script@npm:5.0.21"
checksum: 10/93f506c9e8df827ab1872d433a09079c592f3a20a1c36b9a168e68377967d3d1d282fffd51bee973c2ecb253316ff4641d244f8f05242e4aa968a1eb14d065eb
languageName: node
linkType: hard

"@formatjs/ecma402-abstract@npm:1.15.0":
version: 1.15.0
resolution: "@formatjs/ecma402-abstract@npm:1.15.0"
Expand Down

0 comments on commit 49b25c0

Please sign in to comment.