Skip to content

Commit

Permalink
feat(HelpText): add shorthand sizes (#2014)
Browse files Browse the repository at this point in the history
  • Loading branch information
Barsnes authored May 16, 2024
1 parent 50cbb8e commit ad97311
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
6 changes: 3 additions & 3 deletions packages/css/helptext.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@
max-width: 700px;
}

.fds-helptext--small .fds-helptext__icon {
.fds-helptext--sm .fds-helptext__icon {
width: var(--fds-sizing-6);
height: var(--fds-sizing-6);
}

.fds-helptext--medium .fds-helptext__icon {
.fds-helptext--md .fds-helptext__icon {
width: var(--fds-sizing-7);
height: var(--fds-sizing-7);
}

.fds-helptext--large .fds-helptext__icon {
.fds-helptext--lg .fds-helptext__icon {
width: var(--fds-sizing-8);
height: var(--fds-sizing-8);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/HelpText/HelpText.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const Preview: Story = {
args: {
title: 'Help text title',
children: 'Help text content',
size: 'medium',
size: 'md',
},
decorators,
};
Expand All @@ -30,7 +30,7 @@ export const Portal: Story = {
args: {
title: 'Help text title',
children: 'Help text content',
size: 'medium',
size: 'md',
portal: true,
placement: 'top',
},
Expand Down
9 changes: 6 additions & 3 deletions packages/react/src/components/HelpText/HelpText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { Placement } from '@floating-ui/utils';
import { Popover } from '../Popover';
import type { PopoverProps } from '../Popover/Popover';
import type { PortalProps } from '../../types/Portal';
import { getSize } from '../../utilities/getSize';

import { HelpTextIcon } from './HelpTextIcon';

Expand All @@ -15,8 +16,9 @@ export type HelpTextProps = {
**/
title: string;
/**
* Size of the icon.
* @default medium
* Size of the helptext
* @default md
* @note `small`, `medium`, `large` is deprecated
*/
size?: PopoverProps['size'];
/**
Expand All @@ -30,12 +32,13 @@ export type HelpTextProps = {
const HelpText = ({
title,
placement = 'right',
size = 'md',
portal,
className,
children,
...rest
}: HelpTextProps) => {
const size = getSize(rest.size || 'md') as PopoverProps['size'];

const [open, setOpen] = useState(false);

return (
Expand Down

0 comments on commit ad97311

Please sign in to comment.