-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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(surveys): templates #17904
Merged
Merged
feat(surveys): templates #17904
Changes from 10 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
84c00e4
routes for survey templates
liyiy 343a5a4
basic on click setup logic
liyiy 610b11f
Update UI snapshots for `chromium` (2)
github-actions[bot] 725eb46
import type
liyiy e2f4d00
Merge branch 'master' into surveys/templates
liyiy d006c61
Apply suggestions from code review
liyiy f4f0047
Merge branch 'surveys/templates' of https://github.com/PostHog/postho…
liyiy c729606
address feedback from cory
liyiy 8c63bad
fix logic
liyiy 84a068c
remove unused logic file
liyiy c9600e8
Update frontend/src/scenes/surveys/constants.tsx
liyiy 1994686
Update frontend/src/scenes/surveys/constants.tsx
liyiy 3732a91
Merge branch 'master' into surveys/templates
liyiy 55f8744
Merge branch 'surveys/templates' of https://github.com/PostHog/postho…
liyiy d0095eb
address comments
liyiy ce744a9
Update UI snapshots for `chromium` (2)
github-actions[bot] 0ca4d0e
more fixes
liyiy 3739f7e
Merge branch 'surveys/templates' of https://github.com/PostHog/postho…
liyiy 7febe5d
Update UI snapshots for `webkit` (2)
github-actions[bot] cd405b5
Update UI snapshots for `webkit` (2)
github-actions[bot] a617a0e
Update UI snapshots for `chromium` (2)
github-actions[bot] c3e9196
Merge branch 'master' into surveys/templates
liyiy 3150085
Merge branch 'surveys/templates' of https://github.com/PostHog/postho…
liyiy 92fedf7
move description and title together
liyiy f53936b
Merge branch 'master' into surveys/templates
liyiy 027562d
fix e2e
liyiy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file modified
BIN
+1.05 KB
(100%)
frontend/__snapshots__/scenes-app-surveys--surveys-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
@import '../../styles/mixins'; | ||
|
||
.SurveyTemplateContainer { | ||
display: flex; | ||
align-items: center; | ||
border: 1px solid var(--border); | ||
border-radius: 6px; | ||
min-height: 300px; | ||
margin-top: 2px; | ||
|
||
&:hover { | ||
cursor: pointer; | ||
border-color: var(--primary-light); | ||
} | ||
|
||
.SurveyTemplate { | ||
-ms-transform: scale(0.8, 0.8); /* IE 9 */ | ||
-webkit-transform: scale(0.8, 0.8); /* Safari */ | ||
transform: scale(0.8, 0.8); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { SceneExport } from 'scenes/sceneTypes' | ||
import { SurveyAppearance } from './SurveyAppearance' | ||
import { defaultSurveyTemplates } from './constants' | ||
import { SurveyQuestion } from '~/types' | ||
import './SurveyTemplates.scss' | ||
import { useActions } from 'kea' | ||
import { PageHeader } from 'lib/components/PageHeader' | ||
import { LemonButton } from '@posthog/lemon-ui' | ||
import { urls } from 'scenes/urls' | ||
import { surveyLogic } from './surveyLogic' | ||
|
||
export const scene: SceneExport = { | ||
component: SurveyTemplates, | ||
} | ||
|
||
export function SurveyTemplates(): JSX.Element { | ||
const { setSurveyTemplateValues } = useActions(surveyLogic({ id: 'new' })) | ||
|
||
return ( | ||
<> | ||
<PageHeader | ||
title={'New survey'} | ||
buttons={ | ||
<LemonButton type="primary" to={urls.survey('new')} data-attr="new-survey"> | ||
Create blank survey | ||
</LemonButton> | ||
} | ||
/> | ||
<div className="flex flex-row flex-wrap gap-10 ml-8 mt-8"> | ||
{defaultSurveyTemplates.map((template, idx) => { | ||
return ( | ||
<div | ||
className="flex flex-col items-center" | ||
key={idx} | ||
onClick={() => | ||
setSurveyTemplateValues({ name: template.type, questions: template.questions }) | ||
} | ||
> | ||
<span className="mb-2 text-md"> | ||
<b>{template.type}</b> | ||
</span> | ||
<div className="SurveyTemplateContainer"> | ||
<div className="SurveyTemplate"> | ||
<SurveyAppearance | ||
key={idx} | ||
type={template.questions[0].type} | ||
question={template.questions[0].question} | ||
appearance={{ whiteLabel: true }} | ||
surveyQuestionItem={template.questions[0] as SurveyQuestion} | ||
onAppearanceChange={() => {}} | ||
readOnly | ||
/> | ||
</div> | ||
</div> | ||
<span className="flex flex-wrap text-xs text-muted max-w-80 font-medium mt-3"> | ||
{template.description} | ||
</span> | ||
</div> | ||
) | ||
})} | ||
</div> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the new scene for templates doesn't really make sense anymore, since it's on the surveys page itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It actually still routes to
survey_templates
which is its own scene, I was thinking a bit about this on whether to just incorporate it directly onto the surveys components or not but I think a separation of routes is the better option. That way users can always be directed to the templates page instead of it being a "state"