-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Global Styles: Move prototype from G2
- Loading branch information
Showing
31 changed files
with
1,728 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { createContext, useContext } from '@wordpress/element'; | ||
|
||
export const ItemGroupContext = createContext( { size: 'medium' } ); | ||
export const useItemGroupContext = () => useContext( ItemGroupContext ); |
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,2 @@ | ||
export { default as Item, useItem } from './item'; | ||
export { default as ItemGroup, useItemGroup } from './item-group'; |
31 changes: 31 additions & 0 deletions
31
packages/components/src/item-group/item-group/component.js
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,31 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { contextConnect } from '../../ui/context'; | ||
import { ItemGroupContext, useItemGroupContext } from '../context'; | ||
import { useItemGroup } from './hook'; | ||
import { View } from '../../view'; | ||
|
||
function ItemGroup( props, ref ) { | ||
const { bordered, separated, size: sizeProp, ...otherProps } = useItemGroup( | ||
props | ||
); | ||
|
||
const { size: contextSize } = useItemGroupContext(); | ||
|
||
const spacedAround = ! bordered && ! separated; | ||
const size = sizeProp || contextSize; | ||
|
||
const contextValue = { | ||
spacedAround, | ||
size, | ||
}; | ||
|
||
return ( | ||
<ItemGroupContext.Provider value={ contextValue }> | ||
<View { ...otherProps } ref={ ref } /> | ||
</ItemGroupContext.Provider> | ||
); | ||
} | ||
|
||
export default contextConnect( ItemGroup, 'ItemGroup' ); |
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,36 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { cx } from 'emotion'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { useContextSystem } from '../../ui/context'; | ||
import * as styles from '../styles'; | ||
|
||
export function useItemGroup( props ) { | ||
const { | ||
bordered = false, | ||
className, | ||
role = 'list', | ||
rounded = true, | ||
separated = false, | ||
...otherProps | ||
} = useContextSystem( props, 'ItemGroup' ); | ||
|
||
const classes = cx( | ||
bordered && styles.bordered, | ||
( bordered || separated ) && styles.separated, | ||
rounded && styles.rounded, | ||
className | ||
); | ||
|
||
return { | ||
bordered, | ||
className: classes, | ||
role, | ||
separated, | ||
...otherProps, | ||
}; | ||
} |
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,2 @@ | ||
export { default } from './component'; | ||
export { useItemGroup } from './hook'; |
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 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { createComponent } from '../../ui/utils'; | ||
import { useItem } from './hook'; | ||
|
||
export default createComponent( { | ||
useHook: useItem, | ||
as: 'div', | ||
name: 'Item', | ||
} ); |
Oops, something went wrong.