-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathStudioTextfieldToggleView.tsx
37 lines (34 loc) · 1.13 KB
/
StudioTextfieldToggleView.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import React from 'react';
import { PencilIcon } from '@studio/icons';
import { StudioButton, type StudioButtonProps } from '@studio/components';
import classes from './StudioTextfieldToggleView.module.css';
import cn from 'classnames';
export type StudioTextfieldToggleViewProps = Omit<StudioButtonProps, 'icon'> & {
Icon?: React.ComponentType<React.SVGProps<SVGSVGElement>>;
label: string;
};
export const StudioTextfieldToggleView = ({
onClick,
label,
className: givenClass,
Icon,
...rest
}: StudioTextfieldToggleViewProps) => {
const className = cn(classes.button, givenClass);
return (
<StudioButton variant='tertiary' className={className} onClick={onClick} {...rest}>
<span className={classes.viewModeIconsContainer}>
<Icon aria-hidden />
<span className={classes.textContainer}>
{label && (
<span className={classes.label} aria-hidden>
{label}
</span>
)}
<span className={classes.ellipsis}>{rest.value}</span>
</span>
</span>
<PencilIcon className={classes.editIcon} aria-hidden />
</StudioButton>
);
};