Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: components review #95

Merged
merged 24 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e23d113
chore: NO-JIRA fix correct type when importing package
wleklinskimateusz Oct 19, 2023
b47fa56
chore: TET-400 fix SocialIcons size
wleklinskimateusz Oct 23, 2023
ba85245
chore: TET-396 RadioButton corrections
wleklinskimateusz Oct 23, 2023
2f4748f
chore: TET-383 fix Avatar correction
wleklinskimateusz Oct 23, 2023
f40180a
chore: TET-405 change StatusDot stroked to hasStroke
wleklinskimateusz Oct 30, 2023
6c2e71d
fix: TET-405 StatusDot Test fix
wleklinskimateusz Oct 30, 2023
09211c7
fix: TET-385 fix Button
wleklinskimateusz Oct 30, 2023
04a145f
fix: TET-398 clear button in TextInput
wleklinskimateusz Oct 31, 2023
931c1a4
fix: TET-403 change helperText beforeIcon to hasBeforeIcon
wleklinskimateusz Oct 31, 2023
0a7fec5
fix: TET-382 change AlerBanner Positive to Success intent
wleklinskimateusz Oct 31, 2023
9f4011b
fix: TET-384 add wrapper for vertical divider
wleklinskimateusz Nov 2, 2023
f263f9e
fix: TET-402 fix height of the toast
wleklinskimateusz Nov 2, 2023
cb3e4f4
fix: TET-402 change location of typo in config Toast
wleklinskimateusz Nov 2, 2023
3bb3bed
fix: TET-395 change size of a ring to smaller (from 2px to 1px)
wleklinskimateusz Nov 2, 2023
7ced472
fix: TET-384 grid presentation and emphasis order
wleklinskimateusz Nov 2, 2023
257e3d2
fix: TET-384 change color of border Badge
wleklinskimateusz Nov 2, 2023
7d646e8
fix: TET-390 fix presentation of an IconButton, fix BareButton
wleklinskimateusz Nov 2, 2023
f4bc22a
fix: TET-386 adjust Checkbox component
wleklinskimateusz Nov 2, 2023
72d8b41
feat: TET-399 extract useTextInput hook and use it to create Select c…
wleklinskimateusz Nov 3, 2023
701fae8
chore: NO-JIRA add bg to text Input
wleklinskimateusz Nov 3, 2023
5229417
fix: NO-JIRA fix export file
wleklinskimateusz Nov 3, 2023
a6dbd52
chore: NO-JIRA: change React.FC to FC
wleklinskimateusz Nov 3, 2023
103a199
chore: NO-JIRA update readme
wleklinskimateusz Nov 3, 2023
4cc0045
Merge branch 'main' into fix/NO-JIRA/components-review
mwleklinski Nov 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,41 @@ 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.cjs"
"require": "./dist/tetrisly-react.umd.js"
}
},
"repository": {
Expand Down
9 changes: 8 additions & 1 deletion src/components/AlertBanner/AlertBanner.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ const meta = {
},
],
},
argTypes: {
intent: {
options: ['none', 'success', 'warning', 'negative'],
defaultValue: 'none',
control: { type: 'radio' },
},
},
parameters: {
docs: {
description: {
Expand All @@ -46,7 +53,7 @@ export const Default: Story = {};

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

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',
},
positive: {
success: {
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): IconName<20> => {
const iconConfig: Record<AlertBannerIntent, IconName<20>> = {
export const resolveIconName = (intent: AlertBannerIntent) => {
const iconConfig = {
none: '20-info-fill',
positive: '20-info-fill',
success: '20-check-circle-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 (positive)', () => {
it('should render correct intent color (success)', () => {
const alertBanner = getAlertBanner(
<AlertBanner text="Alert" intent="positive" />,
<AlertBanner text="Alert" intent="success" />,
);
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' | 'positive' | 'warning' | 'negative';
export type AlertBannerIntent = 'none' | 'success' | 'warning' | 'negative';
5 changes: 4 additions & 1 deletion src/components/Avatar/Avatar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ 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-white-content-primary',
color: '$color-nonSemantic-grey-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 { FC, useMemo } from 'react';
import { type FC, useMemo } from 'react';

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

export type AvatarAppearance = AvatarAppearanceColors | 'image';
export type AvatarAppearanceColors = (typeof avatarAppearanceColors)[number];

export type AvatarAppearance = 'image' | AvatarAppearanceColors;
9 changes: 9 additions & 0 deletions src/components/Badge/Badge.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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 @@ -9,6 +10,14 @@ 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-strong',
borderColor: '$color-nonSemantic-grey-border-subtle',
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 { FC, useMemo } from 'react';
import { type FC, useMemo } from 'react';

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

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

export const Badge: FC<BadgeProps & MarginProps> = ({
appearance,
Expand Down
10 changes: 10 additions & 0 deletions src/components/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ 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-small',
gap: '$space-component-gap-xSmall',
w: 'fit-content',
justifyContent: 'center',
alignItems: 'center',
Expand Down Expand Up @@ -304,7 +304,7 @@ const defaultButtonConfig = {

const ghostButtonConfig = {
...commonConfig,
borderRadius: '$border-radius-medium',
borderRadius: '$border-radius-large',
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 { FC, useMemo } from 'react';
import { type FC, useMemo } from 'react';

import { ButtonProps } from './Button.props';
import type { 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" />}
{dropdown && <Icon name="20-chevron-down-small" />}
{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-small',
gap: '$space-component-gap-xSmall',
justifyContent: 'center',
opacity: {
disabled: '$opacity-disabled',
Expand Down
9 changes: 8 additions & 1 deletion src/components/Checkbox/Checkbox.props.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { InputHTMLAttributes } from 'react';

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

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

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

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

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

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

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

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