2023-01-25 16:54:32 +00:00
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { Story } from '@storybook/react' ;
import React from 'react' ;
import { ListTile } from './ListTile' ;
import type { Props } from './ListTile' ;
import { CircleCheckbox } from './CircleCheckbox' ;
2023-04-20 17:03:43 +00:00
import { UserText } from './UserText' ;
2023-01-25 16:54:32 +00:00
export default {
title : 'Components/ListTile' ,
component : ListTile ,
} ;
const lorem =
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam feugiat quam vitae semper facilisis. Praesent eu efficitur dui. Donec semper mattis nisl non hendrerit.' ;
function TemplateList ( width : number ) : Story < Props > {
// eslint-disable-next-line react/display-name
return args = > {
return (
< div
style = { {
width ,
height : 400 ,
overflow : 'auto' ,
outline : '1px solid gray' ,
} }
>
< ListTile
{ . . . args }
subtitle = "Checkbox"
trailing = { < CircleCheckbox / > }
clickable
/ >
< ListTile
{ . . . args }
subtitle = "Checkbox"
trailing = { < CircleCheckbox checked / > }
clickable
/ >
< ListTile { ...args } trailing = { undefined } / >
< ListTile { ...args } title = { ` Long title - ${ lorem } ` } / >
< ListTile { ...args } subtitle = "Disabled" disabled / >
< ListTile
{ . . . args }
2023-04-20 17:03:43 +00:00
title = { < UserText text = "Emoji in title 📞" / > }
2023-01-25 16:54:32 +00:00
subtitle = "Clickable"
clickable
/ >
< ListTile
{ . . . args }
2023-04-20 17:03:43 +00:00
title = { < UserText text = "With a LOT of emoji 🚗" / > }
2023-01-25 16:54:32 +00:00
subtitle = {
2023-04-20 17:03:43 +00:00
< UserText text = "😂, 😃, 🧘🏻♂️, 🌍, 🌦️, 🍞, 🚗, 📞, 🎉, ❤️, 🍆, 🍑 and 🏁" / >
2023-01-25 16:54:32 +00:00
}
/ >
< ListTile
{ . . . args }
subtitle = { ` One line max - ${ lorem } ` }
subtitleMaxLines = { 1 }
/ >
< ListTile
{ . . . args }
subtitle = { ` Two lines max - ${ lorem } ` }
subtitleMaxLines = { 2 }
/ >
< ListTile
{ . . . args }
subtitle = { ` Three lines max - ${ lorem } ` }
subtitleMaxLines = { 3 }
/ >
< ListTile
{ . . . args }
subtitle = "Button root element"
rootElement = "button"
/ >
< / div >
) ;
} ;
}
const circleAvatar = (
< div
style = { { borderRadius : '100%' , background : 'gray' , width : 36 , height : 36 } }
/ >
) ;
export const Item = TemplateList ( 400 ) . bind ( { } ) ;
Item . args = {
leading : circleAvatar ,
2023-04-20 17:03:43 +00:00
title : < UserText text = "Some user" / > ,
2023-01-25 16:54:32 +00:00
subtitle : 'Hello my friend' ,
clickable : true ,
} ;
export const PanelRow = TemplateList ( 800 ) . bind ( { } ) ;
PanelRow . args = {
leading : circleAvatar ,
title : 'Some user' ,
subtitle : 'Hello my friend' ,
trailing : < div className = "ConversationDetails-panel-row__right" > Admin < / div > ,
clickable : false ,
variant : 'panelrow' ,
} ;