Skip to content

Commit 43ec5d8

Browse files
charlesBochetAdityaPimpalkar
authored andcommitted
Inbox task 2 (twentyhq#991)
* Add ability to properly cast a string, number, null to an integer * Adding Tab UI component * Only trigger chromatic when asked
1 parent e297646 commit 43ec5d8

File tree

4 files changed

+91
-6
lines changed

4 files changed

+91
-6
lines changed

.github/workflows/ci-chromatic.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
pull_request_target:
88
jobs:
99
chromatic-deployment:
10+
if: ${{ github.event.label.name == 'run-chromatic' || github.event_name == 'push' }}
1011
runs-on: ubuntu-latest
1112
env:
1213
REACT_APP_API_URL: http://127.0.0.1:3000/graphql

front/src/modules/ui/chip/components/__stories__/Chip.stories.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ export const Catalog: Story = {
3939
parameters: {
4040
pseudo: { hover: ['.hover'], active: ['.active'] },
4141
catalog: [
42+
{
43+
name: 'states',
44+
values: ['default', 'hover', 'active', 'disabled'],
45+
props: (state: string) =>
46+
state === 'default' ? {} : { className: state },
47+
},
4248
{
4349
name: 'variants',
4450
values: Object.values(ChipVariant),
@@ -54,12 +60,6 @@ export const Catalog: Story = {
5460
values: Object.values(ChipAccent),
5561
props: (accent: ChipAccent) => ({ accent }),
5662
},
57-
{
58-
name: 'states',
59-
values: ['default', 'hover', 'active', 'disabled'],
60-
props: (state: string) =>
61-
state === 'default' ? {} : { className: state },
62-
},
6363
],
6464
},
6565
decorators: [CatalogDecorator],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import * as React from 'react';
2+
import styled from '@emotion/styled';
3+
4+
type OwnProps = {
5+
title: string;
6+
active?: boolean;
7+
className?: string;
8+
onClick?: () => void;
9+
};
10+
11+
const StyledTab = styled.div<{ active?: boolean }>`
12+
align-items: center;
13+
border-bottom: 1px solid ${({ theme }) => theme.border.color.light};
14+
border-color: ${({ theme, active }) =>
15+
active ? theme.border.color.inverted : 'transparent'};
16+
color: ${({ theme, active }) =>
17+
active ? theme.font.color.primary : theme.font.color.secondary};
18+
19+
cursor: pointer;
20+
display: flex;
21+
justify-content: center;
22+
padding: ${({ theme }) => theme.spacing(2) + ' ' + theme.spacing(4)};
23+
24+
&:hover,
25+
&:active {
26+
border-color: ${({ theme }) => theme.border.color.inverted};
27+
color: ${({ theme }) => theme.font.color.primary};
28+
}
29+
`;
30+
31+
export function Tab({ title, active = false, onClick, className }: OwnProps) {
32+
return (
33+
<StyledTab onClick={onClick} active={active} className={className}>
34+
{title}
35+
</StyledTab>
36+
);
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
3+
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator';
4+
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
5+
6+
import { Tab } from '../Tab';
7+
8+
const meta: Meta<typeof Tab> = {
9+
title: 'UI/Tab/Tab',
10+
component: Tab,
11+
};
12+
13+
export default meta;
14+
type Story = StoryObj<typeof Tab>;
15+
16+
export const Default: Story = {
17+
args: {
18+
title: 'Tab title',
19+
active: false,
20+
},
21+
decorators: [ComponentDecorator],
22+
};
23+
24+
export const Catalog: Story = {
25+
args: { title: 'Tab title' },
26+
argTypes: {
27+
active: { control: false },
28+
onClick: { control: false },
29+
},
30+
parameters: {
31+
pseudo: { hover: ['.hover'], active: ['.active'] },
32+
catalog: [
33+
{
34+
name: 'states',
35+
values: ['default', 'hover', 'active'],
36+
props: (state: string) =>
37+
state === 'default' ? {} : { className: state },
38+
},
39+
{
40+
name: 'Active',
41+
values: ['true', 'false'],
42+
props: (active: string) => ({ active: active === 'true' }),
43+
},
44+
],
45+
},
46+
decorators: [CatalogDecorator],
47+
};

0 commit comments

Comments
 (0)