Skip to content

Commit

Permalink
chore: add inherit option for survery font customization
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasheriques committed Feb 25, 2025
1 parent 75274e5 commit e0829e9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
13 changes: 9 additions & 4 deletions frontend/src/scenes/surveys/SurveyCustomization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,23 @@ export function Customization({
</LemonField.Pure>
)}
{isCustomFontsEnabled && (
<LemonField.Pure className="mt-2" label="Font family">
<LemonField.Pure
className="mt-2"
label="Font family"
// TODO: Update this info when we have a version of posthog-js that supports this
info="Showing a survey all the time requires at least version [XXX] of posthog-js"
>
<LemonSelect
value={appearance?.fontFamily}
onChange={(fontFamily) => onAppearanceChange({ ...appearance, fontFamily })}
options={WEB_SAFE_FONTS.map((font) => {
return {
label: (
<span className={font.toLowerCase().replace(/\s/g, '-')}>
{font} {font === 'system-ui' ? '(default)' : ''}
<span className={font.value.toLowerCase().replace(/\s/g, '-')}>
{font.label}
</span>
),
value: font,
value: font.value,
}
})}
className="ignore-error-border"
Expand Down
19 changes: 10 additions & 9 deletions frontend/src/scenes/surveys/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,14 @@ export const defaultSurveyTemplates = [
]

export const WEB_SAFE_FONTS = [
'system-ui',
'Arial',
'Verdana',
'Tahoma',
'Trebuchet MS',
'Helvetica',
'Times New Roman',
'Georgia',
'Courier New',
{ value: 'system-ui', label: 'system-ui (default)' },
{ value: 'inherit', label: 'inherit (uses the font family of your website)' },
{ value: 'Arial', label: 'Arial' },
{ value: 'Verdana', label: 'Verdana' },
{ value: 'Tahoma', label: 'Tahoma' },
{ value: 'Trebuchet MS', label: 'Trebuchet MS' },
{ value: 'Helvetica', label: 'Helvetica' },
{ value: 'Times New Roman', label: 'Times New Roman' },
{ value: 'Georgia', label: 'Georgia' },
{ value: 'Courier New', label: 'Courier New' },
] as const
4 changes: 4 additions & 0 deletions frontend/src/styles/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,10 @@ img {
font-family: system-ui;
}

.inherit {
font-family: inherit;
}

// Highlight background blink

/* stylelint-disable-next-line keyframes-name-pattern */
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2879,7 +2879,7 @@ export interface SurveyAppearance {
widgetSelector?: string
widgetLabel?: string
widgetColor?: string
fontFamily?: (typeof WEB_SAFE_FONTS)[number]
fontFamily?: (typeof WEB_SAFE_FONTS)[number]['value']
}

export interface SurveyQuestionBase {
Expand Down

0 comments on commit e0829e9

Please sign in to comment.