Button Component
const primaryButton = new ComponentKit.Button({
text: 'Primary Button',
variant: 'primary',
onClick: () => alert('Primary clicked!')
});
primaryButton.render('#container');
Input Component
Email Input with Validation
const emailInput = new ComponentKit.Input({
type: 'email',
label: 'Email Address',
placeholder: 'user@example.com',
required: true,
validation: { email: true }
});
emailInput.render('#container');
Card Component
const card = new ComponentKit.Card({
title: 'Card Title',
content: 'This is the card content.',
variant: 'elevated',
actions: [
{ text: 'Action 1', onClick: () => alert('Action 1!') },
{ text: 'Action 2', variant: 'secondary' }
]
});
card.render('#container');
ProgressGift Component
const progressGift = new ComponentKit.ProgressGift({
maxPoints: 100,
giftIcon: '🎁',
onGiftEarned: (gifts, points) => {
console.log(`Поздравляем! Подарок #${gifts} получен!`);
console.log(`Осталось очков: ${points}`);
}
});
// Добавить очки
progressGift.addPoints(25);
// Рендер
progressGift.render('#container');
Modal Component
const modal = new ComponentKit.Modal({
title: 'Confirm Action',
content: 'Are you sure you want to proceed?',
size: 'medium',
actions: [
{ text: 'Cancel', variant: 'secondary' },
{ text: 'Confirm', variant: 'primary', onClick: () => alert('Confirmed!') }
]
});
modal.open();
Complete Form Example
// Create a complete form with validation
const form = document.createElement('form');
const nameInput = new ComponentKit.Input({
label: 'Full Name',
placeholder: 'Enter your name',
required: true
});
const emailInput = new ComponentKit.Input({
type: 'email',
label: 'Email',
placeholder: 'user@example.com',
validation: { email: true }
});
const submitButton = new ComponentKit.Button({
text: 'Submit Form',
variant: 'primary',
onClick: () => validateAndSubmit()
});
// Render components
nameInput.render(form);
emailInput.render(form);
submitButton.render(form);