Add spoiler UI component
This commit is contained in:
parent
ea67a18962
commit
6aba41c3d9
3 changed files with 51 additions and 0 deletions
|
@ -27,6 +27,7 @@ export * from './select';
|
|||
export * from './skeleton';
|
||||
export * from './slider';
|
||||
export * from './spinner';
|
||||
export * from './spoiler';
|
||||
export * from './switch';
|
||||
export * from './tabs';
|
||||
export * from './text';
|
||||
|
|
41
src/renderer/components/spoiler/index.tsx
Normal file
41
src/renderer/components/spoiler/index.tsx
Normal file
|
@ -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>
|
||||
);
|
||||
};
|
9
src/renderer/components/spoiler/spoiler.module.scss
Normal file
9
src/renderer/components/spoiler/spoiler.module.scss
Normal file
|
@ -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 a new issue