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

feat: allow changing the font family for surveys #27292

Merged
merged 6 commits into from
Jan 14, 2025

Conversation

lucasheriques
Copy link
Contributor

@lucasheriques lucasheriques commented Jan 6, 2025

Problem

Feature request: #25338

Adds a new appearance property to surveys: font family.

For this current version, we allow to change for the default web fonts.

Releasing behind a feature flag, which is only enabled for PostHog internal use atm.

Changes

CleanShot.2025-01-06.at.18.11.44.mp4

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Does this work well for both Cloud and self-hosted?

Yes

How did you test this code?

Verified on localhost and on the surveyPreview that the fonts are matching

@lucasheriques lucasheriques changed the title feat: allow custom fonts on surveys feat: allow admins to configure font in the survey editor Jan 6, 2025
Copy link
Contributor

github-actions bot commented Jan 6, 2025

Size Change: -92 B (-0.01%)

Total Size: 1.12 MB

ℹ️ View Unchanged
Filename Size Change
frontend/dist/toolbar.js 1.12 MB -92 B (-0.01%)

compressed-size-action

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

64 snapshot changes in total. 0 added, 64 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@lucasheriques lucasheriques force-pushed the feat/allow-custom-fonts-on-surveys branch from 4212e3f to 6c1c9f8 Compare January 6, 2025 21:30
Comment on lines 144 to 151
}
onChange={(placeholder) => onAppearanceChange({ ...appearance, placeholder })}
disabled={!surveysStylingAvailable}
/>
</LemonField.Pure>
</>
<LemonField.Pure className="mt-2" label="Placeholder text">
<LemonInput
value={
appearance?.placeholder !== undefined
? appearance.placeholder
: defaultSurveyAppearance.placeholder
}
onChange={(placeholder) => onAppearanceChange({ ...appearance, placeholder })}
disabled={!surveysStylingAvailable}
/>
</LemonField.Pure>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes here are just to remove the unneeded fragment

@corywatilo
Copy link
Contributor

Exciting! A few pieces of feedback:

  1. As a front end-oriented person, I'd be pretty disappointed to see only this list of fonts since this triggers my PTSD of being a front end developer back when the web was actually limited to these fonts. (I get this is an MVP and we're going to add more - woo! But just to say I hope we don't launch with just these.) =]

    • Even if we're going to do email surveys, I'd still opt for progressive enhancement and use good fonts on the web and just fall back to whatever we have to in email. It's also worth noting that recent versions of Mac OS come with a tonnn more fonts (eg: Proxima Nova), so I'd probably look at that list as a starting point.
  2. Mac OS has started shipping with a much larger library of fonts like Avenir Next, Baskerville, Noto Sans, Proxima Nova. It'd be worth including options for these (again, progressive enhancement), though denoting fallbacks might be used on other devices.

  3. Figma imports all Google Fonts and lets you pick any of them from there. Since that library has become a pretty solid resource of cross-compatible fonts, it's worth considering doing something similar. Some random implementation thoughts which may or may not be useful:

    • If we're planning on showing a preview of each font in the select, it probably makes sense to only load the single weight used in the select until a font is chosen
    • When loading a Google font on a customer's site, we can probably make a gut call to just import two weights (like 400 and 700) and omit italic (and let the OS infer it if necessary).
    • If the customer is already importing a Google font on their site, we might want an option to exclude us loading it on their site so we're not loading it twice! (Assuming we're not shadow dom'd and have access to the parent?)
  4. Obviously supporting custom fonts would be awesome, but that also introduces a bunch of variables:
    a. Can we just ask for their font string and assume they'll have the font loaded on their site for us to use?
    b. (We're not running in shadow DOM are we?) Do we host them upload fonts to us? Or if we reference their hosted font, any CORS issues?

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

64 snapshot changes in total. 0 added, 64 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week. If you want to permanentely keep it open, use the waiting label.

@lucasheriques lucasheriques requested a review from a team January 14, 2025 15:02
@lucasheriques lucasheriques force-pushed the feat/allow-custom-fonts-on-surveys branch from adf1772 to 931e1fa Compare January 14, 2025 15:04
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

22 snapshot changes in total. 0 added, 22 modified, 0 deleted:

  • chromium: 0 added, 22 modified, 0 deleted (wasn't pushed!)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@lucasheriques lucasheriques force-pushed the feat/allow-custom-fonts-on-surveys branch from 931e1fa to 8f17bab Compare January 14, 2025 15:21
@lucasheriques lucasheriques changed the title feat: allow admins to configure font in the survey editor feat: allow changing the font family for surveys Jan 14, 2025
Comment on lines 140 to +152
{customizePlaceholderText && (
<>
<LemonField.Pure className="mt-2" label="Placeholder text">
<LemonInput
value={
appearance?.placeholder !== undefined
? appearance.placeholder
: defaultSurveyAppearance.placeholder
<LemonField.Pure className="mt-2" label="Placeholder text">
<LemonInput
value={
appearance?.placeholder !== undefined
? appearance.placeholder
: defaultSurveyAppearance.placeholder
}
onChange={(placeholder) => onAppearanceChange({ ...appearance, placeholder })}
disabled={!surveysStylingAvailable}
/>
</LemonField.Pure>
)}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no changes here, just removing the unneeded fragment

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

77 snapshot changes in total. 0 added, 77 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@lucasheriques lucasheriques marked this pull request as ready for review January 14, 2025 15:53
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

4 snapshot changes in total. 0 added, 4 modified, 0 deleted:

  • chromium: 0 added, 4 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Copy link
Member

@marandaneto marandaneto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@lucasheriques lucasheriques enabled auto-merge (squash) January 14, 2025 17:40
@lucasheriques lucasheriques merged commit d667e01 into master Jan 14, 2025
99 checks passed
@lucasheriques lucasheriques deleted the feat/allow-custom-fonts-on-surveys branch January 14, 2025 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants