Skip to content

Commit

Permalink
feat: changed type for TabsItem label prop to accept also components …
Browse files Browse the repository at this point in the history
…and fixed problem with Label 'htmlFor' attribute in Fields
  • Loading branch information
soslayando committed Nov 11, 2024
1 parent 197667b commit cb95779
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/core/src/components/Flex/Flex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const InternalFlex = React.forwardRef<HTMLElement, Resolve<FlexProps>>(
alignItems,
childrenFlex,
columnGap,
display,
flex,
flexDirection,
flexWrap,
Expand All @@ -41,6 +42,7 @@ const InternalFlex = React.forwardRef<HTMLElement, Resolve<FlexProps>>(
alignItems,
childrenFlex,
columnGap,
display,
flex,
flexDirection,
flexWrap,
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/components/Flex/mixins.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { css, DefaultTheme } from 'styled-components';
import type { ILayoutFlexCss } from '../../declarations';
import type { ILayoutBox, ILayoutFlexCss } from '../../declarations';

import { getSpacingPropCss } from '../../helpers';

export interface IFlexMixin extends ILayoutFlexCss {
display?: ILayoutBox['display'];
theme: DefaultTheme;
}

Expand All @@ -17,6 +18,7 @@ export const flexMixin = ({
alignItems,
childrenFlex,
columnGap,
display,
flex,
flexDirection,
flexWrap,
Expand All @@ -26,7 +28,7 @@ export const flexMixin = ({
rowGap,
theme,
}: IFlexMixin) => css`
display: ${inline ? 'inline-flex' : 'flex'};
display: ${display || (inline ? 'inline-flex' : 'flex')};
align-content: ${alignContent};
align-items: ${alignItems};
flex: ${flex};
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/components/Tabs/components/Docs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ The `Tabs.Item` component is used to define the individual tabs.

<Canvas of={ItemStories.Item} />

### With badge

<Canvas of={ItemStories.WithBadge} />

### Props

<ArgTypes of={ItemStories} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { Meta, StoryObj } from '@storybook/react';

import { Tabs } from '../../Tabs';
import * as React from 'react';
import { useTabsAccessibility } from '../../hooks';
import { GIChart, GICheckThick } from '@devoinc/genesys-icons';
import { Box } from '../../../Box';
import { Badge } from '../../../Badge';

const meta: Meta<typeof Tabs.Item> = {
title: 'Components/Navigation/Tabs/Components',
Expand All @@ -16,3 +21,28 @@ export default meta;
type Story = StoryObj<typeof Tabs.Item>;

export const Item: Story = {};

export const WithBadge: Story = {
name: 'With badge',
tags: ['isHidden'],
render: () =>
(() => {
return (
<Tabs.Item
icon={<GIChart />}
label={
<>
Tiny
<Box
position="absolute"
positionTop="-0.8rem"
positionRight="-0.4rem"
>
<Badge size="sm" colorScheme="warning" />
</Box>
</>
}
/>
);
})(),
};
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface TabsItemProps
/** This property defines the icon type */
icon?: IconProps['children'];
/** Tab label */
label: string;
label: React.ReactNode;
/** Action when click on close tab button */
onClose?: () => void;
/** Possible states */
Expand Down

0 comments on commit cb95779

Please sign in to comment.