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

feat(InfoBox): introduce #7352

Merged
merged 8 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
63 changes: 63 additions & 0 deletions apps/site/components/Common/InfoBox/index.module.css
AugustinMauroy marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
.infoBox {
@apply flex
flex-row
items-center
gap-2
rounded
px-4
py-3
text-sm
text-white;
AugustinMauroy marked this conversation as resolved.
Show resolved Hide resolved

&.small {
@apply gap-1
py-2
text-xs;

.title {
@apply px-1;
}
}

.title {
@apply rounded-sm
px-1.5;
}

svg {
@apply inline
size-5;
}

&.info {
@apply bg-info-600;

.title {
@apply bg-info-700;
}
}

&.success {
@apply bg-green-600;

.title {
@apply bg-green-700;
}
}

&.warning {
@apply bg-warning-600;

.title {
@apply bg-warning-700;
}
}

&.error {
AugustinMauroy marked this conversation as resolved.
Show resolved Hide resolved
@apply bg-danger-600;

.title {
@apply bg-danger-700;
}
}
}
73 changes: 73 additions & 0 deletions apps/site/components/Common/InfoBox/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { ExclamationCircleIcon } from '@heroicons/react/24/solid';
import type { Meta as MetaObj, StoryObj } from '@storybook/react';

import InfoBox from '@/components/Common/InfoBox';

type Story = StoryObj<typeof InfoBox>;
type Meta = MetaObj<typeof InfoBox>;

export const Info: Story = {
args: {
level: 'info',
title: '3',
children:
'Legacy. Although this feature is unlikely to be removed and is still covered by semantic versioning guarantees, it is no longer actively maintained, and other alternatives are available.',
size: 'default',
},
};

export const Success: Story = {
args: {
level: 'success',
title: '2',
children:
'Stable. Compatibility with the npm ecosystem is a high priority.',
size: 'default',
},
};

export const Warning: Story = {
args: {
level: 'warning',
title: '1',
children:
'Experimental. The feature is not subject to semantic versioning rules. Non-backward compatible changes or removal may occur in any future release. Use of the feature is not recommended in production environments. Experimental features are subdivided into stages:',
size: 'default',
},
};

export const Error: Story = {
args: {
level: 'error',
title: '0',
children:
'Deprecated. The feature may emit warnings. Backward compatibility is not guaranteed.',
size: 'default',
},
};

export const WithIcon: Story = {
args: {
level: 'info',
title: '3',
children: (
<p>
Lorem ipsum dolor sit amet <ExclamationCircleIcon /> consectetur
adipisicing elit. Inventore, quasi doloremque. Totam, earum velit, sunt
voluptates fugiat beatae praesentium quis magni explicabo repudiandae
nam aut molestias ex ad sequi eum!
</p>
),
size: 'default',
},
};

export default {
component: InfoBox,
argTypes: {
size: {
options: ['default', 'small'],
control: { type: 'radio' },
},
},
} as Meta;
24 changes: 24 additions & 0 deletions apps/site/components/Common/InfoBox/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import classNames from 'classnames';
import type { FC, PropsWithChildren } from 'react';

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

type InfoBoxProps = PropsWithChildren<{
level: 'info' | 'success' | 'warning' | 'error';
title: string;
size?: 'default' | 'small';
}>;

const InfoBox: FC<InfoBoxProps> = ({
level,
title,
children,
size = 'default',
}) => (
<div className={classNames(styles.infoBox, styles[level], styles[size])}>
<span className={styles.title}>{title}</span>
{children}
</div>
);

export default InfoBox;
6 changes: 0 additions & 6 deletions apps/site/next-env.d.ts

This file was deleted.

Loading