export function documentationFeedbackForm(form: FormTs) {
// Documentation Feedback Form
// Demonstrates: ThumbRating, StarRating, EmojiRating, RatingScale,
// CheckboxList, SuggestionChips, Textarea, multi-page wizard
// ============================================
// PAGES STRUCTURE
// ============================================
const pages = form.addPages('feedbackPages', {
heightMode: 'current-page'
});
// ============================================
// PAGE 1: Quick Feedback
// ============================================
const page1 = pages.addPage('quickFeedback');
page1.addRow(row => {
row.addTextPanel('header', {
label: 'Documentation Feedback',
computedValue: () => 'Help us improve this documentation. Your feedback matters.',
customStyles: {
backgroundColor: '#3b82f6',
color: 'white',
padding: '24px',
borderRadius: '12px',
textAlign: 'center',
fontSize: '15px'
}
});
});
const quickSection = page1.addSubform('quick', {
title: 'Was this page helpful?'
});
quickSection.addRow(row => {
row.addThumbRating('wasHelpful', {
label: '',
showLabels: true,
upLabel: 'Yes, helpful',
downLabel: 'No, needs work',
alignment: 'center',
size: 'lg'
});
});
// Conditional emoji rating based on thumb
quickSection.addSpacer({
height: '16px',
isVisible: () => quickSection.thumbRating('wasHelpful')?.value() !== null
});
quickSection.addRow(row => {
row.addEmojiRating('experience', {
label: () => {
const helpful = quickSection.thumbRating('wasHelpful')?.value();
if (helpful === 'up') return 'How was your documentation experience?';
return 'How frustrated were you?';
},
preset: () => {
const helpful = quickSection.thumbRating('wasHelpful')?.value();
return helpful === 'up' ? 'satisfaction' : 'effort';
},
size: 'lg',
showLabels: true,
alignment: 'center',
isVisible: () => quickSection.thumbRating('wasHelpful')?.value() !== null
});
});
// Navigation for positive feedback - go to page 2
const positiveNav = page1.addSubform('positiveNav', {
isVisible: () => quickSection.thumbRating('wasHelpful')?.value() === 'up'
});
positiveNav.addSpacer({ height: '16px' });
positiveNav.addRow(row => {
row.addButton('toPositiveDetails', {
label: 'Tell us more (optional) →',
onClick: () => pages.goToPage('positiveDetails')
});
});
// Navigation for negative feedback - go to page 3
const negativeNav = page1.addSubform('negativeNav', {
isVisible: () => quickSection.thumbRating('wasHelpful')?.value() === 'down'
});
negativeNav.addSpacer({ height: '16px' });
negativeNav.addRow(row => {
row.addButton('toNegativeDetails', {
label: 'Help us improve →',
onClick: () => pages.goToPage('negativeDetails')
});
});
// ============================================
// PAGE 2: Positive Feedback Details
// ============================================
const page2 = pages.addPage('positiveDetails');
page2.addRow(row => {
row.addTextPanel('positiveHeader', {
label: 'Great to hear!',
computedValue: () => 'Tell us what worked well so we can do more of it.',
customStyles: {
backgroundColor: '#10b981',
color: 'white',
padding: '20px',
borderRadius: '12px',
textAlign: 'center'
}
});
});
const positiveSection = page2.addSubform('positive', {
title: 'What did you like about this documentation?'
});
positiveSection.addRow(row => {
row.addSuggestionChips('whatLiked', {
label: 'Select all that apply',
suggestions: [
{ id: 'clear', name: 'Clear and easy to understand' },
{ id: 'complete', name: 'Complete information' },
{ id: 'examples', name: 'Good code examples' },
{ id: 'organized', name: 'Well organized' },
{ id: 'accurate', name: 'Accurate and up-to-date' },
{ id: 'quick', name: 'Found answer quickly' }
],
alignment: 'center'
});
});
positiveSection.addSpacer({ height: '16px' });
positiveSection.addRow(row => {
row.addStarRating('docQuality', {
label: 'Overall documentation quality',
maxStars: 5,
size: 'lg',
alignment: 'center',
showConfettiOnMax: true,
filledColor: '#10b981'
});
});
const positiveFeedback = page2.addSubform('positiveFeedback', {
title: 'Additional Feedback'
});
positiveFeedback.addRow(row => {
row.addTextarea('positiveComments', {
label: 'Anything else you\'d like to share?',
placeholder: 'Your suggestions for improvement...',
rows: 3,
autoExpand: true
});
});
const positiveNavBack = page2.addSubform('positiveNavBack', {});
positiveNavBack.addRow(row => {
row.addButton('backFromPositive', {
label: '← Back',
onClick: () => pages.goToPage('quickFeedback')
});
});
// ============================================
// PAGE 3: Negative Feedback Details
// ============================================
const page3 = pages.addPage('negativeDetails');
page3.addRow(row => {
row.addTextPanel('negativeHeader', {
label: 'We want to do better',
computedValue: () => 'Help us understand what went wrong so we can fix it.',
customStyles: {
backgroundColor: '#f59e0b',
color: 'white',
padding: '20px',
borderRadius: '12px',
textAlign: 'center'
}
});
});
const issueSection = page3.addSubform('issue', {
title: 'What was the main issue?'
});
issueSection.addRow(row => {
row.addCheckboxList('issueTypes', {
label: 'Select all issues that apply',
options: [
{ id: 'unclear', name: 'Content was unclear or confusing' },
{ id: 'incomplete', name: 'Information was incomplete or missing' },
{ id: 'inaccurate', name: 'Information was inaccurate or outdated' },
{ id: 'examples', name: 'Code examples didn\'t work' },
{ id: 'hard-find', name: 'Hard to find what I needed' },
{ id: 'too-technical', name: 'Too technical / assumed too much' },
{ id: 'too-basic', name: 'Too basic / not enough detail' }
],
orientation: 'vertical',
isRequired: true
});
});
// Conditional follow-ups based on issues selected
const missingSection = page3.addSubform('missing', {
title: 'What information was missing?',
isVisible: () => {
const issues = issueSection.checkboxList('issueTypes')?.value() || [];
return issues.includes('incomplete');
},
customStyles: { backgroundColor: '#fffbeb', padding: '16px', borderRadius: '8px' }
});
missingSection.addRow(row => {
row.addTextarea('missingInfo', {
label: 'Please describe what information you were looking for',
placeholder: 'I was trying to find information about...',
rows: 3,
isRequired: () => {
const issues = issueSection.checkboxList('issueTypes')?.value() || [];
return issues.includes('incomplete');
}
});
});
const inaccurateSection = page3.addSubform('inaccurate', {
title: 'What was inaccurate?',
isVisible: () => {
const issues = issueSection.checkboxList('issueTypes')?.value() || [];
return issues.includes('inaccurate');
},
customStyles: { backgroundColor: '#fef2f2', padding: '16px', borderRadius: '8px' }
});
inaccurateSection.addRow(row => {
row.addTextarea('inaccurateInfo', {
label: 'Please describe what was incorrect',
placeholder: 'The documentation says X but actually...',
rows: 3,
isRequired: () => {
const issues = issueSection.checkboxList('issueTypes')?.value() || [];
return issues.includes('inaccurate');
}
});
});
// Rating and comments
const ratingSection = page3.addSubform('rating', {
title: 'Additional Details'
});
ratingSection.addRow(row => {
row.addRatingScale('clarityRating', {
label: 'How clear was the writing?',
preset: 'likert-5',
lowLabel: 'Very confusing',
highLabel: 'Very clear',
alignment: 'center',
size: 'md'
}, '1fr');
row.addRatingScale('completenessRating', {
label: 'How complete was the information?',
preset: 'likert-5',
lowLabel: 'Missing a lot',
highLabel: 'Very complete',
alignment: 'center',
size: 'md'
}, '1fr');
});
ratingSection.addSpacer({ height: '16px' });
ratingSection.addRow(row => {
row.addTextarea('suggestionBox', {
label: 'How could we improve this documentation?',
placeholder: 'Your specific suggestions...',
rows: 4,
autoExpand: true
});
});
// Contact option
const contactSection = page3.addSubform('contact', {
title: 'Need help?'
});
contactSection.addRow(row => {
row.addCheckbox('wantsFollowUp', {
label: 'I would like someone to follow up with me about this documentation issue'
});
});
contactSection.addRow(row => {
row.addEmail('contactEmail', {
label: 'Your email address',
placeholder: 'email@example.com',
isRequired: () => contactSection.checkbox('wantsFollowUp')?.value() === true,
isVisible: () => contactSection.checkbox('wantsFollowUp')?.value() === true
});
});
const negativeNavBack = page3.addSubform('negativeNavBack', {});
negativeNavBack.addRow(row => {
row.addButton('backFromNegative', {
label: '← Back',
onClick: () => pages.goToPage('quickFeedback')
});
});
// ============================================
// FORM CONFIGURATION
// ============================================
form.configureSubmitButton({
label: () => {
const helpful = quickSection.thumbRating('wasHelpful')?.value();
const page = pages.currentPageIndex();
if (page === 0 && helpful === 'up') return 'Submit Quick Feedback';
if (page === 0 && helpful === 'down') return 'Submit Quick Feedback';
if (page === 1) return 'Submit Positive Feedback';
if (page === 2) return 'Submit Detailed Feedback';
return 'Submit Feedback';
},
isVisible: () => quickSection.thumbRating('wasHelpful')?.value() !== null
});
form.configureCompletionScreen({
type: 'text',
title: () => {
const helpful = quickSection.thumbRating('wasHelpful')?.value();
if (helpful === 'up') return 'Thank you for the positive feedback!';
return 'Thank you for helping us improve!';
},
message: () => {
const helpful = quickSection.thumbRating('wasHelpful')?.value();
if (helpful === 'up') {
return 'Your feedback helps us know what\'s working well. We\'ll keep creating helpful documentation!';
}
return 'We take your feedback seriously and will review the issues you reported. Our technical writing team continuously works to improve our documentation.';
}
});
}