Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Elevation: refactor away from the createComponent function
  • Loading branch information
ciampo committed Sep 9, 2021
commit c444b9a8f89e6ad02d9a895b2b5bae6600562098
21 changes: 14 additions & 7 deletions packages/components/src/elevation/component.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
/**
* Internal dependencies
*/
import { contextConnect } from '../ui/context';
import { View } from '../view';
import { useElevation } from './hook';
import { createComponent } from '../ui/utils';

/**
* @param {import('../ui/context').PolymorphicComponentProps<import('./types').Props, 'div'>} props
* @param {import('react').Ref<any>} forwardedRef
*/
function Elevation( props, forwardedRef ) {
const elevationProps = useElevation( props );

return <View { ...elevationProps } ref={ forwardedRef } />;
}

/**
* `Elevation` is a core component that renders shadow, using the library's shadow system.
Expand All @@ -27,10 +38,6 @@ import { createComponent } from '../ui/utils';
* }
* ```
*/
const Elevation = createComponent( {
as: 'div',
useHook: useElevation,
name: 'Elevation',
} );
const ConnectedElevation = contextConnect( Elevation, 'Elevation' );

export default Elevation;
export default ConnectedElevation;