Skip to content

Commit

Permalink
feat(Tab): add story and throw rest props to main component element
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-shaposhnik committed Jan 18, 2021
1 parent c113f5e commit 0c8a1ec
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
6 changes: 2 additions & 4 deletions packages/ui/src/core/tab/tab.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ const Tab = intrinsicComponent<TabProps, HTMLDivElement>((
{...rest}
className={`${className}${active ? ' active' : ''}`}
>
<Styled.Tab {...rest} className={`${className}${active ? ' active' : ''}`}>
{icon && <Styled.Icon>{icon}</Styled.Icon>}
{label && <Styled.Label>{label}</Styled.Label>}
</Styled.Tab>
{icon && <Styled.Icon>{icon}</Styled.Icon>}
{label && <Styled.Label>{label}</Styled.Label>}
</Styled.Tab>
));

Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/core/tab/tab.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Tab = styled.div.attrs({
({ theme: { palette, typography: { font } } }: WithTheme) => css`
${font['label-normal']}
position: relative;
display: flex;
display: inline-flex;
align-items: center;
text-align: center;
color: ${palette[PColor.TextPrimary]};
Expand Down
36 changes: 35 additions & 1 deletion packages/ui/stories/core/tab.story.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
// TODO
import React from 'react';
import type { Meta, Story } from '@storybook/react';
import AssetsIcon from '@scaleflex/icons/assets';
import _Tab, { TabProps } from '../../src/core/tab';
import { StoryGroup } from './types';

export const Tab = _Tab;

export default {
title: `${StoryGroup.DataDisplay}/Tab`,
component: Tab,
excludeStories: ['Tab'],
} as Meta;

const defaultArgs = {
label: 'Assets',
icon: <AssetsIcon size={10} />,
};

const BasicTemplate: Story<TabProps> = ({
...args
}) => (
<Tab {...args} />
);

// Basic
export const Basic = BasicTemplate.bind({});
Basic.args = { ...defaultArgs };

// Active
export const Active = BasicTemplate.bind({});
Active.args = {
...defaultArgs,
active: true,
};

0 comments on commit 0c8a1ec

Please sign in to comment.