Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(surveys): extract hosted survey css to a static file (#58289)

Lucas Faria892fe3e7f7e3
diff --git a/frontend/public/surveys/hosted-survey.css b/frontend/public/surveys/hosted-survey.css
new file mode 100644
index 000000000000..bb91d4ae8af5
--- /dev/null
+++ b/frontend/public/surveys/hosted-survey.css
@@ -0,0 +1,625 @@
+.PostHogHostedSurvey {
+ --ph-survey-page-background: #fff;
+ --ph-survey-page-text: #111;
+ --ph-survey-page-text-subtle: #6b6b6b;
+ --ph-survey-page-progress-track: rgb(17 17 17 / 8%);
+ --ph-survey-page-progress-bar: #111;
+ --ph-survey-progress-value: 0%;
+ --ph-survey-page-font:
+ -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', helvetica, arial, sans-serif;
+ --ph-survey-card-shadow: 0 1px 2px rgb(17 17 17 / 4%), 0 2px 8px rgb(17 17 17 / 4%);
+ --ph-survey-pill-background: rgb(255 255 255 / 70%);
+
+ box-sizing: border-box;
+ font-family: var(--ph-survey-page-font);
+ font-size: 16px;
+ line-height: 1.5;
+ color: var(--ph-survey-page-text);
+ background: var(--ph-survey-page-background);
+ -webkit-font-smoothing: antialiased;
+ text-rendering: optimizeLegibility;
+}
+
+body.PostHogHostedSurvey {
+ min-height: 100vh;
+ padding: 0;
+ margin: 0;
+}
+
+.PostHogHostedSurvey *,
+.PostHogHostedSurvey *::before,
+.PostHogHostedSurvey *::after {
+ box-sizing: border-box;
+}
+
+.PostHogHostedSurvey button,
+.PostHogHostedSurvey input,
+.PostHogHostedSurvey textarea,
+.PostHogHostedSurvey a {
+ touch-action: manipulation;
+}
+
+.PostHogHostedSurvey .main-container,
+.PostHogHostedSurvey.main-container {
+ display: flex;
+ flex-direction: column;
+ min-height: 100vh;
+ padding: clamp(1.5rem, 4vw, 2.5rem) clamp(1.25rem, 4vw, 2.5rem);
+}
+
+.PostHogHostedSurvey.HostedSurveyPreviewFrame {
+ display: flex;
+ flex-direction: column;
+ width: 100%;
+ min-height: 520px;
+ padding: clamp(1.5rem, 4vw, 2.5rem);
+ border: 1px solid var(--border, rgb(17 17 17 / 10%));
+ border-radius: 8px;
+}
+
+.PostHogHostedSurvey.HostedSurveyPreviewFrame--mobile {
+ max-width: 360px;
+ min-height: 560px;
+ padding: 1.25rem;
+ margin: 0 auto;
+}
+
+.PostHogHostedSurvey .survey-progress-wrap {
+ width: 100%;
+ max-width: 44rem;
+ margin: 0 auto;
+}
+
+.PostHogHostedSurvey .survey-progress-track {
+ width: 100%;
+ height: 3px;
+ overflow: hidden;
+ background: var(--ph-survey-page-progress-track);
+ border-radius: 999px;
+}
+
+.PostHogHostedSurvey .survey-progress-bar {
+ display: block;
+ width: var(--ph-survey-progress-value);
+ height: 100%;
+ background: var(--ph-survey-page-progress-bar);
+ transition: width 240ms cubic-bezier(0.22, 1, 0.36, 1);
+}
+
+.PostHogHostedSurvey .survey-stage {
+ display: flex;
+ flex-direction: column;
+ width: 100%;
+ max-width: 44rem;
+ margin: auto;
+}
+
+.PostHogHostedSurvey #posthog-survey-container,
+.PostHogHostedSurvey .posthog-survey-container {
+ display: flex;
+ flex-direction: column;
+ font-family: inherit;
+ color: var(--ph-survey-text-primary-color, #111);
+}
+
+.PostHogHostedSurvey .question-container {
+ display: flex;
+ flex-direction: column;
+ gap: 1.5rem;
+}
+
+.PostHogHostedSurvey .thank-you-message {
+ display: flex;
+ flex-direction: column;
+ gap: 1.5rem;
+ align-items: center;
+ text-align: center;
+}
+
+.PostHogHostedSurvey .survey-question,
+.PostHogHostedSurvey .thank-you-message-header {
+ margin: 0;
+ font-size: clamp(1.5rem, 2.4vw, 1.875rem);
+ font-weight: 600;
+ line-height: 1.25;
+ color: var(--ph-survey-text-primary-color, #111);
+ text-wrap: balance;
+ letter-spacing: -0.015em;
+}
+
+.PostHogHostedSurvey .survey-question-description,
+.PostHogHostedSurvey .thank-you-message-body {
+ margin: 0;
+ font-size: 0.975rem;
+ line-height: 1.6;
+ color: var(--ph-survey-text-subtle-color, #6b6b6b);
+}
+
+.PostHogHostedSurvey .survey-question-description strong,
+.PostHogHostedSurvey .thank-you-message strong {
+ color: var(--ph-survey-text-primary-color, #111);
+}
+
+.PostHogHostedSurvey fieldset {
+ min-width: 0;
+ padding: 0;
+ margin: 0;
+ border: 0;
+}
+
+.PostHogHostedSurvey legend {
+ padding: 0;
+}
+
+.PostHogHostedSurvey .response-choice {
+ display: flex;
+ flex: 1;
+ gap: 0.75rem;
+ align-items: center;
+ min-width: 0;
+}
+
+.PostHogHostedSurvey textarea,
+.PostHogHostedSurvey input[type='text'] {
+ width: 100%;
+ padding: 0.875rem 1rem;
+ font: inherit;
+ font-size: 1rem;
+ line-height: 1.5;
+ color: var(--ph-survey-input-text-color, #111);
+ background: var(--ph-survey-input-background, #fff);
+ border: 1px solid var(--ph-survey-border-color, rgb(17 17 17 / 10%));
+ border-radius: var(--ph-survey-border-radius, 10px);
+ box-shadow: var(--ph-survey-card-shadow);
+ transition:
+ border-color 160ms ease,
+ box-shadow 160ms ease;
+}
+
+.PostHogHostedSurvey textarea {
+ min-height: 8rem;
+ resize: vertical;
+}
+
+.PostHogHostedSurvey textarea::placeholder,
+.PostHogHostedSurvey input[type='text']::placeholder {
+ color: var(--ph-survey-text-subtle-color, #6b6b6b);
+ opacity: 0.65;
+}
+
+.PostHogHostedSurvey textarea:focus-visible,
+.PostHogHostedSurvey input[type='text']:focus-visible {
+ border-color: var(--ph-survey-rating-active-bg-color, #111);
+ outline: none;
+ box-shadow:
+ 0 0 0 3px rgb(17 17 17 / 10%),
+ var(--ph-survey-card-shadow);
+}
+
+.PostHogHostedSurvey .validation-hint {
+ margin-top: 0.5rem;
+ font-size: 0.825rem;
+ color: var(--ph-survey-text-subtle-color, #6b6b6b);
+}
+
+.PostHogHostedSurvey .multiple-choice-options {
+ display: flex;
+ flex-direction: column;
+ gap: 0.5rem;
+ padding: 0;
+ margin: 0;
+}
+
+.PostHogHostedSurvey .multiple-choice-options label {
+ display: flex;
+ flex-direction: column;
+ gap: 0.625rem;
+ min-height: 3rem;
+ padding: 0.875rem 1rem;
+ font-size: 0.975rem;
+ color: var(--ph-survey-input-text-color, #111);
+ cursor: pointer;
+ background: var(--ph-survey-input-background, #fff);
+ border: 1px solid var(--ph-survey-border-color, rgb(17 17 17 / 10%));
+ border-radius: var(--ph-survey-border-radius, 10px);
+ box-shadow: var(--ph-survey-card-shadow);
+ transition:
+ border-color 140ms ease,
+ background-color 140ms ease,
+ transform 140ms ease,
+ box-shadow 140ms ease;
+}
+
+.PostHogHostedSurvey .multiple-choice-options label:has(input:checked) {
+ border-color: var(--ph-survey-rating-active-bg-color, #111);
+ box-shadow:
+ inset 0 0 0 1px var(--ph-survey-rating-active-bg-color, #111),
+ var(--ph-survey-card-shadow);
+}
+
+.PostHogHostedSurvey .multiple-choice-options label:has(input:focus-visible) {
+ outline: none;
+ box-shadow: 0 0 0 3px rgb(17 17 17 / 12%);
+}
+
+.PostHogHostedSurvey .multiple-choice-options input[type='checkbox'],
+.PostHogHostedSurvey .multiple-choice-options input[type='radio'] {
+ position: relative;
+ flex-shrink: 0;
+ width: 1.1rem;
+ height: 1.1rem;
+ margin: 0;
+ /* stylelint-disable-next-line property-no-vendor-prefix */
+ -webkit-appearance: none;
+ appearance: none;
+ cursor: pointer;
+ background: #fff;
+ border: 1.5px solid rgb(17 17 17 / 28%);
+ transition:
+ border-color 140ms ease,
+ background-color 140ms ease;
+}
+
+.PostHogHostedSurvey .multiple-choice-options input[type='checkbox'] {
+ border-radius: 4px;
+}
+
+.PostHogHostedSurvey .multiple-choice-options input[type='radio'] {
+ border-radius: 999px;
+}
+
+.PostHogHostedSurvey .multiple-choice-options input[type='checkbox']:focus-visible,
+.PostHogHostedSurvey .multiple-choice-options input[type='radio']:focus-visible,
+.PostHogHostedSurvey button:focus-visible {
+ outline: none;
+ box-shadow: 0 0 0 3px rgb(17 17 17 / 12%);
+}
+
+.PostHogHostedSurvey .multiple-choice-options input[type='checkbox']:checked,
+.PostHogHostedSurvey .multiple-choice-options input[type='radio']:checked {
+ background: var(--ph-survey-rating-active-bg-color, #111);
+ border-color: var(--ph-survey-rating-active-bg-color, #111);
+}
+
+.PostHogHostedSurvey .multiple-choice-options input[type='checkbox']:checked::after,
+.PostHogHostedSurvey .multiple-choice-options input[type='radio']:checked::after {
+ position: absolute;
+ box-sizing: content-box;
+ content: '';
+}
+
+.PostHogHostedSurvey .multiple-choice-options input[type='checkbox']:checked::after {
+ top: 0.05rem;
+ left: 0.3rem;
+ width: 0.22rem;
+ height: 0.5rem;
+ border: solid var(--ph-survey-rating-active-text-color, #fff);
+ border-width: 0 2px 2px 0;
+ transform: rotate(45deg);
+}
+
+.PostHogHostedSurvey .multiple-choice-options input[type='radio']:checked::after {
+ top: 0.27rem;
+ left: 0.27rem;
+ width: 0.32rem;
+ height: 0.32rem;
+ background: var(--ph-survey-rating-active-text-color, #fff);
+ border-radius: 999px;
+}
+
+.PostHogHostedSurvey .choice-option-open input[type='text'] {
+ width: calc(100% - 1.85rem);
+ margin-left: calc(1.1rem + 0.75rem);
+}
+
+.PostHogHostedSurvey .rating-section {
+ display: flex;
+ flex-direction: column;
+ gap: 0.625rem;
+}
+
+.PostHogHostedSurvey .rating-options-number {
+ display: grid;
+ grid-auto-columns: 1fr;
+ grid-auto-flow: column;
+ gap: 0.4rem;
+}
+
+.PostHogHostedSurvey .ratings-number {
+ min-height: 3rem;
+ padding: 0.75rem 0;
+ font: inherit;
+ font-size: 1rem;
+ font-weight: 600;
+ color: var(--ph-survey-rating-text-color, #111);
+ cursor: pointer;
+ background: var(--ph-survey-rating-bg-color, #f1efea);
+ border: 1px solid var(--ph-survey-border-color, rgb(17 17 17 / 10%));
+ border-radius: var(--ph-survey-border-radius, 10px);
+ box-shadow: var(--ph-survey-card-shadow);
+ transition:
+ background-color 140ms ease,
+ color 140ms ease,
+ border-color 140ms ease,
+ transform 140ms ease,
+ box-shadow 140ms ease;
+}
+
+.PostHogHostedSurvey .ratings-number.rating-active {
+ color: var(--ph-survey-rating-active-text-color, #fff);
+ background: var(--ph-survey-rating-active-bg-color, #111);
+ border-color: var(--ph-survey-rating-active-bg-color, #111);
+}
+
+.PostHogHostedSurvey .rating-options-emoji {
+ display: flex;
+ gap: 0.5rem;
+ justify-content: space-between;
+}
+
+.PostHogHostedSurvey .ratings-emoji {
+ min-width: 2.75rem;
+ min-height: 2.75rem;
+ padding: 0;
+ cursor: pointer;
+ background: transparent;
+ border: 0;
+ border-radius: 999px;
+ opacity: 0.5;
+ transition:
+ opacity 140ms ease,
+ background-color 140ms ease;
+}
+
+.PostHogHostedSurvey .ratings-emoji.rating-active {
+ background: rgb(17 17 17 / 6%);
+ opacity: 1;
+}
+
+.PostHogHostedSurvey .ratings-emoji svg {
+ fill: var(--ph-survey-text-primary-color, #111);
+}
+
+.PostHogHostedSurvey .rating-text {
+ display: flex;
+ gap: 1rem;
+ justify-content: space-between;
+ font-size: 0.825rem;
+ color: var(--ph-survey-text-subtle-color, #6b6b6b);
+}
+
+.PostHogHostedSurvey .bottom-section {
+ display: flex;
+ flex-flow: row wrap;
+ gap: 0.875rem 1rem;
+ align-items: center;
+ margin-top: 2rem;
+}
+
+.PostHogHostedSurvey .form-submit {
+ min-width: 10rem;
+ min-height: 3rem;
+ padding: 0.75rem 1.75rem;
+ font: inherit;
+ font-size: 1rem;
+ font-weight: 600;
+ color: var(--ph-survey-submit-button-text-color, #fff);
+ cursor: pointer;
+ user-select: none;
+ background: var(--ph-survey-submit-button-color, #111);
+ border: 0;
+ border-radius: var(--ph-survey-border-radius, 10px);
+ box-shadow: none;
+ transition:
+ opacity 140ms ease,
+ transform 140ms ease,
+ background-color 140ms ease,
+ color 140ms ease,
+ box-shadow 140ms ease;
+}
+
+.PostHogHostedSurvey .form-submit[disabled] {
+ color: var(--ph-survey-text-subtle-color, #6b6b6b);
+ cursor: not-allowed;
+ background: transparent;
+ box-shadow: inset 0 0 0 1px var(--ph-survey-border-color, rgb(17 17 17 / 10%));
+ opacity: 1;
+}
+
+.PostHogHostedSurvey .footer-branding {
+ z-index: 10;
+ display: inline-flex;
+ gap: 0.35rem;
+ align-items: center;
+ align-self: flex-end;
+ padding: 0.4rem 0.7rem;
+ margin-top: 1rem;
+ font-size: 0.72rem;
+ font-weight: 500;
+ color: var(--ph-survey-page-text-subtle, #6b6b6b);
+ text-decoration: none;
+ background: var(--ph-survey-pill-background);
+ /* stylelint-disable-next-line property-no-vendor-prefix */
+ -webkit-backdrop-filter: blur(8px);
+ backdrop-filter: blur(8px);
+ border-radius: 999px;
+ box-shadow:
+ 0 1px 2px rgb(17 17 17 / 4%),
+ 0 4px 14px rgb(17 17 17 / 6%);
+ opacity: 0.75;
+ transition: opacity 140ms ease;
+}
+
+.PostHogHostedSurvey #posthog-survey-container .footer-branding {
+ position: fixed;
+ right: 1.25rem;
+ bottom: 1.25rem;
+ margin-top: 0;
+}
+
+.PostHogHostedSurvey .footer-branding:hover {
+ opacity: 1;
+}
+
+.PostHogHostedSurvey .footer-branding svg {
+ width: auto;
+ height: 0.85rem;
+}
+
+.PostHogHostedSurvey .loading {
+ display: flex;
+ flex: 1;
+ flex-direction: column;
+ gap: 0.75rem;
+ align-items: center;
+ justify-content: center;
+ min-height: 16rem;
+ color: var(--ph-survey-page-text-subtle);
+ text-align: center;
+}
+
+.PostHogHostedSurvey .loading-spinner {
+ width: 2rem;
+ height: 2rem;
+ border: 2px solid rgb(17 17 17 / 10%);
+ border-top-color: var(--ph-survey-page-text);
+ border-radius: 999px;
+ animation: PostHogHostedSurvey__spin 800ms linear infinite;
+}
+
+.PostHogHostedSurvey .loading-text {
+ margin: 0;
+ font-size: 0.9rem;
+}
+
+.PostHogHostedSurvey #posthog-survey-container:has(.question-container) .loading,
+.PostHogHostedSurvey #posthog-survey-container:has(.thank-you-message) .loading {
+ display: none;
+}
+
+.PostHogHostedSurvey .sr-only {
+ position: absolute;
+ width: 1px;
+ height: 1px;
+ padding: 0;
+ margin: -1px;
+ overflow: hidden;
+ clip: rect(0, 0, 0, 0);
+ white-space: nowrap;
+ border: 0;
+}
+
+.PostHogHostedSurvey .survey-keyhint {
+ display: none;
+ gap: 1rem;
+ align-items: center;
+ font-size: 0.84rem;
+ color: var(--ph-survey-text-subtle-color, #6b6b6b);
+ pointer-events: none;
+ user-select: none;
+}
+
+.PostHogHostedSurvey .survey-keyhint-row {
+ display: inline-flex;
+ gap: 0.4rem;
+ align-items: center;
+}
+
+.PostHogHostedSurvey .survey-kbd {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ min-width: 1.7rem;
+ height: 1.7rem;
+ padding: 0 0.45rem;
+ font-family: inherit;
+ font-size: 0.88rem;
+ font-weight: 500;
+ font-variant-numeric: tabular-nums;
+ line-height: 1;
+ color: var(--ph-survey-text-primary-color, #111);
+ background: var(--ph-survey-rating-bg-color, var(--ph-survey-input-background, rgb(17 17 17 / 6%)));
+ border: 1px solid var(--ph-survey-border-color, rgb(17 17 17 / 10%));
+ border-radius: 6px;
+ box-shadow:
+ inset 0 0 0 1px rgb(255 255 255 / 5%),
+ 0 1px 2px rgb(17 17 17 / 12%);
+}
+
+.PostHogHostedSurvey .survey-keyhint-label {
+ font-weight: 400;
+ color: var(--ph-survey-text-subtle-color, #6b6b6b);
+ letter-spacing: 0.01em;
+}
+
+@media (hover: hover) and (pointer: fine) {
+ .PostHogHostedSurvey .survey-keyhint {
+ display: inline-flex;
+ }
+
+ .PostHogHostedSurvey .multiple-choice-options label:hover:not(:has(input:checked)),
+ .PostHogHostedSurvey .ratings-number:hover:not(.rating-active) {
+ border-color: rgb(17 17 17 / 22%);
+ transform: translateY(-1px);
+ }
+
+ .PostHogHostedSurvey .form-submit:hover:not([disabled]) {
+ opacity: 0.92;
+ transform: translateY(-1px);
+ }
+}
+
+@media (max-width: 640px) {
+ .PostHogHostedSurvey .main-container,
+ .PostHogHostedSurvey.main-container {
+ padding: 1.25rem;
+ padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
+ }
+
+ .PostHogHostedSurvey .form-submit {
+ width: 100%;
+ min-width: 0;
+ }
+
+ .PostHogHostedSurvey .survey-question,
+ .PostHogHostedSurvey .thank-you-message-header {
+ font-size: 1.5rem;
+ }
+
+ .PostHogHostedSurvey #posthog-survey-container .footer-branding {
+ right: 0.75rem;
+ bottom: 0.75rem;
+ }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .PostHogHostedSurvey *,
+ .PostHogHostedSurvey *::before,
+ .PostHogHostedSurvey *::after {
+ transition-duration: 0.01ms !important;
+ animation-duration: 0.01ms !important;
+ animation-iteration-count: 1 !important;
+ scroll-behavior: auto !important;
+ }
+}
+
+@keyframes PostHogHostedSurvey__spin {
+ to {
+ transform: rotate(360deg);
+ }
+}
+
+html.embed-mode body.PostHogHostedSurvey {
+ min-height: auto;
+ background: transparent;
+}
+
+html.embed-mode .PostHogHostedSurvey .main-container,
+html.embed-mode .PostHogHostedSurvey.main-container {
+ min-height: auto;
+ padding: 0;
+}
+
+html.embed-mode .PostHogHostedSurvey .survey-progress-track {
+ margin-bottom: 1.5rem;
+}
diff --git a/posthog/settings/web.py b/posthog/settings/web.py
index 3c0f1e8862ee..682f5b0313ba 100644
--- a/posthog/settings/web.py
+++ b/posthog/settings/web.py
@@ -337,7 +337,11 @@ STORAGES = {
"BACKEND": "django.core.files.storage.FileSystemStorage",
},
"staticfiles": {
- "BACKEND": "whitenoise.storage.ManifestStaticFilesStorage",
+ "BACKEND": (
+ "django.contrib.staticfiles.storage.StaticFilesStorage"
+ if TEST
+ else "whitenoise.storage.ManifestStaticFilesStorage"
+ ),
},
}
diff --git a/posthog/templates/surveys/public_survey.html b/posthog/templates/surveys/public_survey.html
index f57d8d5dfe62..3d36bbc2698f 100644
--- a/posthog/templates/surveys/public_survey.html
+++ b/posthog/templates/surveys/public_survey.html
@@ -1,3 +1,4 @@
+{% load static %}
<!DOCTYPE html>
<html lang="{{ display_language|default:'en' }}"{% if embed_mode %} class="embed-mode"{% endif %}>
@@ -9,592 +10,11 @@
<link rel="icon" type="image/png" sizes="16x16" href="/static/icons/favicon-16x16.png?v=2023-07-07">
<link rel="mask-icon" href="/static/icons/safari-pinned-tab.svg?v=2023-07-07" color="#FF053C">
<link rel="manifest" href="/static/site.webmanifest?v=2023-07-07">
+ <link rel="stylesheet" href="{% static 'surveys/hosted-survey.css' %}">
<meta name="apple-mobile-web-app-title" content="{{ name }}">
<meta name="application-name" content="{{ name }}">
<title>{{ name }}</title>
<meta name="description" content="{{ name }}">
- <style>
- :root {
- --ph-survey-page-background: #ffffff;
- --ph-survey-page-text: #111111;
- --ph-survey-page-text-subtle: #6b6b6b;
- --ph-survey-page-progress-track: rgba(17, 17, 17, 0.08);
- --ph-survey-page-progress-bar: #111111;
- --ph-survey-progress-value: 0%;
- --ph-survey-page-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
- --ph-survey-card-shadow: 0 1px 2px rgba(17, 17, 17, 0.04), 0 2px 8px rgba(17, 17, 17, 0.04);
- --ph-survey-pill-background: rgba(255, 255, 255, 0.7);
- }
-
- * {
- box-sizing: border-box;
- }
-
- html,
- body {
- margin: 0;
- padding: 0;
- background: var(--ph-survey-page-background);
- color: var(--ph-survey-page-text);
- font-family: var(--ph-survey-page-font);
- font-size: 16px;
- line-height: 1.5;
- -webkit-font-smoothing: antialiased;
- text-rendering: optimizeLegibility;
- }
-
- body {
- min-height: 100vh;
- }
-
- body,
- button,
- input,
- textarea,
- a {
- touch-action: manipulation;
- }
-
- .main-container {
- min-height: 100vh;
- display: flex;
- flex-direction: column;
- padding: clamp(1.5rem, 4vw, 2.5rem) clamp(1.25rem, 4vw, 2.5rem);
- }
-
- .survey-progress-wrap {
- width: 100%;
- max-width: 44rem;
- margin: 0 auto;
- }
-
- .survey-stage {
- width: 100%;
- max-width: 44rem;
- margin: auto;
- display: flex;
- flex-direction: column;
- }
-
- .survey-progress-track {
- width: 100%;
- height: 3px;
- overflow: hidden;
- border-radius: 999px;
- background: var(--ph-survey-page-progress-track);
- }
-
- .survey-progress-bar {
- display: block;
- width: var(--ph-survey-progress-value);
- height: 100%;
- background: var(--ph-survey-page-progress-bar);
- transition: width 240ms cubic-bezier(0.22, 1, 0.36, 1);
- }
-
- #posthog-survey-container {
- display: flex;
- flex-direction: column;
- color: var(--ph-survey-text-primary-color, #111);
- font-family: inherit;
- }
-
- #posthog-survey-container .question-container {
- display: flex;
- flex-direction: column;
- gap: 1.5rem;
- }
-
- #posthog-survey-container .thank-you-message {
- display: flex;
- flex-direction: column;
- align-items: center;
- text-align: center;
- gap: 1.5rem;
- }
-
- #posthog-survey-container .survey-question,
- #posthog-survey-container .thank-you-message-header {
- margin: 0;
- font-size: clamp(1.5rem, 2.4vw, 1.875rem);
- font-weight: 600;
- line-height: 1.25;
- letter-spacing: -0.015em;
- color: var(--ph-survey-text-primary-color, #111);
- text-wrap: balance;
- }
-
- #posthog-survey-container .survey-question-description,
- #posthog-survey-container .thank-you-message-body {
- margin: 0;
- font-size: 0.975rem;
- line-height: 1.6;
- color: var(--ph-survey-text-subtle-color, #6b6b6b);
- }
-
- #posthog-survey-container .survey-question-description strong,
- #posthog-survey-container .thank-you-message strong {
- color: var(--ph-survey-text-primary-color, #111);
- }
-
- #posthog-survey-container fieldset {
- min-width: 0;
- margin: 0;
- padding: 0;
- border: none;
- }
-
- #posthog-survey-container legend {
- padding: 0;
- }
-
- #posthog-survey-container .response-choice {
- flex: 1;
- min-width: 0;
- display: flex;
- align-items: center;
- gap: 0.75rem;
- }
-
- #posthog-survey-container textarea,
- #posthog-survey-container input[type='text'] {
- width: 100%;
- padding: 0.875rem 1rem;
- border: 1px solid var(--ph-survey-border-color, rgba(17, 17, 17, 0.10));
- border-radius: var(--ph-survey-border-radius, 10px);
- background: var(--ph-survey-input-background, #fff);
- color: var(--ph-survey-input-text-color, #111);
- font: inherit;
- font-size: 1rem;
- line-height: 1.5;
- box-shadow: var(--ph-survey-card-shadow);
- transition: border-color 160ms ease, box-shadow 160ms ease;
- }
-
- #posthog-survey-container textarea {
- resize: vertical;
- min-height: 8rem;
- }
-
- #posthog-survey-container textarea::placeholder,
- #posthog-survey-container input[type='text']::placeholder {
- color: var(--ph-survey-text-subtle-color, #6b6b6b);
- opacity: 0.65;
- }
-
- #posthog-survey-container textarea:focus-visible,
- #posthog-survey-container input[type='text']:focus-visible {
- outline: none;
- border-color: var(--ph-survey-rating-active-bg-color, #111);
- box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.10), var(--ph-survey-card-shadow);
- }
-
- #posthog-survey-container .validation-hint {
- margin-top: 0.5rem;
- font-size: 0.825rem;
- color: var(--ph-survey-text-subtle-color, #6b6b6b);
- }
-
- #posthog-survey-container .multiple-choice-options {
- display: flex;
- flex-direction: column;
- gap: 0.5rem;
- margin: 0;
- padding: 0;
- }
-
- #posthog-survey-container .multiple-choice-options label {
- display: flex;
- flex-direction: column;
- gap: 0.625rem;
- min-height: 3rem;
- padding: 0.875rem 1rem;
- border: 1px solid var(--ph-survey-border-color, rgba(17, 17, 17, 0.10));
- border-radius: var(--ph-survey-border-radius, 10px);
- background: var(--ph-survey-input-background, #fff);
- color: var(--ph-survey-input-text-color, #111);
- cursor: pointer;
- font-size: 0.975rem;
- box-shadow: var(--ph-survey-card-shadow);
- transition: border-color 140ms ease, background-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
- }
-
- #posthog-survey-container .multiple-choice-options label:has(input:checked) {
- border-color: var(--ph-survey-rating-active-bg-color, #111);
- box-shadow: inset 0 0 0 1px var(--ph-survey-rating-active-bg-color, #111), var(--ph-survey-card-shadow);
- }
-
- #posthog-survey-container .multiple-choice-options label:has(input:focus-visible) {
- outline: none;
- box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.12);
- }
-
- #posthog-survey-container .multiple-choice-options input[type='checkbox'],
- #posthog-survey-container .multiple-choice-options input[type='radio'] {
- appearance: none;
- -webkit-appearance: none;
- width: 1.1rem;
- height: 1.1rem;
- margin: 0;
- flex-shrink: 0;
- position: relative;
- border: 1.5px solid rgba(17, 17, 17, 0.28);
- background: #ffffff;
- cursor: pointer;
- transition: border-color 140ms ease, background-color 140ms ease;
- }
-
- #posthog-survey-container .multiple-choice-options input[type='checkbox'] {
- border-radius: 4px;
- }
-
- #posthog-survey-container .multiple-choice-options input[type='radio'] {
- border-radius: 999px;
- }
-
- #posthog-survey-container .multiple-choice-options input[type='checkbox']:focus-visible,
- #posthog-survey-container .multiple-choice-options input[type='radio']:focus-visible {
- outline: none;
- box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.12);
- }
-
- #posthog-survey-container .multiple-choice-options input[type='checkbox']:checked,
- #posthog-survey-container .multiple-choice-options input[type='radio']:checked {
- border-color: var(--ph-survey-rating-active-bg-color, #111);
- background: var(--ph-survey-rating-active-bg-color, #111);
- }
-
- #posthog-survey-container .multiple-choice-options input[type='checkbox']:checked::after,
- #posthog-survey-container .multiple-choice-options input[type='radio']:checked::after {
- content: '';
- position: absolute;
- box-sizing: content-box;
- }
-
- #posthog-survey-container .multiple-choice-options input[type='checkbox']:checked::after {
- top: 0.05rem;
- left: 0.3rem;
- width: 0.22rem;
- height: 0.5rem;
- border: solid var(--ph-survey-rating-active-text-color, #fff);
- border-width: 0 2px 2px 0;
- transform: rotate(45deg);
- }
-
- #posthog-survey-container .multiple-choice-options input[type='radio']:checked::after {
- top: 0.27rem;
- left: 0.27rem;
- width: 0.32rem;
- height: 0.32rem;
- border-radius: 999px;
- background: var(--ph-survey-rating-active-text-color, #fff);
- }
-
- #posthog-survey-container .choice-option-open input[type='text'] {
- margin-left: calc(1.1rem + 0.75rem);
- width: calc(100% - 1.85rem);
- }
-
- #posthog-survey-container .rating-section {
- display: flex;
- flex-direction: column;
- gap: 0.625rem;
- }
-
- #posthog-survey-container .rating-options-number {
- display: grid;
- grid-auto-flow: column;
- grid-auto-columns: 1fr;
- gap: 0.4rem;
- }
-
- #posthog-survey-container .ratings-number {
- min-height: 3rem;
- padding: 0.75rem 0;
- border: 1px solid var(--ph-survey-border-color, rgba(17, 17, 17, 0.10));
- border-radius: var(--ph-survey-border-radius, 10px);
- background: var(--ph-survey-rating-bg-color, #f1efea);
- color: var(--ph-survey-rating-text-color, #111);
- font: inherit;
- font-size: 1rem;
- font-weight: 600;
- cursor: pointer;
- box-shadow: var(--ph-survey-card-shadow);
- transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
- }
-
- #posthog-survey-container .ratings-number.rating-active {
- background: var(--ph-survey-rating-active-bg-color, #111);
- color: var(--ph-survey-rating-active-text-color, #fff);
- border-color: var(--ph-survey-rating-active-bg-color, #111);
- }
-
- #posthog-survey-container .rating-options-emoji {
- display: flex;
- justify-content: space-between;
- gap: 0.5rem;
- }
-
- #posthog-survey-container .ratings-emoji {
- min-width: 2.75rem;
- min-height: 2.75rem;
- padding: 0;
- border: none;
- border-radius: 999px;
- background: transparent;
- opacity: 0.5;
- cursor: pointer;
- transition: opacity 140ms ease, background-color 140ms ease;
- }
-
- #posthog-survey-container .ratings-emoji.rating-active {
- opacity: 1;
- background: rgba(17, 17, 17, 0.06);
- }
-
- #posthog-survey-container .ratings-emoji svg {
- fill: var(--ph-survey-text-primary-color, #111);
- }
-
- #posthog-survey-container .rating-text {
- display: flex;
- justify-content: space-between;
- gap: 1rem;
- color: var(--ph-survey-text-subtle-color, #6b6b6b);
- font-size: 0.825rem;
- }
-
- #posthog-survey-container .bottom-section {
- display: flex;
- flex-direction: row;
- align-items: center;
- flex-wrap: wrap;
- gap: 0.875rem 1rem;
- margin-top: 2rem;
- }
-
- #posthog-survey-container .form-submit {
- min-width: 10rem;
- min-height: 3rem;
- padding: 0.75rem 1.75rem;
- border: none;
- border-radius: var(--ph-survey-border-radius, 10px);
- cursor: pointer;
- user-select: none;
- background: var(--ph-survey-submit-button-color, #111);
- color: var(--ph-survey-submit-button-text-color, #fff);
- font: inherit;
- font-size: 1rem;
- font-weight: 600;
- box-shadow: none;
- transition: opacity 140ms ease, transform 140ms ease, background-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
- }
-
- #posthog-survey-container .form-submit:focus-visible {
- outline: none;
- box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.12);
- }
-
- #posthog-survey-container .form-submit[disabled] {
- background: transparent;
- color: var(--ph-survey-text-subtle-color, #6b6b6b);
- box-shadow: inset 0 0 0 1px var(--ph-survey-border-color, rgba(17, 17, 17, 0.10));
- cursor: not-allowed;
- opacity: 1;
- }
-
- #posthog-survey-container .footer-branding {
- position: fixed;
- bottom: 1.25rem;
- right: 1.25rem;
- display: inline-flex;
- align-items: center;
- gap: 0.35rem;
- padding: 0.4rem 0.7rem;
- border-radius: 999px;
- background: var(--ph-survey-pill-background);
- backdrop-filter: blur(8px);
- -webkit-backdrop-filter: blur(8px);
- box-shadow: 0 1px 2px rgba(17, 17, 17, 0.04), 0 4px 14px rgba(17, 17, 17, 0.06);
- color: var(--ph-survey-page-text-subtle, #6b6b6b);
- font-size: 0.72rem;
- font-weight: 500;
- text-decoration: none;
- opacity: 0.75;
- transition: opacity 140ms ease;
- z-index: 10;
- }
-
- #posthog-survey-container .footer-branding:hover {
- opacity: 1;
- }
-
- #posthog-survey-container .footer-branding svg {
- width: auto;
- height: 0.85rem;
- }
-
- @media (max-width: 640px) {
- #posthog-survey-container .footer-branding {
- bottom: 0.75rem;
- right: 0.75rem;
- }
- }
-
- .loading {
- flex: 1;
- min-height: 16rem;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- gap: 0.75rem;
- color: var(--ph-survey-page-text-subtle);
- text-align: center;
- }
-
- .loading-spinner {
- width: 2rem;
- height: 2rem;
- border-radius: 999px;
- border: 2px solid rgba(17, 17, 17, 0.1);
- border-top-color: var(--ph-survey-page-text);
- animation: spin 800ms linear infinite;
- }
-
- .loading-text {
- margin: 0;
- font-size: 0.9rem;
- }
-
- #posthog-survey-container:has(.question-container) .loading,
- #posthog-survey-container:has(.thank-you-message) .loading {
- display: none;
- }
-
- .sr-only {
- position: absolute;
- width: 1px;
- height: 1px;
- padding: 0;
- margin: -1px;
- overflow: hidden;
- clip: rect(0, 0, 0, 0);
- white-space: nowrap;
- border: 0;
- }
-
- /* Hidden by default; shown on hover-capable devices via media query below. */
- #posthog-survey-container .survey-keyhint {
- display: none;
- align-items: center;
- gap: 1rem;
- color: var(--ph-survey-text-subtle-color, #6b6b6b);
- font-size: 0.84rem;
- pointer-events: none;
- user-select: none;
- }
-
- #posthog-survey-container .survey-keyhint-row {
- display: inline-flex;
- align-items: center;
- gap: 0.4rem;
- }
-
- #posthog-survey-container .survey-kbd {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- min-width: 1.7rem;
- height: 1.7rem;
- padding: 0 0.45rem;
- border-radius: 6px;
- border: 1px solid var(--ph-survey-border-color, rgba(17, 17, 17, 0.10));
- background: var(--ph-survey-rating-bg-color, var(--ph-survey-input-background, rgba(17, 17, 17, 0.06)));
- color: var(--ph-survey-text-primary-color, #111);
- font-family: inherit;
- font-size: 0.88rem;
- font-weight: 500;
- line-height: 1;
- font-variant-numeric: tabular-nums;
- box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 1px 2px rgba(17, 17, 17, 0.12);
- }
-
- #posthog-survey-container .survey-keyhint-label {
- color: var(--ph-survey-text-subtle-color, #6b6b6b);
- font-weight: 400;
- letter-spacing: 0.01em;
- }
-
- @media (hover: hover) and (pointer: fine) {
- #posthog-survey-container .survey-keyhint {
- display: inline-flex;
- }
-
- #posthog-survey-container .multiple-choice-options label:hover:not(:has(input:checked)) {
- border-color: rgba(17, 17, 17, 0.22);
- transform: translateY(-1px);
- }
-
- #posthog-survey-container .ratings-number:hover:not(.rating-active) {
- border-color: rgba(17, 17, 17, 0.22);
- transform: translateY(-1px);
- }
-
- #posthog-survey-container .form-submit:hover:not([disabled]) {
- opacity: 0.92;
- transform: translateY(-1px);
- }
- }
-
- @media (max-width: 640px) {
- .main-container {
- padding: 1.25rem;
- padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
- }
-
- #posthog-survey-container .form-submit {
- width: 100%;
- min-width: 0;
- }
-
- #posthog-survey-container .survey-question,
- #posthog-survey-container .thank-you-message-header {
- font-size: 1.5rem;
- }
- }
-
- @media (prefers-reduced-motion: reduce) {
- *,
- *::before,
- *::after {
- animation-duration: 0.01ms !important;
- animation-iteration-count: 1 !important;
- transition-duration: 0.01ms !important;
- scroll-behavior: auto !important;
- }
- }
-
- @keyframes spin {
- to {
- transform: rotate(360deg);
- }
- }
-
- html.embed-mode body {
- min-height: auto;
- background: transparent;
- }
-
- html.embed-mode .main-container {
- min-height: auto;
- padding: 0;
- }
-
- html.embed-mode .survey-progress-track {
- margin-bottom: 1.5rem;
- }
- </style>
{% if embed_mode %}
<script nonce="{{ request.csp_nonce }}">
document.addEventListener('DOMContentLoaded', function() {
@@ -612,7 +32,7 @@
{% endif %}
</head>
-<body>
+<body class="PostHogHostedSurvey">
<div class="main-container">
<div class="survey-progress-wrap">
<div
@@ -648,7 +68,7 @@
const displayLanguage = JSON.parse(document.getElementById("display-language").textContent);
// Defaults tuned for the standalone hosted survey page. Customer-supplied
- // appearance values always win — we only fill in fields they didn't customize,
+ // appearance values always win. We only fill in fields they didn't customize,
// overriding posthog-js's popup-oriented defaults (gray bg, dark border, etc).
const HOSTED_SURVEY_DEFAULTS = {
backgroundColor: '#ffffff',
@@ -667,9 +87,9 @@
}
// posthog-js doesn't set --ph-survey-* vars on the hosted page path,
- // so we replicate them on :root from the merged appearance object.
+ // so we replicate them on the hosted page scope from the merged appearance object.
function applyPageAppearance(appearance) {
- const root = document.documentElement
+ const root = document.querySelector('.PostHogHostedSurvey') || document.documentElement
if (appearance.backgroundColor) {
root.style.setProperty('--ph-survey-page-background', appearance.backgroundColor)
@@ -765,7 +185,8 @@
function updateProgress(percentage) {
const normalized = Math.max(0, Math.min(100, Math.round(percentage)))
- document.documentElement.style.setProperty('--ph-survey-progress-value', normalized + '%')
+ const root = document.querySelector('.PostHogHostedSurvey') || document.documentElement
+ root.style.setProperty('--ph-survey-progress-value', normalized + '%')
const progressTrack = document.getElementById('survey-progress-track')
if (progressTrack) {
progressTrack.setAttribute('aria-valuenow', String(normalized))