Skip to content

Commit

Permalink
Components: Group all G2 components in the ui folder (#28624)
Browse files Browse the repository at this point in the history
* Components: Group all G2 components in the `ui` folder

* Move G2 context to the `ui` folder

* Storybook improvements for G2 stories

* Move G2 Text component to `ui` folder

* Update manifest for the handbook

* Move FontSizeControl to the `ui` subfolder

* Move createComponent util to the `ui` folder

* Move G2 utils to the `ui` folder
  • Loading branch information
gziolo authored and noisysocks committed Feb 2, 2021
1 parent 458a74c commit 996d399
Show file tree
Hide file tree
Showing 60 changed files with 249 additions and 374 deletions.
30 changes: 0 additions & 30 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -965,12 +965,6 @@
"markdown_source": "../packages/components/src/form-token-field/README.md",
"parent": "components"
},
{
"title": "Grid",
"slug": "grid",
"markdown_source": "../packages/components/src/grid/README.md",
"parent": "components"
},
{
"title": "Guide",
"slug": "guide",
Expand Down Expand Up @@ -1073,12 +1067,6 @@
"markdown_source": "../packages/components/src/menu-items-choice/README.md",
"parent": "components"
},
{
"title": "BottomSheetNavigation",
"slug": "bottom-sheet-navigation",
"markdown_source": "../packages/components/src/mobile/bottom-sheet/bottom-sheet-navigation/README.md",
"parent": "components"
},
{
"title": "Modal",
"slug": "modal",
Expand Down Expand Up @@ -1223,12 +1211,6 @@
"markdown_source": "../packages/components/src/text-highlight/README.md",
"parent": "components"
},
{
"title": "Next",
"slug": "next",
"markdown_source": "../packages/components/src/text/next/README.md",
"parent": "components"
},
{
"title": "Text",
"slug": "text",
Expand Down Expand Up @@ -1289,24 +1271,12 @@
"markdown_source": "../packages/components/src/tree-select/README.md",
"parent": "components"
},
{
"title": "Truncate",
"slug": "truncate",
"markdown_source": "../packages/components/src/truncate/README.md",
"parent": "components"
},
{
"title": "UnitControl",
"slug": "unit-control",
"markdown_source": "../packages/components/src/unit-control/README.md",
"parent": "components"
},
{
"title": "View",
"slug": "view",
"markdown_source": "../packages/components/src/view/README.md",
"parent": "components"
},
{
"title": "VisuallyHidden",
"slug": "visually-hidden",
Expand Down
4 changes: 2 additions & 2 deletions docs/tool/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const glob = require( 'glob' ).sync;

const baseRepoUrl = '..';
const componentPaths = glob( 'packages/components/src/*/**/README.md', {
// Don't expose documentation for mobile only components just yet.
ignore: '**/mobile/*/README.md',
// Don't expose documentation for mobile only and G2 components just yet.
ignore: [ '**/src/mobile/**/README.md', '**/src/ui/**/README.md' ],
} );
const packagePaths = glob( 'packages/*/package.json' ).map(
( fileName ) => fileName.split( '/' )[ 1 ]
Expand Down
2 changes: 0 additions & 2 deletions packages/components/src/__next/context/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/components/src/font-size-picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Button from '../button';
import RangeControl from '../range-control';
import CustomSelectControl from '../custom-select-control';
import VisuallyHidden from '../visually-hidden';
import { withNextComponent } from './next/';
import { withNextComponent } from './next';

const DEFAULT_FONT_SIZE = 'default';
const CUSTOM_FONT_SIZE = 'custom';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Internal dependencies
*/
import { __unstableWithNext as withNext } from '../../__next/context';
import FontSizeControl from './font-size-control';
import { withNext } from '../ui/context';
import { FontSizeControl } from '../ui/font-size-control';

const FontSizePicker =
process.env.COMPONENT_SYSTEM_PHASE === 1
Expand Down
2 changes: 0 additions & 2 deletions packages/components/src/grid/index.js

This file was deleted.

9 changes: 3 additions & 6 deletions packages/components/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export { default as FormToggle } from './form-toggle';
export { default as FormTokenField } from './form-token-field';
export { default as __experimentalGradientPicker } from './gradient-picker';
export { default as __experimentalCustomGradientPicker } from './custom-gradient-picker';
export { default as __experimentalGrid } from './grid';
export { default as Guide } from './guide';
export { default as GuidePage } from './guide/page';
export { default as Icon } from './icon';
Expand Down Expand Up @@ -130,9 +129,7 @@ export {
TreeGridItem as __experimentalTreeGridItem,
} from './tree-grid';
export { default as TreeSelect } from './tree-select';
export { default as __experimentalTruncate } from './truncate';
export { default as __experimentalUnitControl } from './unit-control';
export { default as __experimentalView } from './view';
export { default as VisuallyHidden } from './visually-hidden';
export { default as IsolatedEventContainer } from './isolated-event-container';
export {
Expand Down Expand Up @@ -161,6 +158,6 @@ export { default as withSpokenMessages } from './higher-order/with-spoken-messag

// Component System
export {
__unstableWithNext,
__unstableComponentSystemProvider,
} from './__next/context';
withNext as __unstableWithNext,
ComponentSystemProvider as __unstableComponentSystemProvider,
} from './ui/context';
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/**
* Internal dependencies
*/
import { __unstableWithNext as withNext } from '../../__next/context';
import NextText from './text';
import { text } from '../styles/text-mixins';
import { withNext } from '../ui/context';
import { Text as NextText } from '../ui/text';
import { text } from './styles/text-mixins';

const Text = process.env.COMPONENT_SYSTEM_PHASE === 1 ? NextText : undefined;

/**
* @typedef AdaptedTextProps
* @property {keyof JSX.IntrinsicElements} as Styled components `as` prop.
* @property {import('../styles/text-mixins').TextVariant} variant The variant to render.
* @property {import('./styles/text-mixins').TextVariant} variant The variant to render.
* @property {import('react').ReactNode} children Children to render.
* @property {string} [className] Classname to render on the element.
*/
Expand Down
3 changes: 0 additions & 3 deletions packages/components/src/truncate/index.js

This file was deleted.

2 changes: 2 additions & 0 deletions packages/components/src/ui/context/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { ComponentSystemProvider } from './component-system-provider';
export { withNext } from './with-next';
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
/**
* WordPress dependencies
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { contextConnect } from '@wp-g2/context';
import { VisuallyHidden, VStack } from '@wp-g2/components';

/**
* External dependencies
* WordPress dependencies
*/
import { contextConnect } from '@wp-g2/context';
import { View, VisuallyHidden, VStack } from '@wp-g2/components';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import FontSizeControlSelect from './font-size-control-select';
import FontSizeControlSlider from './font-size-control-slider';
import { useFontSizeControl } from './use-font-size-control';
import FontSizeControlSelect from './select';
import FontSizeControlSlider from './slider';
import useFontSizeControl from './use-font-size-control';
import { View } from '../view';

function FontSizeControl( props, forwardedRef ) {
const {
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/ui/font-size-control/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as FontSizeControl } from './font-size-control';
export { default as useFontSizeControl } from './use-font-size-control';
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';

/**
* External dependencies
*/
import { noop } from 'lodash';
import { contextConnect, useContextSystem } from '@wp-g2/context';
import {
Grid,
TextInput,
SelectDropdown,
FormGroup,
Button,
View,
} from '@wp-g2/components';

/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import { getSelectTemplateColumns } from './font-size-control-utils';
import { getSelectTemplateColumns } from './utils';
import { Grid } from '../grid';
import { View } from '../view';

function renderItem( { name, style } ) {
return <span style={ style }>{ name }</span>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
/**
* WordPress dependencies
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { noop } from 'lodash';
import { ControlLabel, Slider, TextInput, VStack } from '@wp-g2/components';

/**
* External dependencies
* WordPress dependencies
*/
import { noop } from 'lodash';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import {
ControlLabel,
Grid,
Slider,
TextInput,
VStack,
} from '@wp-g2/components';
import { getSliderTemplateColumns } from './font-size-control-utils';
import { getSliderTemplateColumns } from './utils';
import { Grid } from '../grid';

function FontSizeControlSlider( props ) {
const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ import { useCallback, useMemo } from '@wordpress/element';
/**
* Internal dependencies
*/
import * as styles from './font-size-control-styles';
import * as styles from './styles';
import {
getInputValue,
getSelectOptions,
getSelectValueFromFontSize,
hasUnit,
isCustomSelectedItem,
isCustomValue,
} from './font-size-control-utils';
} from './utils';

export function useFontSizeControl( props ) {
export default function useFontSizeControl( props ) {
const {
disableCustomFontSizes,
fontSizes = [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# Grid
# Grid (Experimental)

`Grid` is a primitive layout component that can arrange content in a grid configuration.

## Usage

```jsx
import {
__experientalGrid as Grid,
__experimentalView as View,
} from '@wordpress/components';
import { Grid, View } from '@wordpress/components/ui';

function Example() {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/**
* Internal dependencies
*/
import { createComponent } from '../utils/create-component';
import { useGrid } from './use-grid';
import { createComponent } from '../utils';
import useGrid from './use-grid';

/**
* `Grid` is a primitive layout component that can arrange content in a grid configuration.
*
* @example
* ```jsx
* import { __experimentalGrid as Grid } from `@wordpress/components`
* import { Grid } from `@wordpress/components/ui`
*
* function Example() {
* return (
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/ui/grid/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as Grid } from './grid';
export { default as useGrid } from './use-grid';
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { number } from '@storybook/addon-knobs';
/**
* Internal dependencies
*/
import View from '../../view';
import Grid from '../index';
import { View } from '../../view';
import Grid from '../grid';

export default {
component: Grid,
title: 'Components/Grid',
title: 'G2 Components (Experimental)/Grid',
};

const Item = ( props ) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { ui } from '@wp-g2/styles';
/**
* Internal dependencies
*/
import View from '../../view';
import Grid from '../index';
import { View } from '../../view';
import Grid from '../grid';

describe( 'props', () => {
test( 'should render correctly', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { CSSProperties } from 'react';
import { ResponsiveCSSValue } from '../utils/types';

type ResponsiveCSSValue<T> = Array<T | undefined> | T;

type GridAlignment =
| 'bottom'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import { useMemo } from '@wordpress/element';
/**
* Internal dependencies
*/
import { getAlignmentProps } from './grid-utils';
import { getAlignmentProps } from './utils';

/**
* @param {import('@wp-g2/create-styles').ViewOwnProps<import('./types').Props, 'div'>} props
*/
export function useGrid( props ) {
export default function useGrid( props ) {
const {
align,
alignment,
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions packages/components/src/ui/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './grid';
export * from './text';
export * from './truncate';
export * from './view';
Loading

0 comments on commit 996d399

Please sign in to comment.