Skip to content

Commit

Permalink
fix(react): export types for Stack component (carbon-design-system#15456
Browse files Browse the repository at this point in the history
)

* fix(react): export types for Stack component

Signed-off-by: Onur Özkardeş <[email protected]>

* refactor(react/stack): move type declarations into main component file

* fix(stack): get spacing definition from layout instead of icons-react

---------

Signed-off-by: Onur Özkardeş <[email protected]>
Co-authored-by: Onur Özkardeş <[email protected]>
Co-authored-by: Andrea N. Cardona <[email protected]>
  • Loading branch information
3 people authored and preetibansalui committed Apr 24, 2024
1 parent 94bad93 commit 9371cc6
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 29 deletions.
8 changes: 8 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,14 @@
]
},
{
"login": "onurozkardes",
"name": "Onur Özkardeş",
"avatar_url": "https://avatars.githubusercontent.com/u/38096930?v=4",
"profile": "https://github.com/onurozkardes",
"contributions": [
"code"
]
},
"login": "mattborghi",
"name": "Matias Borghi",
"avatar_url": "https://avatars.githubusercontent.com/u/11933424?v=4",
Expand Down
23 changes: 23 additions & 0 deletions packages/react/src/components/Stack/HStack.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Copyright IBM Corp. 2016, 2023
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';

import { Stack, StackProps } from './Stack';

const HStack = React.forwardRef<React.ReactNode, StackProps>(function HStack(
{ children, ...props },
ref
) {
return (
<Stack {...props} ref={ref} orientation="horizontal">
{children}
</Stack>
);
});

export { HStack };
7 changes: 4 additions & 3 deletions packages/react/src/components/Stack/Stack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
* LICENSE file in the root directory of this source tree.
*/

import { spacing } from '@carbon/layout';
import React from 'react';
import cx from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import { spacing } from '@carbon/layout';

import { usePrefix } from '../../internal/usePrefix';

/**
Expand All @@ -21,7 +22,7 @@ const SPACING_STEPS = Array.from({ length: spacing.length - 1 }).map(
}
);

interface StackProps extends React.HTMLAttributes<HTMLElement> {
export interface StackProps extends React.HTMLAttributes<HTMLElement> {
/**
* Provide a custom element type to render as the outermost element in
* the Stack component. By default, this component will render a `div`.
Expand Down
19 changes: 19 additions & 0 deletions packages/react/src/components/Stack/VStack.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright IBM Corp. 2016, 2023
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';

import { Stack, StackProps } from './Stack';

const VStack = React.forwardRef<React.ReactNode, StackProps>(function VStack(
props,
ref
) {
return <Stack {...props} ref={ref} orientation="vertical" />;
});

export { VStack };
10 changes: 10 additions & 0 deletions packages/react/src/components/Stack/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Copyright IBM Corp. 2016, 2023
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

export { HStack } from './HStack';
export { VStack } from './VStack';
export { Stack, type StackProps } from './Stack';
26 changes: 0 additions & 26 deletions packages/react/src/components/Stack/index.tsx

This file was deleted.

1 change: 1 addition & 0 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export * from './components/SkeletonIcon';
export * from './components/SkeletonPlaceholder';
export * from './components/SkeletonText';
export * from './components/Slider';
export * from './components/Stack';
export * from './components/StructuredList';
export * from './components/Switch';
export * from './components/Tab';
Expand Down

0 comments on commit 9371cc6

Please sign in to comment.