Skip to content

Commit

Permalink
Revert "Chore/review components (#93)" (#94)
Browse files Browse the repository at this point in the history
This reverts commit 3e62507.
  • Loading branch information
adrian-potepa authored Nov 6, 2023
1 parent 3e62507 commit 96dade9
Show file tree
Hide file tree
Showing 84 changed files with 328 additions and 626 deletions.
35 changes: 0 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,41 +191,6 @@ If you want to dive deeper into the components Tetrisly offers, check out our of

You can also check out our Storybook, which is our Documentation for React components (now in progress): [Tetrisly Storybook](https://virtuslab.github.io/tetrisly-react/?path=/docs/alertbanner--docs)

## Customization

All Tetrisly components have a `custom` prop. It makes it possible to customize the component without the need to create a new one. Below you can see an example of Button customization

### Button

If you want to change any of button styles, you can make it by passing custom props with object based on
specific component config.

For instance, to change background-color of appereance="primary" intent="secondary" variant to pink, just pass
refferenced object structure:

```jsx
<Button
label="Button label"
appearance="primary"
intent="success"
custom={{
variants: {
appearance: {
primary: {
intent: {
success: {
backgroundColor: 'raspberry-0', // you can also pass any color value not included in default theme
},
},
},
},
},
}}
/>
```

we are still working on it, thanks for your feedback here!

### Useful links

- [Tetrisly Storybook](https://storybook.tetrisly.com/)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"exports": {
".": {
"import": "./dist/tetrisly-react.es.js",
"require": "./dist/tetrisly-react.umd.js"
"require": "./dist/tetrisly-react.umd.cjs"
}
},
"repository": {
Expand Down
9 changes: 1 addition & 8 deletions src/components/AlertBanner/AlertBanner.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ const meta = {
},
],
},
argTypes: {
intent: {
options: ['none', 'success', 'warning', 'negative'],
defaultValue: 'none',
control: { type: 'radio' },
},
},
parameters: {
docs: {
description: {
Expand All @@ -53,7 +46,7 @@ export const Default: Story = {};

export const Positive: Story = {
args: {
intent: 'success',
intent: 'positive',
},
};

Expand Down
10 changes: 5 additions & 5 deletions src/components/AlertBanner/AlertBanner.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const defaultConfig = {
backgroundColor: '$color-background-neutral-strong',
color: '$color-content-primary-inverted',
},
success: {
positive: {
backgroundColor: '$color-background-positive-strong',
color: '$color-content-primary-inverted',
},
Expand Down Expand Up @@ -53,13 +53,13 @@ export const defaultConfig = {
},
} satisfies AlertBannerConfig;

export const resolveIconName = (intent: AlertBannerIntent) => {
const iconConfig = {
export const resolveIconName = (intent: AlertBannerIntent): IconName<20> => {
const iconConfig: Record<AlertBannerIntent, IconName<20>> = {
none: '20-info-fill',
success: '20-check-circle-fill',
positive: '20-info-fill',
warning: '20-warning-fill',
negative: '20-alert-fill',
} satisfies Record<AlertBannerIntent, IconName<20>>;
};

return iconConfig[intent];
};
4 changes: 2 additions & 2 deletions src/components/AlertBanner/AlertBanner.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ describe('AlertBanner', () => {
expect(alertBanner).toHaveStyle('background-color: rgb(85, 95, 109);');
});

it('should render correct intent color (success)', () => {
it('should render correct intent color (positive)', () => {
const alertBanner = getAlertBanner(
<AlertBanner text="Alert" intent="success" />,
<AlertBanner text="Alert" intent="positive" />,
);
expect(alertBanner).toHaveStyle('color: rgb(255,255,255);');
expect(alertBanner).toHaveStyle('background-color: rgb(29, 124, 77);');
Expand Down
2 changes: 1 addition & 1 deletion src/components/AlertBanner/types/AlertBannerIntent.type.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type AlertBannerIntent = 'none' | 'success' | 'warning' | 'negative';
export type AlertBannerIntent = 'none' | 'positive' | 'warning' | 'negative';
5 changes: 1 addition & 4 deletions src/components/Avatar/Avatar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ const meta = {
img: { if: { arg: 'appearance', eq: 'image' } },
initials: { if: { arg: 'appearance', neq: 'image' } },
emphasis: { if: { arg: 'appearance', neq: 'image' } },
appearance: {
options: appearances,
control: { type: 'select' },
},
},
parameters: {
controls: { sort: 'alpha' },
docs: {
description: {
component:
Expand Down
2 changes: 1 addition & 1 deletion src/components/Avatar/Avatar.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const defaultConfig = {
orange: {
emphasis: {
high: {
color: '$color-nonSemantic-grey-content-primary',
color: '$color-nonSemantic-white-content-primary',
backgroundColor: '$color-nonSemantic-orange-background-strong',
},
low: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type FC, useMemo } from 'react';
import { FC, useMemo } from 'react';

import type { AvatarProps } from './Avatar.props';
import { stylesBuilder } from './stylesBuilder';
Expand Down
35 changes: 16 additions & 19 deletions src/components/Avatar/types/AvatarAppearance.type.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
export const avatarAppearanceColors = [
'blue',
'green',
'grey',
'red',
'orange',
'raspberry',
'magenta',
'purple',
'grape',
'violet',
'cyan',
'teal',
'aquamarine',
'emerald',
] as const;
export type AvatarAppearanceColors =
| 'blue'
| 'green'
| 'grey'
| 'red'
| 'orange'
| 'raspberry'
| 'magenta'
| 'purple'
| 'grape'
| 'violet'
| 'cyan'
| 'teal'
| 'aquamarine'
| 'emerald';

export type AvatarAppearanceColors = (typeof avatarAppearanceColors)[number];

export type AvatarAppearance = 'image' | AvatarAppearanceColors;
export type AvatarAppearance = AvatarAppearanceColors | 'image';
9 changes: 0 additions & 9 deletions src/components/Badge/Badge.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Meta, StoryObj } from '@storybook/react';

import { Badge } from './Badge';
import type { BadgeEmphasis } from './BadgeEmphasis.type';

import { BadgeDocs } from '@/docs-components/BadgeDocs';
import { TetDocs } from '@/docs-components/TetDocs';
Expand All @@ -10,14 +9,6 @@ const meta = {
title: 'Badge',
component: Badge,
tags: ['autodocs'],
argTypes: {
emphasis: {
control: {
type: 'select',
options: ['high', 'medium', 'low'] satisfies BadgeEmphasis[],
},
},
},
parameters: {
docs: {
description: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Badge/Badge.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export const defaultConfig = {
},
medium: {
border: '1px solid',
borderColor: '$color-nonSemantic-grey-border-subtle',
borderColor: '$color-nonSemantic-grey-border-strong',
color: '$color-nonSemantic-grey-content-primary',
backgroundColor: '$color-nonSemantic-white-background-strong',
},
Expand Down
6 changes: 3 additions & 3 deletions src/components/Badge/Badge.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Icon } from '@virtuslab/tetrisly-icons';
import { type FC, useMemo } from 'react';
import { FC, useMemo } from 'react';

import type { BadgeProps } from './Badge.props';
import { BadgeProps } from './Badge.props';
import { stylesBuilder } from './stylesBuilder';

import { tet } from '@/tetrisly';
import type { MarginProps } from '@/types/MarginProps';
import { MarginProps } from '@/types/MarginProps';

export const Badge: FC<BadgeProps & MarginProps> = ({
appearance,
Expand Down
10 changes: 0 additions & 10 deletions src/components/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ const meta = {
defaultValue: 'medium',
control: { type: 'radio' },
},
variant: {
options: ['default', 'ghost', 'bare'],
defaultValue: 'default',
control: { type: 'radio' },
},
intent: {
options: ['none', 'success', 'destructive'],
defaultValue: 'none',
control: { type: 'radio' },
},
},
parameters: {
docs: {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Button/Button.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const size = {

const commonConfig = {
display: 'inline-flex',
gap: '$space-component-gap-xSmall',
gap: '$space-component-gap-small',
w: 'fit-content',
justifyContent: 'center',
alignItems: 'center',
Expand Down Expand Up @@ -304,7 +304,7 @@ const defaultButtonConfig = {

const ghostButtonConfig = {
...commonConfig,
borderRadius: '$border-radius-large',
borderRadius: '$border-radius-medium',
backgroundColor: {
_: 'transparent',
hover: '$color-action-ghost-hover',
Expand Down
6 changes: 3 additions & 3 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Icon } from '@virtuslab/tetrisly-icons';
import { type FC, useMemo } from 'react';
import { FC, useMemo } from 'react';

import type { ButtonProps } from './Button.props';
import { ButtonProps } from './Button.props';
import { stylesBuilder } from './stylesBuilder';
import { tet } from '../../tetrisly';
import { Loader } from '../Loader';
Expand Down Expand Up @@ -67,7 +67,7 @@ export const Button: FC<ButtonProps & MarginProps> = ({
)}
{beforeIcon && state !== 'loading' && <Icon name={beforeIcon} />}
{children}
{dropdown && <Icon name="20-chevron-down-small" />}
{dropdown && <Icon name="20-chevron-down" />}
{afterIcon && !dropdown && <Icon name={afterIcon} />}
</tet.button>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Button/stylesBuilder/stylesBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('stylesBuilder', () => {
boxShadow: '$elevation-bottom-100',
color: '$color-action-inverted-normal',
display: 'inline-flex',
gap: '$space-component-gap-xSmall',
gap: '$space-component-gap-small',
justifyContent: 'center',
opacity: {
disabled: '$opacity-disabled',
Expand Down
9 changes: 1 addition & 8 deletions src/components/Checkbox/Checkbox.props.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { InputHTMLAttributes } from 'react';

import type { CheckboxConfig } from './Checkbox.styles';
import { HelperTextProps } from '../HelperText';

export type CheckboxProps = {
isChecked?: boolean;
Expand All @@ -14,11 +13,5 @@ export type CheckboxProps = {
> &
(
| { label?: string; helperText?: never }
| {
label: string;
helperText?: Pick<
HelperTextProps,
'hasBeforeIcon' | 'counter' | 'text'
>;
}
| { label: string; helperText?: string }
);
13 changes: 2 additions & 11 deletions src/components/Checkbox/Checkbox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ const meta = {
title: 'Checkbox',
component: Checkbox,
tags: ['autodocs'],
argTypes: {
state: {
control: {
type: 'select',
options: [undefined, 'disabled', 'alert'],
},
},
},
parameters: {
docs: {
description: {
Expand All @@ -42,7 +34,6 @@ export const Default: Story = {};
export const Checked: Story = {
args: {
isChecked: true,
onChange: () => {},
},
};

Expand Down Expand Up @@ -96,7 +87,7 @@ export const Alert: Story = {
args: {
state: 'alert',
label: 'Label',
helperText: { text: 'Helper text' },
helperText: 'Helper text',
},
};

Expand All @@ -109,6 +100,6 @@ export const Label: Story = {
export const HelperText: Story = {
args: {
label: 'Label',
helperText: { text: 'Helper text' },
helperText: 'Helper text',
},
};
23 changes: 10 additions & 13 deletions src/components/Checkbox/Checkbox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,16 @@ const getCheckbox = (jsx: JSX.Element) => {
};

describe('Checkbox', () => {
customPropTester(
<Checkbox label="Label" helperText={{ text: 'Helper Text' }} />,
{
containerId: 'checkbox',
innerElements: {
input: [],
checkboxContainer: [],
checkboxIcon: [],
label: [],
helperText: [],
},
customPropTester(<Checkbox label="Label" helperText="Helper Text" />, {
containerId: 'checkbox',
innerElements: {
input: [],
checkboxContainer: [],
checkboxIcon: [],
label: [],
helperText: [],
},
);
});

beforeEach(() => {
handleEventMock.mockReset();
Expand Down Expand Up @@ -104,7 +101,7 @@ describe('Checkbox', () => {

it('should render helper text if props provided', () => {
const { label, helperText } = getCheckbox(
<Checkbox label="Label" helperText={{ text: 'Helper text' }} />,
<Checkbox label="Label" helperText="Helper text" />,
);

expect(label).toHaveTextContent('Label');
Expand Down
Loading

0 comments on commit 96dade9

Please sign in to comment.