import React from 'react';
import configureStore from 'redux-mock-store';
import { Provider } from 'react-intl-redux';
import type { Meta, StoryObj } from '@storybook/react';
import PersonPill from '@kitconcept/volto-plate/components/PersonPill/PersonPill';
const mockStore = configureStore();
//To demonstrate the "explicit portrait" path in Storybook.
const personImage =
'data:image/svg+xml;utf8,' +
encodeURIComponent(
``,
);
const withStore = (disableProfileLinks = false) => {
const store = mockStore({
site: {
data: { 'kitconcept.clickable_profile_links': disableProfileLinks },
},
intl: {
locale: 'en',
messages: {},
},
});
const Decorator = (Story: React.ComponentType) => (
);
return Decorator;
};
const meta: Meta = {
title: 'Components/PersonPill',
component: PersonPill,
decorators: [withStore()],
parameters: {
docs: {
description: {
component:
'Unified person representation: portrait + name, ' +
'optionally linked to a profile. Covers Plone users, the Person content ' +
'type, compact pills and normal-sized bylines/footers.',
},
},
},
argTypes: {
id: { control: 'text' },
fullname: { control: 'text' },
name: { control: 'text' },
portrait: { control: 'text' },
url: { control: 'text' },
compact: { control: 'boolean' },
background: { control: 'color' },
kicker: { control: 'text' },
subheading: { control: 'text' },
},
};
export default meta;
type Story = StoryObj;
// Use case 1: Plone user — no URL → not clickable.
export const PloneUser: Story = {
args: {
id: 'anna',
fullname: 'Anna Becker',
},
};
// Use case 2: Person content type — explicit portrait + URL linking to profile.
export const PersonContentType: Story = {
args: {
id: 'ben',
fullname: 'Ben Yilmaz',
portrait: personImage,
url: '/persons/ben',
},
};
// Use case 3: compact pill — smaller variant for inline mentions.
export const CompactPill: Story = {
args: {
id: 'clara',
fullname: 'Clara Nguyen',
portrait: personImage,
url: '/persons/clara',
compact: true,
},
};
// Use case 4: byline / footer — normal size (default).
export const Byline: Story = {
args: {
id: 'david',
fullname: 'David Schmidt',
url: '/persons/david',
},
};
// Use case 5: shared background — portrait + name in one rounded pill.
export const WithBackground: Story = {
args: {
id: 'frida',
fullname: 'Frida Lang',
portrait: personImage,
url: '/persons/frida',
background: '#eee',
},
};
// Compact + background together.
export const CompactWithBackground: Story = {
args: {
id: 'greta',
fullname: 'Greta Vogel',
portrait: personImage,
compact: true,
background: '#eee',
},
};
// Use case 6: kicker label above name (author / responsible bylines).
export const WithKicker: Story = {
args: {
id: 'nils',
fullname: 'Nils Vogl',
portrait: personImage,
url: '/persons/nils',
kicker: 'Autor/in',
},
};
// Use case 7: subheading below name (comment dates, activity headers, etc.).
export const WithSubheading: Story = {
args: {
id: 'sarah',
fullname: 'Dr. Sarah Köhler',
portrait: personImage,
url: '/persons/sarah',
subheading: 'vor 2 Std.',
},
};
// Icon fallback when no portrait resolves.
export const IconFallback: Story = {
args: {
id: 'eva',
fullname: 'Eva Roth',
},
};
// Profile links disabled site-wide → renders as plain text even with a URL.
export const ProfileLinksDisabled: Story = {
decorators: [withStore(true)],
args: {
id: 'ben',
fullname: 'Ben Yilmaz',
portrait: personImage,
url: '/persons/ben',
},
};