Skip to content

Commit

Permalink
feat: add complement to tabs component
Browse files Browse the repository at this point in the history
  • Loading branch information
mathdevelop committed Jun 4, 2024
1 parent d362f89 commit f1da79d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
7 changes: 7 additions & 0 deletions styleguide/src/Components/Tabs/Tabs.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,11 @@ describe(specTitle('Tabs tests'), () => {
.get('span').contains('Cupons de desconto')
})

it('Title complement', () => {
mount(<Default />)
cy.get('.tabs .tabs-item').eq(2).within(() => {
cy.get('span').contains('Todos os relatórios da loja')
cy.get('span').contains('NOVO')
})
})
})
9 changes: 8 additions & 1 deletion styleguide/src/Components/Tabs/Tabs.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Story, Meta } from '@storybook/react'
import { withDesign } from 'storybook-addon-designs'

import { Tabs, TabsProps } from './Tabs'
import { Badge } from '../../Indicators'

export default {
title: 'Components/Tabs',
Expand Down Expand Up @@ -32,7 +33,13 @@ export default {
},
{
id: 'relatorios',
title: 'Todos os relatorio da loja',
title: 'Todos os relatórios da loja',
titleComplement: (
<Badge
text="NOVO"
type="primary"
/>
),
},
{
id: 'vendas',
Expand Down
4 changes: 4 additions & 0 deletions styleguide/src/Components/Tabs/TabsItem.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export interface TabsItemInterface {
* Item visible title
*/
title: string
/**
* Complement to title
* */
titleComplement?: string | React.ReactNode
/**
* Disabled a specific tab
*/
Expand Down
2 changes: 2 additions & 0 deletions styleguide/src/Components/Tabs/TabsItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface TabsItemProps extends TabsItemInterface {
export const TabsItem = ({
id,
title,
titleComplement,
active = false,
disabled = false,
onChange,
Expand All @@ -44,6 +45,7 @@ export const TabsItem = ({
data-title={title}
>
{title}
{titleComplement && <span className="ml-2">{titleComplement}</span>}
</span>
</button>
)
Expand Down

0 comments on commit f1da79d

Please sign in to comment.