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

fix(surveys): polishing the popup survey UI #1279

Merged
merged 4 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 7 additions & 1 deletion src/extensions/surveys/components/QuestionTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ export function RatingQuestion({
onClick={() => {
setRating(idx + 1)
}}
style={{
fill: active
? appearance.ratingButtonActiveColor
: appearance.ratingButtonColor,
borderColor: appearance.borderColor,
}}
>
{emoji}
</button>
Expand Down Expand Up @@ -195,7 +201,7 @@ export function RatingButton({
num: number
active: boolean
displayQuestionIndex: number
appearance: any
appearance: SurveyAppearance
setActiveNumber: (num: number) => void
}) {
const { textColor, ref } = useContrastingTextColor({ appearance, defaultTextColor: 'black', forceUpdate: active })
Expand Down
60 changes: 26 additions & 34 deletions src/extensions/surveys/surveys-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const style = (appearance: SurveyAppearance | null) => {
`,
}
return `
.survey-form {
.survey-form, .thank-you-message {
position: fixed;
margin: 0px;
bottom: 0px;
Expand All @@ -25,24 +25,34 @@ export const style = (appearance: SurveyAppearance | null) => {
font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "Roboto", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
text-align: left;
max-width: ${parseInt(appearance?.maxWidth || '300')}px;
width: 100%;
z-index: ${parseInt(appearance?.zIndex || '99999')};
border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};
border-bottom: 0px;
width: 100%;
${positions[appearance?.position || 'right'] || 'right: 30px;'}
}
.form-submit[disabled] {
opacity: 0.6;
filter: grayscale(50%);
cursor: not-allowed;
}
.survey-form {
flex-direction: column;
background: ${appearance?.backgroundColor || '#eeeded'};
border-top-left-radius: 10px;
border-top-right-radius: 10px;
box-shadow: -6px 0 16px -8px rgb(0 0 0 / 8%), -9px 0 28px 0 rgb(0 0 0 / 5%), -12px 0 48px 16px rgb(0 0 0 / 3%);
}

.survey-box, .thank-you-message-container {
padding: 20px 25px 10px;
display: flex;
flex-direction: column;
border-radius: 10px;
}

.thank-you-message {
text-align: center;
}

.form-submit[disabled] {
opacity: 0.6;
filter: grayscale(50%);
cursor: not-allowed;
}
.survey-form textarea {
color: #2d2d2d;
font-size: 14px;
Expand All @@ -57,6 +67,9 @@ export const style = (appearance: SurveyAppearance | null) => {
border-color: ${appearance?.borderColor || '#c9c6c6'};
margin-top: 14px;
}
.survey-box:has(.survey-question:empty):not(:has(.description)) textarea {
margin-top: 0;
}
Comment on lines +70 to +72
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I only want to remove the margin in the event where there's no description (the selector is gone) AND there's no question (the selector is empty). Otherwise, the margins should remain.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm using the :has pseudo-selector ... supported in all major browsers since 2023, but is this a risky change still?

This is fine in my opinion. It's a small styling detail that just won't work in a tiny minority of cases.

.form-submit {
box-sizing: border-box;
margin: 0;
Expand Down Expand Up @@ -118,12 +131,6 @@ export const style = (appearance: SurveyAppearance | null) => {
background: ${appearance?.backgroundColor || '#eeeded'};
text-decoration: none;
}
.survey-box {
padding: 20px 25px 10px;
display: flex;
flex-direction: column;
border-radius: 10px;
}
.survey-question {
font-weight: 500;
font-size: 14px;
Expand All @@ -139,7 +146,6 @@ export const style = (appearance: SurveyAppearance | null) => {
background: ${appearance?.backgroundColor || '#eeeded'};
}
.ratings-number {
background-color: ${appearance?.ratingButtonColor || 'white'};
font-size: 16px;
font-weight: 600;
padding: 8px 0px;
Expand Down Expand Up @@ -183,7 +189,7 @@ export const style = (appearance: SurveyAppearance | null) => {
fill: ${appearance?.ratingButtonActiveColor || 'black'};
}
.emoji-svg {
fill: ${appearance?.ratingButtonColor || '#c9c6c6'};
fill: '#939393';
}
.rating-text {
display: flex;
Expand All @@ -198,6 +204,9 @@ export const style = (appearance: SurveyAppearance | null) => {
margin-top: 13px;
font-size: 14px;
}
.survey-box:has(.survey-question:empty):not(:has(.description)) .multiple-choice-options {
margin-top: 0;
}
.multiple-choice-options .choice-option {
display: flex;
align-items: center;
Expand Down Expand Up @@ -266,23 +275,6 @@ export const style = (appearance: SurveyAppearance | null) => {
border: 0;
outline: 0;
}
.thank-you-message {
position: fixed;
bottom: 0px;
z-index: ${parseInt(appearance?.zIndex || '99999')};
box-shadow: -6px 0 16px -8px rgb(0 0 0 / 8%), -9px 0 28px 0 rgb(0 0 0 / 5%), -12px 0 48px 16px rgb(0 0 0 / 3%);
font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "Roboto", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
border-top-left-radius: 10px;
border-top-right-radius: 10px;
padding: 20px 25px 10px;
background: ${appearance?.backgroundColor || '#eeeded'};
border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};
text-align: center;
max-width: ${parseInt(appearance?.maxWidth || '300')}px;
min-width: 150px;
width: 100%;
${positions[appearance?.position || 'right'] || 'right: 30px;'}
}
.thank-you-message-body {
margin-top: 6px;
font-size: 14px;
Expand Down
Loading