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

improve tag component: children element #392

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/components/Plugin/Plugin.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const argsOn = {
topActionFunction: () => console.log('download'),
title: `plugin name - 30 characters...`,
subtitle: `Author's Name`,
tag: <Tag type="warning" content="beta" />,
tag: <Tag type="warning">Beta</Tag>,
subtitleIcon: <Certificate />,
version: '1.0.2',
content: [
Expand Down
10 changes: 5 additions & 5 deletions src/components/Tag/Tag.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ export default {
export const _Tag = {
render: () => (
<>
<Tag type={'default'} content={'default type'} />
<Tag type={'default'}>default type</Tag>
<br />
<Tag type={'error'} content={'error type'} />
<Tag type={'error'}>error type</Tag>
<br />
<Tag type={'success'} content={'success type'} />
<Tag type={'success'}>success type</Tag>
<br />
<Tag type={'info'} content={'info type'} />
<Tag type={'info'}>info type</Tag>
<br />
<Tag type={'warning'} content={'warning type'} />
<Tag type={'warning'}>warning type</Tag>
</>
),
};
12 changes: 6 additions & 6 deletions src/components/Tag/Tag.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,47 @@ import { Tag } from './Tag';

describe('Components | Tag', () => {
test('it should render', () => {
render(<Tag type="default" content="default type" />);
render(<Tag type="default">default type</Tag>);

let tag = screen.getByTestId('tag');

expect(tag).toBeTruthy();
});

test('it should have white class with 30% opacity', () => {
render(<Tag type="default" content="default type" />);
render(<Tag type="default">default type</Tag>);

let tag = screen.getByTestId('tag');

expect(tag).toHaveClass('bg-white/30');
});

test('it should have info-1 class', () => {
render(<Tag type="info" content="info type" />);
render(<Tag type="info">info type</Tag>);

let tag = screen.getByTestId('tag');

expect(tag).toHaveClass('bg-s-info-1');
});

test('it should have error class', () => {
render(<Tag type="error" content="error type" />);
render(<Tag type="error">error type</Tag>);

let tag = screen.getByTestId('tag');

expect(tag).toHaveClass('bg-s-error');
});

test('it should have success class', () => {
render(<Tag type="success" content="success type" />);
render(<Tag type="success">success type</Tag>);

let tag = screen.getByTestId('tag');

expect(tag).toHaveClass('bg-s-success');
});

test('it should have warning class', () => {
render(<Tag type="warning" content="warning type" />);
render(<Tag type="warning">warning type</Tag>);

let tag = screen.getByTestId('tag');

Expand Down
6 changes: 3 additions & 3 deletions src/components/Tag/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import React from 'react';

interface TagProps {
type: string;
content: string;
children: React.ReactNode;
customClass?: string;
}

export function Tag(props: TagProps) {
const { content, type, customClass } = props;
const { children, type, customClass } = props;

let isDefault = type === 'default';
let isInfo = type === 'info';
Expand All @@ -31,7 +31,7 @@ export function Tag(props: TagProps) {
className={`${backgroundClass} mas-caption rounded-full w-fit px-3 py-1
bg-opacity-30 ${typeColor} ${customClass}`}
>
{content}
{children}
</p>
);
}
2 changes: 1 addition & 1 deletion src/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function Tooltip(props: TooltipProps) {
{icon || defaultIcon}
{showTooltip && (
<div
className={`w-fit z-10 absolute bg-tertiary p-3 rounded-lg text-neutral ml-2 ${customClass} `}
className={`w-fit z-10 absolute bg-tertiary p-3 rounded-lg text-neutral ml-2 ${customClass}`}
>
{content}
</div>
Expand Down
Loading