export function faqFeedback(form: FormTs) {
// FAQ Usefulness Feedback Form
// Demonstrates: ThumbRating, EmojiRating, SuggestionChips, Slider,
// conditional visibility, dynamic labels, compact widget design
// ============================================
// HEADER
// ============================================
form.addRow(row => {
row.addTextPanel('header', {
label: 'Was this article helpful?',
computedValue: () => 'Your feedback helps us improve our help center.',
customStyles: {
backgroundColor: '#f8fafc',
color: '#475569',
padding: '16px 20px',
borderRadius: '12px 12px 0 0',
textAlign: 'center',
borderBottom: '1px solid #e2e8f0'
}
});
});
// ============================================
// QUICK RATING SECTION
// ============================================
const ratingSection = form.addSubform('ratingSection', {
customStyles: {
backgroundColor: '#ffffff',
padding: '20px',
borderRadius: '0 0 12px 12px',
border: '1px solid #e2e8f0',
borderTop: 'none'
}
});
ratingSection.addRow(row => {
row.addThumbRating('wasHelpful', {
label: '',
showLabels: true,
upLabel: 'Yes, helpful!',
downLabel: 'Not really',
size: 'lg',
alignment: 'center'
});
});
// ============================================
// POSITIVE FEEDBACK PATH (Thumbs Up)
// ============================================
const positiveSection = form.addSubform('positiveSection', {
title: 'Great! Tell us more',
isVisible: () => ratingSection.thumbRating('wasHelpful')?.value() === 'up',
customStyles: {
backgroundColor: '#ecfdf5',
padding: '16px',
borderRadius: '8px',
marginTop: '16px'
}
});
positiveSection.addRow(row => {
row.addSuggestionChips('whatHelped', {
label: 'What did you find most helpful?',
suggestions: [
{ id: 'clear', name: 'Clear explanations' },
{ id: 'examples', name: 'Good examples' },
{ id: 'complete', name: 'Complete answer' },
{ id: 'easyFind', name: 'Easy to find' },
{ id: 'stepByStep', name: 'Step-by-step guide' },
{ id: 'images', name: 'Helpful images' }
],
max: 3,
alignment: 'center'
});
});
positiveSection.addRow(row => {
row.addEmojiRating('articleQuality', {
label: 'Rate the overall article quality',
preset: 'satisfaction',
size: 'md',
alignment: 'center'
});
});
// ============================================
// NEGATIVE FEEDBACK PATH (Thumbs Down)
// ============================================
const negativeSection = form.addSubform('negativeSection', {
title: 'Sorry to hear that',
isVisible: () => ratingSection.thumbRating('wasHelpful')?.value() === 'down',
customStyles: {
backgroundColor: '#fef2f2',
padding: '16px',
borderRadius: '8px',
marginTop: '16px'
}
});
negativeSection.addRow(row => {
row.addSuggestionChips('issues', {
label: 'What was the problem?',
suggestions: [
{ id: 'outdated', name: 'Outdated information' },
{ id: 'incomplete', name: 'Missing steps' },
{ id: 'confusing', name: 'Confusing content' },
{ id: 'wrong', name: 'Incorrect info' },
{ id: 'notRelevant', name: 'Not what I needed' },
{ id: 'tooTechnical', name: 'Too technical' }
],
alignment: 'center'
});
});
negativeSection.addRow(row => {
row.addRadioButton('foundElsewhere', {
label: 'Did you find your answer elsewhere?',
options: [
{ id: 'yes', name: 'Yes, I figured it out' },
{ id: 'support', name: 'I contacted support' },
{ id: 'no', name: 'Still looking for help' }
],
orientation: 'vertical'
});
});
negativeSection.addSpacer({ height: '16px' });
negativeSection.addRow(row => {
row.addTextarea('missingInfo', {
label: 'What information were you looking for?',
placeholder: 'Describe what you expected to find...',
rows: 3,
autoExpand: true
});
});
// ============================================
// CONTENT IMPROVEMENT SECTION
// ============================================
const improvementSection = form.addSubform('improvementSection', {
title: 'Help Us Improve',
isVisible: () => ratingSection.thumbRating('wasHelpful')?.value() !== null,
customStyles: {
backgroundColor: '#f8fafc',
padding: '16px',
borderRadius: '8px',
marginTop: '16px'
}
});
improvementSection.addRow(row => {
row.addSlider('contentClarity', {
label: 'How clear was the content?',
min: 1,
max: 5,
step: 1,
showValue: true,
defaultValue: 3
}, '1fr');
row.addSlider('contentCompleteness', {
label: 'How complete was the answer?',
min: 1,
max: 5,
step: 1,
showValue: true,
defaultValue: 3
}, '1fr');
});
improvementSection.addRow(row => {
row.addMatrixQuestion('contentAspects', {
label: 'Rate specific aspects:',
rows: [
{ id: 'accuracy', label: 'Information accuracy' },
{ id: 'organization', label: 'Content organization' },
{ id: 'relevance', label: 'Relevance to my question' }
],
columns: [
{ id: 'poor', label: 'Poor' },
{ id: 'ok', label: 'OK' },
{ id: 'good', label: 'Good' },
{ id: 'great', label: 'Great' }
],
fullWidth: true
});
});
// ============================================
// MISSING TOPICS SECTION
// ============================================
const topicsSection = form.addSubform('topicsSection', {
title: 'Missing Topics',
isVisible: () => ratingSection.thumbRating('wasHelpful')?.value() !== null,
customStyles: {
padding: '16px',
borderRadius: '8px',
marginTop: '16px',
border: '1px dashed #cbd5e1'
}
});
topicsSection.addRow(row => {
row.addCheckboxList('wantedTopics', {
label: 'What topics should we add to our FAQ?',
options: [
{ id: 'troubleshooting', name: 'More troubleshooting guides' },
{ id: 'advanced', name: 'Advanced use cases' },
{ id: 'integration', name: 'Integration tutorials' },
{ id: 'video', name: 'Video tutorials' },
{ id: 'comparison', name: 'Feature comparisons' },
{ id: 'bestPractices', name: 'Best practices' }
],
orientation: 'vertical'
});
});
topicsSection.addSpacer({ height: '12px' });
topicsSection.addRow(row => {
row.addTextbox('suggestTopic', {
label: 'Suggest a specific topic or question',
placeholder: 'What would you like us to write about?'
});
});
// ============================================
// SEARCH EXPERIENCE
// ============================================
const searchSection = form.addSubform('searchSection', {
title: 'Finding Content',
isVisible: () => ratingSection.thumbRating('wasHelpful')?.value() !== null
});
searchSection.addRow(row => {
row.addRatingScale('findDifficulty', {
label: 'How easy was it to find this article?',
preset: 'ces',
alignment: 'center'
});
});
searchSection.addRow(row => {
row.addRadioButton('howFound', {
label: 'How did you find this article?',
options: [
{ id: 'search', name: 'Site search' },
{ id: 'browse', name: 'Browsing categories' },
{ id: 'google', name: 'Google search' },
{ id: 'link', name: 'Link from another page' },
{ id: 'support', name: 'Support agent shared it' }
],
orientation: 'vertical'
});
});
// ============================================
// SUMMARY SECTION
// ============================================
const summarySection = form.addSubform('summarySection', {
title: 'Feedback Summary',
isVisible: () => ratingSection.thumbRating('wasHelpful')?.value() !== null
});
summarySection.addRow(row => {
row.addTextPanel('summaryPanel', {
computedValue: () => {
const helpful = ratingSection.thumbRating('wasHelpful')?.value();
const clarity = improvementSection.slider('contentClarity')?.value() ?? 3;
const completeness = improvementSection.slider('contentCompleteness')?.value() ?? 3;
const emoji = helpful === 'up' ? '👍' : helpful === 'down' ? '👎' : '🤔';
let summary = `${emoji} Feedback Summary\n`;
summary += `${'─'.repeat(25)}\n`;
summary += `Helpful: ${helpful === 'up' ? 'Yes' : helpful === 'down' ? 'No' : 'Not rated'}\n`;
summary += `Clarity: ${'★'.repeat(clarity)}${'☆'.repeat(5 - clarity)}\n`;
summary += `Completeness: ${'★'.repeat(completeness)}${'☆'.repeat(5 - completeness)}`;
return summary;
},
customStyles: () => {
const helpful = ratingSection.thumbRating('wasHelpful')?.value();
return {
padding: '16px',
borderRadius: '8px',
whiteSpace: 'pre-wrap',
fontFamily: 'monospace',
fontSize: '13px',
backgroundColor: helpful === 'up' ? '#dcfce7' : helpful === 'down' ? '#fef2f2' : '#f8fafc',
borderLeft: helpful === 'up' ? '4px solid #22c55e' : helpful === 'down' ? '4px solid #ef4444' : '4px solid #94a3b8'
};
}
});
});
// ============================================
// FORM CONFIGURATION
// ============================================
form.configureSubmitButton({
label: () => {
const helpful = ratingSection.thumbRating('wasHelpful')?.value();
if (helpful === 'up') return 'Send Feedback';
if (helpful === 'down') return 'Submit & Help Us Improve';
return 'Submit Feedback';
},
isVisible: () => ratingSection.thumbRating('wasHelpful')?.value() !== null
});
form.configureCompletionScreen({
type: 'text',
title: () => {
const helpful = ratingSection.thumbRating('wasHelpful')?.value();
if (helpful === 'up') return 'Thanks for the feedback!';
return 'We appreciate your input!';
},
message: () => {
const helpful = ratingSection.thumbRating('wasHelpful')?.value();
if (helpful === 'up') {
return 'Your positive feedback helps us know what content works. We\'ll keep improving!';
}
return 'Your feedback helps us create better content. Our team will review your suggestions.';
}
});
}