gov-gui
Version:
Gov UI Component Library Typscript Build
148 lines (147 loc) • 6.17 kB
JavaScript
import { html } from "lit-html";
import "../../global/animate.min.css";
/**
* Avatars represent users or entities visually. They can display a user's profile picture or initials,
* with optional status badges, notifications, and selection states.
*/
export default {
title: 'Components/Avatar',
tags: ['autodocs'],
parameters: {
actions: {
handles: ['click'], // Track click actions for the avatar
},
},
argTypes: {
imgUrl: {
control: 'text',
description: 'The profile picture URL to display in the avatar.',
table: {
type: { summary: 'string' },
defaultValue: { summary: '' },
category: 'Attributes',
},
},
initials: {
control: 'text',
description: 'Fallback initials to display if no image is provided.',
table: {
type: { summary: 'string' },
defaultValue: { summary: '' },
category: 'Attributes',
},
},
hasNotification: {
control: 'boolean',
description: 'Displays a notification badge on the avatar if set to true.',
table: {
type: { summary: 'boolean' },
defaultValue: { summary: 'false' },
category: 'Attributes',
},
},
notificationCount: {
control: 'number',
description: 'The number of notifications to display in the badge.',
table: {
type: { summary: 'number' },
defaultValue: { summary: '0' },
category: 'Attributes',
},
},
status: {
control: 'select',
options: ['online', 'offline', 'busy'],
description: 'Displays a status badge to indicate the user\'s availability (online, offline, busy).',
table: {
type: { summary: 'string' },
defaultValue: { summary: 'null' },
category: 'Attributes',
},
},
size: {
control: 'select',
options: ['small', 'medium', 'large'],
description: 'Controls the avatar size.',
table: {
type: { summary: 'string' },
defaultValue: { summary: 'medium' },
category: 'Attributes',
},
},
animation: {
control: 'select',
options: ["",
"bounce", "flash", "pulse", "rubberBand", "shakeX", "shakeY", "headShake", "swing", "tada", "wobble", "jello", "heartBeat",
"backInDown", "backInLeft", "backInRight", "backInUp",
"backOutDown", "backOutLeft", "backOutRight", "backOutUp",
"bounceIn", "bounceInDown", "bounceInLeft", "bounceInRight", "bounceInUp",
"bounceOut", "bounceOutDown", "bounceOutLeft", "bounceOutRight", "bounceOutUp",
"fadeIn", "fadeInDown", "fadeInDownBig", "fadeInLeft", "fadeInLeftBig", "fadeInRight", "fadeInRightBig", "fadeInUp", "fadeInUpBig", "fadeInTopLeft", "fadeInTopRight", "fadeInBottomLeft", "fadeInBottomRight",
"fadeOut", "fadeOutDown", "fadeOutDownBig", "fadeOutLeft", "fadeOutLeftBig", "fadeOutRight", "fadeOutRightBig", "fadeOutUp", "fadeOutUpBig", "fadeOutTopLeft", "fadeOutTopRight", "fadeOutBottomRight", "fadeOutBottomLeft",
"flip", "flipInX", "flipInY", "flipOutX", "flipOutY",
"lightSpeedInRight", "lightSpeedInLeft", "lightSpeedOutRight", "lightSpeedOutLeft",
"rotateIn", "rotateInDownLeft", "rotateInDownRight", "rotateInUpLeft", "rotateInUpRight",
"rotateOut", "rotateOutDownLeft", "rotateOutDownRight", "rotateOutUpLeft", "rotateOutUpRight",
"hinge", "jackInTheBox", "rollIn", "rollOut",
"zoomIn", "zoomInDown", "zoomInLeft", "zoomInRight", "zoomInUp",
"zoomOut", "zoomOutDown", "zoomOutLeft", "zoomOutRight", "zoomOutUp",
"slideInDown", "slideInLeft", "slideInRight", "slideInUp",
"slideOutDown", "slideOutLeft", "slideOutRight", "slideOutUp"
],
description: 'Selects the animation effect to apply to the component.',
table: {
type: { summary: 'string' },
defaultValue: { summary: '' },
category: 'Animations',
},
},
animationDelay: {
control: 'select',
options: ["2s", "3s", "4s", "5s"],
description: 'Sets the delay before the animation begins (in seconds).',
table: {
type: { summary: 'string' },
defaultValue: { summary: '2s' },
category: 'Animations',
},
},
animationSpeed: {
control: 'select',
options: ["slow", "slower", "fast", "faster"],
description: 'Controls how quickly the animation plays.',
table: {
type: { summary: 'string' },
defaultValue: { summary: '' },
category: 'Animations',
},
},
},
};
const Template = (args) => html `
<gov-avatar
img-url="${args.imgUrl}"
initials="${args.initials}"
?has-notification="${args.hasNotification}"
notification-count="${args.notificationCount}"
status="${args.status}"
size="${args.size}"
animation-delay="${args.animationDelay}"
animation="${args.animation}"
animation-speed="${args.animationSpeed}"
>
</gov-avatar>
`;
export const Avatar = Template.bind({});
Avatar.args = {
imgUrl: 'https://picsum.photos/400/300', // Example image URL
initials: 'US', // Example initials
hasNotification: false, // Show notification badge
notificationCount: 1, // Display number of notifications
status: 'online', // User status
size: "medium", // Avatar size
animation: '',
animationDelay: '',
animationSpeed: '',
};
//# sourceMappingURL=gov-avatar.stories.js.map