Skip to content

Commit

Permalink
Feat(web-react): Introduce Divider component #DS-1391
Browse files Browse the repository at this point in the history
  • Loading branch information
curdaj committed Jul 19, 2024
1 parent 61edf9a commit 6fe9931
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { useStyleProps } from '../../hooks';
import { SpiritDividerProps } from '../../types';
import { useDividerStyleProps } from './useDividerStyleProps';

export const UNSTABLE_Divider = (props: SpiritDividerProps): JSX.Element => {
export const Divider = (props: SpiritDividerProps): JSX.Element => {
const { classProps, props: modifiedProps } = useDividerStyleProps(props);
const { styleProps, props: otherProps } = useStyleProps(modifiedProps);

return <hr {...otherProps} {...styleProps} className={classNames(classProps, styleProps.className)} />;
};

export default UNSTABLE_Divider;
export default Divider;
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# UNSTABLE Divider
# Divider

> ⚠️ This component is UNSTABLE. It may significantly change at any point in the future.
> Please use it with caution.
The `UNSTABLE_Divider` component is used to separate content in a layout.
The `Divider` component is used to separate content in a layout.

```jsx
<UNSTABLE_Divider />
<Divider />
```

## API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import React from 'react';
import { classNamePrefixProviderTest } from '../../../../tests/providerTests/classNamePrefixProviderTest';
import { restPropsTest } from '../../../../tests/providerTests/restPropsTest';
import { stylePropsTest } from '../../../../tests/providerTests/stylePropsTest';
import UNSTABLE_Divider from '../UNSTABLE_Divider';
import Divider from '../Divider';

describe('UNSTABLE_Divider', () => {
classNamePrefixProviderTest(UNSTABLE_Divider, 'UNSTABLE_Divider');
describe('Divider', () => {
classNamePrefixProviderTest(Divider, 'Divider');

stylePropsTest(UNSTABLE_Divider);
stylePropsTest(Divider);

restPropsTest(UNSTABLE_Divider, 'hr');
restPropsTest(Divider, 'hr');

it('should have default classname', () => {
render(<UNSTABLE_Divider />);
render(<Divider />);

expect(screen.getByRole('separator')).toHaveClass('UNSTABLE_Divider');
expect(screen.getByRole('separator')).toHaveClass('Divider');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react';
import Divider from '../Divider';

const DividerDefault = () => <Divider />;

export default DividerDefault;
3 changes: 3 additions & 0 deletions packages/web-react/src/components/Divider/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './Divider';
export * from './useDividerStyleProps';
export { default as Divider } from './Divider';
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { Markdown } from '@storybook/blocks';
import type { Meta, StoryObj } from '@storybook/react';
import React from 'react';
import ReadMe from '../README.md';
import { UNSTABLE_Divider } from '..';
import { Divider } from '..';

const meta: Meta<typeof UNSTABLE_Divider> = {
title: 'Experimental/UNSTABLE_Divider',
component: UNSTABLE_Divider,
const meta: Meta<typeof Divider> = {
title: 'Experimental/Divider',
component: Divider,
parameters: {
docs: {
page: () => <Markdown>{ReadMe}</Markdown>,
Expand All @@ -17,8 +17,8 @@ const meta: Meta<typeof UNSTABLE_Divider> = {
};

export default meta;
type Story = StoryObj<typeof UNSTABLE_Divider>;
type Story = StoryObj<typeof Divider>;

export const Playground: Story = {
name: 'UNSTABLE_Divider',
name: 'Divider',
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface DividerStyles {
}

export function useDividerStyleProps(props: SpiritDividerProps): DividerStyles {
const DividerClass = useClassNamePrefix('UNSTABLE_Divider');
const DividerClass = useClassNamePrefix('Divider');

return {
classProps: DividerClass,
Expand Down

This file was deleted.

3 changes: 0 additions & 3 deletions packages/web-react/src/components/UNSTABLE_Divider/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/web-react/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export * from './TextFieldBase';
export * from './Toast';
export * from './Tooltip';
export * from './UNSTABLE_Avatar';
export * from './UNSTABLE_Divider';
export * from './Divider';
export * from './UNSTABLE_PartnerLogo';
export * from './UNSTABLE_ProductLogo';
export * from './VisuallyHidden';

0 comments on commit 6fe9931

Please sign in to comment.