[Glitch] Allow revealing blocked/muted accounts in a collection
Port 02deb0b238 to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
1 parent
9177a3e807
commit
2e70474cde
4 files changed
+286
-7
No files matched your search
@@ -0,0 +1,82 @@
|
||||
import classNames from 'classnames';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import classes from './styles.module.scss';
|
||||
|
||||
interface WrapperProps extends Omit<
|
||||
React.ComponentPropsWithoutRef<'div'>,
|
||||
'title'
|
||||
> {
|
||||
icon?: React.ReactNode;
|
||||
iconEnd?: React.ReactNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* A basic list item component that can be used as a base for more bespoke list items.
|
||||
*
|
||||
* Depending on functionality, use `ListItemButton` or `ListItemLink` as a child of the
|
||||
* wrapper component.
|
||||
*/
|
||||
export const ListItemWrapper: React.FC<WrapperProps> = ({
|
||||
icon,
|
||||
iconEnd,
|
||||
children,
|
||||
className,
|
||||
...otherProps
|
||||
}) => {
|
||||
return (
|
||||
<div {...otherProps} className={classNames(classes.wrapper, className)}>
|
||||
{icon}
|
||||
<div>{children}</div>
|
||||
{iconEnd && <span className={classes.iconEnd}>{iconEnd}</span>}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
interface LinkProps extends React.ComponentPropsWithoutRef<typeof Link> {
|
||||
subtitle?: React.ReactNode;
|
||||
}
|
||||
|
||||
export const ListItemLink: React.FC<LinkProps> = ({
|
||||
subtitle,
|
||||
children,
|
||||
className,
|
||||
...otherProps
|
||||
}) => {
|
||||
return (
|
||||
<>
|
||||
<h3 className={classes.title}>
|
||||
<Link className={classNames(className, 'focusable')} {...otherProps}>
|
||||
{children}
|
||||
</Link>
|
||||
</h3>
|
||||
{subtitle && <div className={classes.subtitle}>{subtitle}</div>}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
interface ButtonProps extends React.ComponentPropsWithoutRef<'button'> {
|
||||
subtitle?: React.ReactNode;
|
||||
}
|
||||
|
||||
export const ListItemButton: React.FC<ButtonProps> = ({
|
||||
subtitle,
|
||||
children,
|
||||
className,
|
||||
...otherProps
|
||||
}) => {
|
||||
return (
|
||||
<>
|
||||
<h3 className={classes.title}>
|
||||
<button
|
||||
type='button'
|
||||
className={classNames(className, 'focusable')}
|
||||
{...otherProps}
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
</h3>
|
||||
{subtitle && <div className={classes.subtitle}>{subtitle}</div>}
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite';
|
||||
|
||||
import ChevronRightIcon from '@/material-icons/400-24px/chevron_right.svg?react';
|
||||
import KeyboardArrowDownIcon from '@/material-icons/400-24px/keyboard_arrow_down.svg?react';
|
||||
import VisibilityIcon from '@/material-icons/400-24px/visibility.svg?react';
|
||||
import VisibilityOffIcon from '@/material-icons/400-24px/visibility_off.svg?react';
|
||||
|
||||
import { Icon } from '../icon';
|
||||
|
||||
import { ListItemWrapper, ListItemButton, ListItemLink } from './index';
|
||||
|
||||
const meta = {
|
||||
title: 'Components/ListItem',
|
||||
component: ListItemWrapper,
|
||||
subcomponents: { ListItemButton, ListItemLink },
|
||||
} satisfies Meta<typeof ListItemWrapper>;
|
||||
|
||||
export default meta;
|
||||
|
||||
type Story = StoryObj<typeof meta>;
|
||||
|
||||
export const WithButton: Story = {
|
||||
render: () => (
|
||||
<ListItemWrapper
|
||||
icon={<Icon icon={VisibilityOffIcon} id='visibility' />}
|
||||
iconEnd={<Icon icon={KeyboardArrowDownIcon} id='down' />}
|
||||
>
|
||||
<ListItemButton subtitle='You’ve blocked or muted these users'>
|
||||
3 hidden accounts
|
||||
</ListItemButton>
|
||||
</ListItemWrapper>
|
||||
),
|
||||
};
|
||||
|
||||
export const WithLink: Story = {
|
||||
render: () => (
|
||||
<ListItemWrapper
|
||||
icon={<Icon icon={VisibilityIcon} id='visibility' />}
|
||||
iconEnd={<Icon icon={ChevronRightIcon} id='right' />}
|
||||
>
|
||||
<ListItemLink to='/'>View more</ListItemLink>
|
||||
</ListItemWrapper>
|
||||
),
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
.wrapper {
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
gap: 12px;
|
||||
padding: 16px;
|
||||
font-size: 15px;
|
||||
color: var(--color-text-primary);
|
||||
}
|
||||
|
||||
.title {
|
||||
font-weight: 500;
|
||||
|
||||
:any-link,
|
||||
button {
|
||||
padding: 0;
|
||||
border: none;
|
||||
color: inherit;
|
||||
background: none;
|
||||
font: inherit;
|
||||
text-decoration: none;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
font-size: 13px;
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.iconEnd {
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
Reference in new issue
Block a user