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

chore: add inherit option for survery font customization #29199

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
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="Custom font selection 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
Loading