Skip to content

Commit

Permalink
feat(StabilityIndex): introduce
Browse files Browse the repository at this point in the history
  • Loading branch information
AugustinMauroy committed Dec 22, 2024
1 parent d687927 commit 61fd52e
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 1 deletion.
48 changes: 48 additions & 0 deletions apps/site/components/ApiDocs/StabilityIndex/index.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.stabilityIndex {
@apply py-3
px-4
flex
flex-row
items-center
gap-2
text-white
rounded;

.indexLelvel {
@apply rounded-sm
text-sm
px-1.5;
}

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

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

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

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

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

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

&.stabilityLevel0 {
@apply bg-danger-600;

.indexLelvel {
@apply bg-danger-700;
}
}
}
37 changes: 37 additions & 0 deletions apps/site/components/ApiDocs/StabilityIndex/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import type { Meta as MetaObj, StoryObj } from '@storybook/react';


import StabilityIndex from '@/components/ApiDocs/StabilityIndex';

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

export const Legacy: Story = {
args: {
level: 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.'
},
}

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

export const Experimental: Story = {
args: {
level: 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:'
},
}

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

export default { component: StabilityIndex } as Meta;
19 changes: 19 additions & 0 deletions apps/site/components/ApiDocs/StabilityIndex/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import classNames from 'classnames';
import type { FC, PropsWithChildren } from 'react';

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

type StabilityIndexProps = PropsWithChildren<{
level: number;
}>;

const StabilityIndex: FC<StabilityIndexProps> = ({ level, children }) => (
<div className={classNames(styles.stabilityIndex, styles[`stabilityLevel${level}`])}>
<span
className={styles.indexLelvel}
>{level}</span>{children}
</div>
);


export default StabilityIndex;
2 changes: 1 addition & 1 deletion apps/site/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

0 comments on commit 61fd52e

Please sign in to comment.