Skip to content

Commit 5ee000e

Browse files
committed
feat(divider): deprecate color attribute & update doc with badge
1 parent 064a1da commit 5ee000e

File tree

8 files changed

+60
-7
lines changed

8 files changed

+60
-7
lines changed

packages/ods-react/src/components/divider/src/components/divider/Divider.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import classNames from 'classnames';
22
import { type ComponentPropsWithRef, type FC, type JSX, forwardRef } from 'react';
3-
import { DIVIDER_COLOR, type DividerColor } from '../../constants/divider-color';
3+
import { type DividerColor } from '../../constants/divider-color';
44
import { DIVIDER_SPACING, type DividerSpacing } from '../../constants/divider-spacing';
55
import style from './divider.module.scss';
66

77
interface DividerProp extends ComponentPropsWithRef<'hr'> {
88
/**
9+
* @deprecated
910
* The color preset to use.
11+
* DEPRECATED: Color will now always be primary, if you need another color, prefer overriding it using css.
1012
*/
1113
color?: DividerColor,
1214
/**
@@ -17,10 +19,14 @@ interface DividerProp extends ComponentPropsWithRef<'hr'> {
1719

1820
const Divider: FC<DividerProp> = forwardRef(({
1921
className,
20-
color = DIVIDER_COLOR.primary,
22+
color,
2123
spacing = DIVIDER_SPACING._2,
2224
...props
2325
}, ref): JSX.Element => {
26+
if (color) {
27+
console.warn('[DEPRECATED]: Color will now always be primary, if you need another color, prefer overriding it using css.');
28+
}
29+
2430
return (
2531
<hr
2632
className={ classNames(

packages/ods-react/src/components/divider/src/components/divider/divider.module.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ $spacings: 0, 2, 4, 8, 12, 16, 24, 32, 40, 48, 64;
44
.divider {
55
transform: scaleY(1);
66
border: none;
7+
background-color: var(--ods-color-neutral-100);
78
height: 1px;
89

10+
// [Deprecated] will be removed in next major version
911
&--neutral {
1012
background-color: var(--ods-color-neutral-700);
1113
}
1214

15+
// [Deprecated] will be removed in next major version
1316
&--primary {
1417
background-color: var(--ods-color-neutral-100);
1518
}

packages/ods-react/src/components/divider/src/constants/divider-color.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
import { COLOR } from '../../../../utils/colors';
22

3+
/**
4+
* @deprecated
5+
* Color will now always be primary, if you need another color, prefer overriding it using css.
6+
*/
37
enum DIVIDER_COLOR {
48
neutral = COLOR.neutral,
59
primary = COLOR.primary,
610
}
711

12+
/**
13+
* @deprecated
14+
* Color will now always be primary, if you need another color, prefer overriding it using css.
15+
*/
816
type DividerColor = `${DIVIDER_COLOR}`;
917

18+
/**
19+
* @deprecated
20+
* Color will now always be primary, if you need another color, prefer overriding it using css.
21+
*/
1022
const DIVIDER_COLORS = Object.freeze(Object.values(DIVIDER_COLOR));
1123

1224
export {
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1-
import { Divider } from '.';
1+
import { DIVIDER_COLOR, Divider } from '.';
22
import style from './dev.module.css';
33

44
export default {
55
component: Divider,
66
title: 'Divider dev',
77
};
88

9+
export const CustomStyle = () => (
10+
<Divider className={ style[ 'custom-divider' ] } />
11+
);
12+
913
export const Default = () => (
1014
<Divider />
1115
);
1216

13-
export const CustomStyle = () => (
14-
<Divider className={ style[ 'custom-divider' ] } />
17+
export const Deprecated = () => (
18+
<>
19+
<Divider color={ DIVIDER_COLOR.primary } />
20+
<Divider color={ DIVIDER_COLOR.neutral } />
21+
</>
1522
);

packages/storybook/src/components/technicalSpecification/ClassModule.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ICON_NAME, Icon } from '@ovhcloud/ods-react';
1+
import { BADGE_COLOR, BADGE_SIZE, ICON_NAME, Badge, Icon } from '@ovhcloud/ods-react';
22
import { CodeOrSourceMdx } from '@storybook/blocks';
33
import { Table } from '@storybook/components';
44
import React, { type JSX, useMemo } from 'react';
@@ -75,6 +75,14 @@ const ClassModule = ({ component, extraInfo }: ClassModuleProp): JSX.Element =>
7575
<tr key={ idx }>
7676
<td>
7777
{ prop.name }
78+
{
79+
prop.deprecated &&
80+
<Badge
81+
color={ BADGE_COLOR.warning }
82+
size={ BADGE_SIZE.sm }>
83+
Deprecated
84+
</Badge>
85+
}
7886
</td>
7987

8088
<td>

packages/storybook/src/components/technicalSpecification/TechnicalSpecification.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { BADGE_COLOR, BADGE_SIZE, Badge } from '@ovhcloud/ods-react';
12
import { CodeOrSourceMdx } from '@storybook/blocks';
23
import { type ModuleExports } from '@storybook/types';
34
import React, { Fragment, type JSX, useMemo } from 'react';
@@ -56,7 +57,16 @@ const TechnicalSpecification = ({ data, extraInfo, of }: Props): JSX.Element =>
5657
enums.map((enumObj, idx) => (
5758
<Fragment key={ idx }>
5859
<Heading label={ enumObj.name }
59-
level={ 3 } />
60+
level={ 3 }>
61+
{
62+
enumObj.deprecated &&
63+
<Badge
64+
color={ BADGE_COLOR.warning }
65+
size={ BADGE_SIZE.sm }>
66+
Deprecated
67+
</Badge>
68+
}
69+
</Heading>
6070

6171
<EnumList
6272
className={ styles['technical-specification__enums__keys'] }

packages/storybook/src/helpers/docgen.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import { type Documentation, type FunctionSignatureType, type LiteralType, type
22

33
enum TAG {
44
defaultValue = '@default-value',
5+
deprecated = '@deprecated',
56
internal = '@internal',
67
type = '@type',
78
}
89

910
type ComponentProp = {
11+
deprecated: boolean,
1012
description: string,
1113
defaultValue: string,
1214
isOptional: boolean,
@@ -47,6 +49,7 @@ function getComponentProp(name: string, prop: PropDescriptor): ComponentProp | u
4749
}
4850

4951
return {
52+
deprecated: tagsMap.has(TAG.deprecated),
5053
description: prop.description || '',
5154
defaultValue: prop.defaultValue?.value?.toString() || tagsMap.get(TAG.defaultValue) || 'undefined',
5255
isOptional: !prop.required,

packages/storybook/src/helpers/typedoc.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ type TypedocEnumMember = {
99

1010
type ComponentTypedoc = {
1111
enums: {
12+
deprecated?: boolean,
1213
members: TypedocEnumMember[],
1314
name: string,
1415
}[],
@@ -41,6 +42,7 @@ function getComponentTypedoc(data: ProjectReflection): ComponentTypedoc {
4142
.filter((declaration) => declaration.type && declaration.type.type === 'union');
4243

4344
const enums = enumDeclarations.map((enumDeclaration) => ({
45+
deprecated: enumDeclaration.comment?.blockTags.some(({ tag }) => tag === TAG.deprecated),
4446
name: enumDeclaration.name,
4547
members: filterByKinds(enumDeclaration.children, [ReflectionKind.EnumMember])
4648
.map((member) => ({
@@ -49,6 +51,7 @@ function getComponentTypedoc(data: ProjectReflection): ComponentTypedoc {
4951
})),
5052
}));
5153
const fakeEnums = fakeEnumDeclarations.map((fakeEnumDeclaration) => ({
54+
deprecated: false,
5255
name: fakeEnumDeclaration.name,
5356
members: filterByKinds((fakeEnumDeclaration.type as ReflectionType)?.declaration.children, [ReflectionKind.EnumMember])
5457
.map((member) => ({
@@ -59,6 +62,7 @@ function getComponentTypedoc(data: ProjectReflection): ComponentTypedoc {
5962

6063
return {
6164
enums: sortByName(enums.concat(fakeEnums).map((enumDoc) => ({
65+
deprecated: enumDoc.deprecated,
6266
name: enumDoc.name,
6367
members: sortByName(enumDoc.members),
6468
}))),

0 commit comments

Comments
 (0)