Skip to content

Commit

Permalink
Revert "Feat/status sizes (#1346)"
Browse files Browse the repository at this point in the history
This reverts commit ce5878c.
  • Loading branch information
fulcanellee committed Sep 2, 2024
1 parent 4146fb8 commit c77bfcd
Show file tree
Hide file tree
Showing 34 changed files with 93 additions and 313 deletions.
9 changes: 0 additions & 9 deletions .changeset/beige-grapes-fry.md

This file was deleted.

40 changes: 1 addition & 39 deletions packages/status/src/Component.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';
import { render } from '@testing-library/react';

import { Status } from './index';
import { colors, sizes } from './consts';
import { Status, colors } from './index';

describe('Status', () => {
describe('Snapshots tests', () => {
Expand Down Expand Up @@ -36,21 +35,6 @@ describe('Status', () => {
expect(container.firstElementChild).toHaveClass('green');
});

it('should set size=20 by default', () => {
const { container } = render(<Status />);
expect(container.firstElementChild).toHaveClass('size-20');
});

it('should set shape=rectangular by default', () => {
const { container } = render(<Status />);
expect(container.firstElementChild).toHaveClass('rectangular');
});

it('should set uppercase=true by default', () => {
const { container } = render(<Status />);
expect(container.firstElementChild).toHaveClass('uppercase');
});

it.each(['muted-alt', 'contrast', 'muted'] as const)('should set view="%s"', (view) => {
const { container } = render(<Status view={view}>Label</Status>);

Expand All @@ -62,28 +46,6 @@ describe('Status', () => {

expect(container.firstElementChild).toHaveClass(color);
});

it.each(sizes)('should set size="%s"', (size) => {
const { container } = render(<Status size={size}>Label</Status>);

expect(container.firstElementChild).toHaveClass(`size-${size}`);
});

it.each(['rectangular', 'rounded'] as const)('should set shape="%s"', (shape) => {
const { container } = render(<Status shape={shape}>Label</Status>);

expect(container.firstElementChild).toHaveClass(shape);
});

it('should set uppercase', () => {
const { container } = render(<Status uppercase={true}>Label</Status>);
expect(container.firstElementChild).toHaveClass('uppercase');
});

it('should not set uppercase', () => {
const { container } = render(<Status uppercase={false}>Label</Status>);
expect(container.firstElementChild).not.toHaveClass('uppercase');
});
});

it('should unmount without errors', () => {
Expand Down
37 changes: 3 additions & 34 deletions packages/status/src/Component.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { FC, ReactNode } from 'react';
import cn from 'classnames';

import { colors, sizes } from './consts';

import styles from './index.module.css';

export const colors = ['green', 'orange', 'red', 'blue', 'grey', 'teal', 'purple'] as const;

export type StatusProps = {
/**
* Дополнительный класс
Expand All @@ -31,24 +31,6 @@ export type StatusProps = {
* Дочерние элементы.
*/
children?: ReactNode;

/**
* Размер компонента
* @default 20
*/
size?: (typeof sizes)[number];

/**
* Форма компонента
* @default rectangular
*/
shape?: 'rounded' | 'rectangular';

/**
* Текст компонента в верхнем регистре
* @default true
*/
uppercase?: boolean;
};

const logWarning = () => {
Expand All @@ -71,27 +53,14 @@ export const Status: FC<StatusProps> = ({
color = 'green',
children,
dataTestId,
size = 20,
shape = 'rectangular',
uppercase = true,
}) => {
if (view === 'soft') {
logWarning();
}

return (
<span
className={cn(
styles.component,
styles[color],
styles[view],
styles[`size-${size}`],
styles[shape],
className,
{
[styles.uppercase]: uppercase,
},
)}
className={cn(styles.component, styles[color], styles[view], className)}
data-test-id={dataTestId}
>
<span className={styles.ellipsis}>{children}</span>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

6 changes: 3 additions & 3 deletions packages/status/src/__snapshots__/Component.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`Status Snapshots tests should match view="contrast" snapshot 1`] = `
<div>
<span
class="component green contrast size-20 rectangular uppercase"
class="component green contrast"
>
<span
class="ellipsis"
Expand All @@ -17,7 +17,7 @@ exports[`Status Snapshots tests should match view="contrast" snapshot 1`] = `
exports[`Status Snapshots tests should match view="muted" snapshot 1`] = `
<div>
<span
class="component green muted size-20 rectangular uppercase"
class="component green muted"
>
<span
class="ellipsis"
Expand All @@ -31,7 +31,7 @@ exports[`Status Snapshots tests should match view="muted" snapshot 1`] = `
exports[`Status Snapshots tests should match view="muted-alt" snapshot 1`] = `
<div>
<span
class="component green muted-alt size-20 rectangular uppercase"
class="component green muted-alt"
>
<span
class="ellipsis"
Expand Down
31 changes: 2 additions & 29 deletions packages/status/src/component.screenshots.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import {
createPreview,
createSpriteStorybookUrl,
generateTestCases,
setupScreenshotTesting,
} from '../../screenshot-utils';
import { createPreview, generateTestCases, setupScreenshotTesting } from '../../screenshot-utils';

import { colors, sizes } from './consts';
import { colors } from './Component';

const screenshotTesting = setupScreenshotTesting({
it,
Expand Down Expand Up @@ -43,25 +38,3 @@ describe(
screenshotOpts: { clip },
}),
);

describe(
'Status | size, shape, uppercase',
screenshotTesting({
cases: [
[
'sprite',
createSpriteStorybookUrl({
componentName: 'Status',
knobs: {
children: 'Label',
view: ['muted-alt'],
color: ['blue'],
size: [...sizes],
shape: ['rectangular', 'rounded'],
uppercase: [true, false],
},
}),
],
],
}),
);
2 changes: 0 additions & 2 deletions packages/status/src/consts/index.ts

This file was deleted.

8 changes: 2 additions & 6 deletions packages/status/src/docs/Component.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import { boolean, select, text } from '@storybook/addon-knobs';
import { Status } from '@alfalab/core-components-status';
import { colors, sizes } from '../consts';
import { select, text } from '@storybook/addon-knobs';
import { Status, colors } from '@alfalab/core-components-status';

const meta: Meta<typeof Status> = {
title: 'Components/Status',
Expand All @@ -18,9 +17,6 @@ export const status: Story = {
<Status
color={select('color', colors, 'green')}
view={select('view', ['muted-alt', 'contrast', 'muted'], 'muted-alt')}
size={select('size', sizes, 20)}
shape={select('shape', ['rectangular', 'rounded'], 'rectangular')}
uppercase={boolean('uppercase', true)}
>
{text('children', 'Label')}
</Status>
Expand Down
Loading

0 comments on commit c77bfcd

Please sign in to comment.