mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
Add spoiler UI component
This commit is contained in:
@@ -27,6 +27,7 @@ export * from './select';
|
|||||||
export * from './skeleton';
|
export * from './skeleton';
|
||||||
export * from './slider';
|
export * from './slider';
|
||||||
export * from './spinner';
|
export * from './spinner';
|
||||||
|
export * from './spoiler';
|
||||||
export * from './switch';
|
export * from './switch';
|
||||||
export * from './tabs';
|
export * from './tabs';
|
||||||
export * from './text';
|
export * from './text';
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import { ReactNode } from 'react';
|
||||||
|
import { Spoiler as MantineSpoiler } from '@mantine/core';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import styles from './spoiler.module.scss';
|
||||||
|
|
||||||
|
type SpoilerProps = {
|
||||||
|
children: ReactNode;
|
||||||
|
hideLabel?: boolean;
|
||||||
|
initialState?: boolean;
|
||||||
|
maxHeight: number;
|
||||||
|
showLabel?: ReactNode;
|
||||||
|
transitionDuration?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Spoiler = ({
|
||||||
|
hideLabel,
|
||||||
|
initialState,
|
||||||
|
maxHeight,
|
||||||
|
showLabel,
|
||||||
|
transitionDuration,
|
||||||
|
children,
|
||||||
|
}: SpoilerProps) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<MantineSpoiler
|
||||||
|
classNames={{
|
||||||
|
content: styles.content,
|
||||||
|
control: styles.control,
|
||||||
|
root: styles.root,
|
||||||
|
}}
|
||||||
|
hideLabel={hideLabel ?? t('common.collapse', { postProcess: 'sentenceCase' })}
|
||||||
|
initialState={initialState}
|
||||||
|
maxHeight={maxHeight ?? 75}
|
||||||
|
showLabel={showLabel ?? t('common.expand', { postProcess: 'sentenceCase' })}
|
||||||
|
transitionDuration={transitionDuration}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</MantineSpoiler>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
.control {
|
||||||
|
color: var(--btn-subtle-fg);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.control:hover {
|
||||||
|
color: var(--btn-subtle-fg-hover);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user