export function visualFeedbackSurvey(form: FormTs) {
// Visual Design Feedback - A/B testing and aesthetics evaluation
// Demonstrates: RadioButton, RatingScale (Likert), Slider, EmojiRating, MatrixQuestion, SuggestionChips, conditional logic
// ============================================
// HEADER
// ============================================
form.addRow(row => {
row.addTextPanel('header', {
label: 'Visual Design Feedback',
computedValue: () => 'Help us create designs that delight you.',
customStyles: {
background: 'linear-gradient(135deg, #8b5cf6 0%, #a855f7 100%)',
color: 'white',
padding: '28px',
borderRadius: '16px',
textAlign: 'center',
fontSize: '15px'
}
});
});
// ============================================
// SECTION 1: Design Preference Test
// ============================================
const preferenceSection = form.addSubform('preferenceSection', {
title: 'Design Preference',
customStyles: { backgroundColor: '#faf5ff', padding: '20px', borderRadius: '12px' }
});
preferenceSection.addRow(row => {
row.addTextPanel('designContext', {
computedValue: () => 'Based on the design you just viewed, please share your thoughts.',
customStyles: {
color: '#6b7280',
fontStyle: 'italic',
marginBottom: '12px'
}
});
});
preferenceSection.addRow(row => {
row.addRadioButton('overallPreference', {
label: 'Which design direction do you prefer?',
options: [
{ id: 'option-a', name: 'Design A (Current/Control)' },
{ id: 'option-b', name: 'Design B (New Variant)' },
{ id: 'no-preference', name: 'No strong preference' }
],
orientation: 'vertical',
isRequired: true
});
});
preferenceSection.addRow(row => {
row.addSlider('preferenceStrength', {
label: 'How strongly do you prefer your choice?',
min: 1,
max: 10,
step: 1,
showValue: true,
defaultValue: 5,
isVisible: () => {
const pref = preferenceSection.radioButton('overallPreference')?.value();
return pref === 'option-a' || pref === 'option-b';
}
});
});
preferenceSection.addRow(row => {
row.addTextPanel('strengthLabel', {
computedValue: () => {
const strength = preferenceSection.slider('preferenceStrength')?.value();
if (!strength) return '';
if (strength <= 3) return 'Slight preference';
if (strength <= 6) return 'Moderate preference';
if (strength <= 8) return 'Strong preference';
return 'Very strong preference';
},
customStyles: {
textAlign: 'center',
color: '#6b7280',
fontSize: '14px'
},
isVisible: () => preferenceSection.slider('preferenceStrength')?.value() !== null
});
});
// ============================================
// SECTION 2: First Impression & Emotion
// ============================================
const emotionSection = form.addSubform('emotionSection', {
title: 'First Impression',
isVisible: () => preferenceSection.radioButton('overallPreference')?.value() !== null
});
emotionSection.addRow(row => {
row.addEmojiRating('emotionalResponse', {
label: 'What was your emotional response to the design?',
preset: 'mood',
size: 'lg',
showLabels: true,
alignment: 'center'
});
});
emotionSection.addRow(row => {
row.addSuggestionChips('designWords', {
label: 'Select words that describe the design (choose up to 5):',
suggestions: [
{ id: 'modern', name: 'Modern' },
{ id: 'clean', name: 'Clean' },
{ id: 'professional', name: 'Professional' },
{ id: 'friendly', name: 'Friendly' },
{ id: 'bold', name: 'Bold' },
{ id: 'elegant', name: 'Elegant' },
{ id: 'playful', name: 'Playful' },
{ id: 'trustworthy', name: 'Trustworthy' },
{ id: 'innovative', name: 'Innovative' },
{ id: 'cluttered', name: 'Cluttered' },
{ id: 'confusing', name: 'Confusing' },
{ id: 'dated', name: 'Dated' }
],
max: 5,
alignment: 'center'
});
});
// ============================================
// SECTION 3: Aesthetic Ratings
// ============================================
const aestheticsSection = form.addSubform('aestheticsSection', {
title: 'Design Elements',
isVisible: () => preferenceSection.radioButton('overallPreference')?.value() !== null,
customStyles: { backgroundColor: '#f8fafc', padding: '20px', borderRadius: '12px' }
});
aestheticsSection.addRow(row => {
row.addMatrixQuestion('elementRatings', {
label: 'Rate these design elements:',
rows: [
{ id: 'colors', label: 'Color scheme', isRequired: true },
{ id: 'typography', label: 'Typography/Fonts', isRequired: true },
{ id: 'layout', label: 'Layout/Structure', isRequired: true },
{ id: 'imagery', label: 'Images/Graphics', isRequired: false },
{ id: 'whitespace', label: 'Use of white space', isRequired: false },
{ id: 'consistency', label: 'Visual consistency', isRequired: false }
],
columns: [
{ id: '1', label: 'Poor' },
{ id: '2', label: 'Fair' },
{ id: '3', label: 'Good' },
{ id: '4', label: 'Very Good' },
{ id: '5', label: 'Excellent' }
],
striped: true,
fullWidth: true
});
});
// ============================================
// SECTION 4: Overall Visual Appeal
// ============================================
const appealSection = form.addSubform('appealSection', {
title: 'Overall Visual Appeal',
isVisible: () => preferenceSection.radioButton('overallPreference')?.value() !== null
});
appealSection.addRow(row => {
row.addRatingScale('visualAppeal', {
label: 'How visually appealing is this design?',
preset: 'likert-7',
lowLabel: 'Not at all appealing',
highLabel: 'Extremely appealing',
variant: 'buttons',
size: 'md',
alignment: 'center'
});
});
appealSection.addRow(row => {
row.addRatingScale('brandFit', {
label: 'How well does this design fit what you expect from the brand?',
preset: 'likert-5',
lowLabel: 'Does not fit at all',
highLabel: 'Fits perfectly',
variant: 'segmented',
size: 'md',
alignment: 'center'
});
});
// ============================================
// SECTION 5: Usability Perception
// ============================================
const usabilitySection = form.addSubform('usabilitySection', {
title: 'Usability Perception',
isVisible: () => preferenceSection.radioButton('overallPreference')?.value() !== null
});
usabilitySection.addRow(row => {
row.addStarRating('easyToNavigate', {
label: 'The design looks easy to navigate',
maxStars: 5,
size: 'md',
showCounter: true,
alignment: 'left'
}, '1fr');
row.addStarRating('clearHierarchy', {
label: 'Information hierarchy is clear',
maxStars: 5,
size: 'md',
showCounter: true,
alignment: 'left'
}, '1fr');
});
usabilitySection.addRow(row => {
row.addStarRating('findableElements', {
label: 'Key elements are easy to find',
maxStars: 5,
size: 'md',
showCounter: true,
alignment: 'left'
}, '1fr');
row.addStarRating('readability', {
label: 'Text is easy to read',
maxStars: 5,
size: 'md',
showCounter: true,
alignment: 'left'
}, '1fr');
});
// ============================================
// SECTION 6: Specific Feedback
// ============================================
const feedbackSection = form.addSubform('feedbackSection', {
title: 'Detailed Feedback',
isVisible: () => preferenceSection.radioButton('overallPreference')?.value() !== null
});
feedbackSection.addRow(row => {
row.addThumbRating('wouldShare', {
label: 'Would you share or show this design to others?',
size: 'md',
showLabels: true,
upLabel: 'Yes, I would share it',
downLabel: 'Probably not',
alignment: 'center'
});
});
feedbackSection.addRow(row => {
row.addCheckboxList('improvements', {
label: 'What would you improve? (Select all that apply)',
options: [
{ id: 'colors', name: 'Color choices' },
{ id: 'fonts', name: 'Font selection or size' },
{ id: 'spacing', name: 'Spacing and layout' },
{ id: 'images', name: 'Images or graphics' },
{ id: 'buttons', name: 'Button styles' },
{ id: 'contrast', name: 'Contrast/Readability' },
{ id: 'simplify', name: 'Simplify the design' },
{ id: 'more-visual', name: 'Add more visual interest' },
{ id: 'nothing', name: 'Nothing - it\'s great!' }
],
orientation: 'vertical'
});
});
feedbackSection.addSpacer({ height: '16px' });
feedbackSection.addRow(row => {
row.addTextarea('openFeedback', {
label: () => {
const pref = preferenceSection.radioButton('overallPreference')?.value();
if (pref === 'option-a') return 'Why do you prefer the current design?';
if (pref === 'option-b') return 'What do you like about the new design?';
return 'Any other thoughts on the design?';
},
placeholder: 'Share specific aspects you like or would change...',
rows: 4,
autoExpand: true
});
});
// ============================================
// SECTION 7: Summary
// ============================================
const summarySection = form.addSubform('summary', {
title: 'Feedback Summary',
isVisible: () => {
const pref = preferenceSection.radioButton('overallPreference')?.value();
const appeal = appealSection.ratingScale('visualAppeal')?.value();
return pref !== null && appeal !== null;
}
});
summarySection.addRow(row => {
row.addTextPanel('summaryContent', {
computedValue: () => {
const preference = preferenceSection.radioButton('overallPreference')?.value();
const strength = preferenceSection.slider('preferenceStrength')?.value();
const emotion = emotionSection.emojiRating('emotionalResponse')?.value();
const words = emotionSection.suggestionChips('designWords')?.value() || [];
const appeal = appealSection.ratingScale('visualAppeal')?.value();
const brandFit = appealSection.ratingScale('brandFit')?.value();
const improvements = feedbackSection.checkboxList('improvements')?.value() || [];
const prefLabels: Record<string, string> = {
'option-a': 'Design A (Current)',
'option-b': 'Design B (New)',
'no-preference': 'No preference'
};
const emotionLabels: Record<string, string> = {
'sad': '😢 Sad',
'down': '😔 Down',
'neutral': '😐 Neutral',
'happy': '😊 Happy',
'excited': '🤩 Excited'
};
let summary = '🎨 Visual Feedback Summary\n';
summary += `${'═'.repeat(30)}\n\n`;
summary += `🎯 Preference: ${prefLabels[preference || ''] || preference}\n`;
if (strength && preference !== 'no-preference') {
summary += `💪 Strength: ${strength}/10\n`;
}
if (emotion) {
summary += `\n😊 Emotion: ${emotionLabels[emotion] || emotion}`;
}
if (appeal) {
summary += `\n⭐ Visual Appeal: ${appeal}/7`;
}
if (brandFit) {
summary += `\n🏷️ Brand Fit: ${brandFit}/5`;
}
if (words.length > 0) {
summary += `\n\n📝 Design Words: ${words.join(', ')}`;
}
if (improvements.length > 0 && !improvements.includes('nothing')) {
summary += `\n\n🔧 Improvements: ${improvements.length} areas noted`;
}
return summary;
},
customStyles: () => {
const preference = preferenceSection.radioButton('overallPreference')?.value();
const baseStyles = {
padding: '20px',
borderRadius: '12px',
whiteSpace: 'pre-wrap',
fontFamily: 'monospace',
fontSize: '14px'
};
if (preference === 'option-b') {
return { ...baseStyles, backgroundColor: '#faf5ff', borderLeft: '4px solid #8b5cf6' };
} else if (preference === 'option-a') {
return { ...baseStyles, backgroundColor: '#ecfdf5', borderLeft: '4px solid #10b981' };
}
return { ...baseStyles, backgroundColor: '#f8fafc', borderLeft: '4px solid #94a3b8' };
}
});
});
// ============================================
// FORM CONFIGURATION
// ============================================
form.configureSubmitButton({
label: 'Submit Design Feedback',
isVisible: () => preferenceSection.radioButton('overallPreference')?.value() !== null
});
form.configureCompletionScreen({
type: 'text',
title: 'Thank You for Your Design Feedback!',
message: 'Your visual preferences and insights help us create designs that truly resonate. We use feedback like yours to make data-driven design decisions.'
});
}