-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat(web-react): Introduce isFluid prop to Container
- Loading branch information
Showing
11 changed files
with
125 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/web-react/src/components/Container/__tests__/useContainerStyleProps.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { renderHook } from '@testing-library/react'; | ||
import { SpiritContainerProps } from '../../../types'; | ||
import { useContainerStyleProps } from '../useContainerStyleProps'; | ||
|
||
describe('useContainerStyleProps', () => { | ||
it('should return defaults', () => { | ||
const props = {}; | ||
const { result } = renderHook(() => useContainerStyleProps(props)); | ||
|
||
expect(result.current.classProps).toBe('Container'); | ||
}); | ||
|
||
it('should return fluid', () => { | ||
const props = { isFluid: true } as SpiritContainerProps; | ||
const { result } = renderHook(() => useContainerStyleProps(props)); | ||
|
||
expect(result.current.classProps).toBe('Container Container--fluid'); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
packages/web-react/src/components/Container/demo/ContainerFluid.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
import DocsBox from '../../../../docs/DocsBox'; | ||
import Container from '../Container'; | ||
|
||
const ContainerFluid = () => ( | ||
<Container isFluid> | ||
<DocsBox>Container</DocsBox> | ||
</Container> | ||
); | ||
|
||
export default ContainerFluid; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
'use client'; | ||
|
||
export * from './useContainerStyleProps'; | ||
export { default as Container } from './Container'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
packages/web-react/src/components/Container/useContainerStyleProps.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import classNames from 'classnames'; | ||
import { useClassNamePrefix } from '../../hooks'; | ||
import { SpiritContainerProps, ContainerProps } from '../../types'; | ||
|
||
export interface ContainerStyles { | ||
/** className props */ | ||
classProps: string; | ||
/** props to be passed to the element */ | ||
props: ContainerProps; | ||
} | ||
|
||
export function useContainerStyleProps(props: SpiritContainerProps): ContainerStyles { | ||
const { isFluid, ...modifiedProps } = props; | ||
|
||
const containerClass = useClassNamePrefix('Container'); | ||
const containerFluidClass = `${containerClass}--fluid`; | ||
const classProps = classNames(containerClass, { | ||
[containerFluidClass]: isFluid, | ||
}); | ||
|
||
return { | ||
classProps, | ||
props: modifiedProps, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { ChildrenProps, StyleProps, TransferProps } from './shared'; | ||
|
||
export interface ContainerProps extends ChildrenProps, StyleProps, TransferProps {} | ||
|
||
export interface SpiritContainerProps extends ContainerProps { | ||
isFluid?: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters