-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Packages: Move the components module partially to the packages folder #7640
Changes from all commits
a5ee024
2a56b49
cfef9ae
44773e5
5ae9343
770ebf4
2f8c9a3
19ea586
afc887f
a5fd1b9
6e115e9
330a4cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,9 @@ const glob = require( 'glob' ); | |
const babel = require( '@babel/core' ); | ||
const chalk = require( 'chalk' ); | ||
const mkdirp = require( 'mkdirp' ); | ||
const sass = require( 'node-sass' ); | ||
const postcss = require( 'postcss' ); | ||
const deasync = require( 'deasync' ); | ||
|
||
/** | ||
* Internal dependencies | ||
|
@@ -29,6 +32,7 @@ const SRC_DIR = 'src'; | |
const BUILD_DIR = { | ||
main: 'build', | ||
module: 'build-module', | ||
style: 'build-style', | ||
}; | ||
const DONE = chalk.reset.inverse.bold.green( ' DONE ' ); | ||
|
||
|
@@ -68,6 +72,36 @@ function buildFile( file, silent ) { | |
buildFileFor( file, silent, 'module' ); | ||
} | ||
|
||
function buildStyle( packagePath ) { | ||
const styleFile = path.resolve( packagePath, SRC_DIR, 'style.scss' ); | ||
const outputFile = path.resolve( packagePath, BUILD_DIR.style, 'style.css' ); | ||
mkdirp.sync( path.dirname( outputFile ) ); | ||
const builtSass = sass.renderSync( { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know it's convenient for development, but a build script responsible for generating many distinct modules seems particularly write for an async implementation, not sync. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, true. I think this could be handled separately as it has implications on the whole |
||
file: styleFile, | ||
includePaths: [ path.resolve( __dirname, '../../edit-post/assets/stylesheets' ) ], | ||
data: ( | ||
[ | ||
'colors', | ||
'breakpoints', | ||
'variables', | ||
'mixins', | ||
'animations', | ||
'z-index', | ||
].map( ( imported ) => `@import "${ imported }";` ).join( ' ' ) + | ||
fs.readFileSync( styleFile, 'utf8' ) | ||
), | ||
} ); | ||
|
||
const postCSSSync = ( callback ) => { | ||
postcss( require( './post-css-config' ) ) | ||
.process( builtSass.css, { from: 'src/app.css', to: 'dest/app.css' } ) | ||
.then( ( result ) => callback( null, result ) ); | ||
}; | ||
|
||
const result = deasync( postCSSSync )(); | ||
fs.writeFileSync( outputFile, result.css ); | ||
} | ||
|
||
/** | ||
* Build a file for a specific environment | ||
* | ||
|
@@ -109,6 +143,13 @@ function buildPackage( packagePath ) { | |
process.stdout.write( `${ path.basename( packagePath ) }\n` ); | ||
|
||
files.forEach( ( file ) => buildFile( file, true ) ); | ||
|
||
// Building styles | ||
const styleFile = path.resolve( srcDir, 'style.scss' ); | ||
if ( fs.existsSync( styleFile ) ) { | ||
buildStyle( packagePath ); | ||
} | ||
|
||
process.stdout.write( `${ DONE }\n` ); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
module.exports = [ | ||
require( '@wordpress/postcss-themes' )( { | ||
defaults: { | ||
primary: '#0085ba', | ||
secondary: '#11a0d2', | ||
toggle: '#11a0d2', | ||
button: '#0085ba', | ||
outlines: '#007cba', | ||
}, | ||
themes: { | ||
'admin-color-light': { | ||
primary: '#0085ba', | ||
secondary: '#c75726', | ||
toggle: '#11a0d2', | ||
button: '#0085ba', | ||
outlines: '#007cba', | ||
}, | ||
'admin-color-blue': { | ||
primary: '#82b4cb', | ||
secondary: '#d9ab59', | ||
toggle: '#82b4cb', | ||
button: '#d9ab59', | ||
outlines: '#417e9B', | ||
}, | ||
'admin-color-coffee': { | ||
primary: '#c2a68c', | ||
secondary: '#9fa47b', | ||
toggle: '#c2a68c', | ||
button: '#c2a68c', | ||
outlines: '#59524c', | ||
}, | ||
'admin-color-ectoplasm': { | ||
primary: '#a7b656', | ||
secondary: '#c77430', | ||
toggle: '#a7b656', | ||
button: '#a7b656', | ||
outlines: '#523f6d', | ||
}, | ||
'admin-color-midnight': { | ||
primary: '#e14d43', | ||
secondary: '#77a6b9', | ||
toggle: '#77a6b9', | ||
button: '#e14d43', | ||
outlines: '#497b8d', | ||
}, | ||
'admin-color-ocean': { | ||
primary: '#a3b9a2', | ||
secondary: '#a89d8a', | ||
toggle: '#a3b9a2', | ||
button: '#a3b9a2', | ||
outlines: '#5e7d5e', | ||
}, | ||
'admin-color-sunrise': { | ||
primary: '#d1864a', | ||
secondary: '#c8b03c', | ||
toggle: '#c8b03c', | ||
button: '#d1864a', | ||
outlines: '#837425', | ||
}, | ||
}, | ||
} ), | ||
require( 'autoprefixer' ), | ||
require( 'postcss-color-function' ), | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,5 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import deprecated from './deprecated'; | ||
|
||
// Components | ||
export { default as APIProvider } from './higher-order/with-api-data/provider'; | ||
export { default as Autocomplete } from './autocomplete'; | ||
export { default as BaseControl } from './base-control'; | ||
export { default as Button } from './button'; | ||
export { default as ButtonGroup } from './button-group'; | ||
export { default as CheckboxControl } from './checkbox-control'; | ||
export { default as ClipboardButton } from './clipboard-button'; | ||
export { default as CodeEditor } from './code-editor'; | ||
export { default as ColorPalette } from './color-palette'; | ||
export { default as Dashicon } from './dashicon'; | ||
export { DateTimePicker, DatePicker, TimePicker } from './date-time'; | ||
export { default as Disabled } from './disabled'; | ||
export { default as Draggable } from './draggable'; | ||
export { default as DropZone } from './drop-zone'; | ||
export { default as DropZoneProvider } from './drop-zone/provider'; | ||
export { default as Dropdown } from './dropdown'; | ||
export { default as DropdownMenu } from './dropdown-menu'; | ||
export { default as ExternalLink } from './external-link'; | ||
export { default as FocusableIframe } from './focusable-iframe'; | ||
export { default as FontSizePicker } from './font-size-picker'; | ||
export { default as FormFileUpload } from './form-file-upload'; | ||
export { default as FormToggle } from './form-toggle'; | ||
export { default as FormTokenField } from './form-token-field'; | ||
export { default as IconButton } from './icon-button'; | ||
export { default as KeyboardShortcuts } from './keyboard-shortcuts'; | ||
export { default as MenuGroup } from './menu-group'; | ||
export { default as MenuItem } from './menu-item'; | ||
export { default as MenuItemsChoice } from './menu-items-choice'; | ||
export { default as Modal } from './modal'; | ||
export { default as ScrollLock } from './scroll-lock'; | ||
export { NavigableMenu, TabbableContainer } from './navigable-container'; | ||
export { default as Notice } from './notice'; | ||
export { default as NoticeList } from './notice/list'; | ||
export { default as Panel } from './panel'; | ||
export { default as PanelBody } from './panel/body'; | ||
export { default as PanelColor } from './panel/color'; | ||
export { default as PanelHeader } from './panel/header'; | ||
export { default as PanelRow } from './panel/row'; | ||
export { default as Placeholder } from './placeholder'; | ||
export { default as Popover } from './popover'; | ||
export { default as QueryControls } from './query-controls'; | ||
export { default as RadioControl } from './radio-control'; | ||
export { default as RangeControl } from './range-control'; | ||
export { default as ResponsiveWrapper } from './responsive-wrapper'; | ||
export { default as SandBox } from './sandbox'; | ||
export { default as SelectControl } from './select-control'; | ||
export { default as Spinner } from './spinner'; | ||
export { default as ServerSideRender } from './server-side-render'; | ||
export { default as TabPanel } from './tab-panel'; | ||
export { default as TextControl } from './text-control'; | ||
export { default as TextareaControl } from './textarea-control'; | ||
export { default as ToggleControl } from './toggle-control'; | ||
export { default as Toolbar } from './toolbar'; | ||
export { default as Tooltip } from './tooltip'; | ||
export { default as TreeSelect } from './tree-select'; | ||
export { createSlotFill, Slot, Fill, Provider as SlotFillProvider } from './slot-fill'; | ||
|
||
// Higher-Order Components | ||
export { default as navigateRegions } from './higher-order/navigate-regions'; | ||
export { default as withAPIData } from './higher-order/with-api-data'; | ||
export { default as withContext } from './higher-order/with-context'; | ||
export { default as withConstrainedTabbing } from './higher-order/with-constrained-tabbing'; | ||
export { default as withFallbackStyles } from './higher-order/with-fallback-styles'; | ||
export { default as withFilters } from './higher-order/with-filters'; | ||
export { default as withFocusOutside } from './higher-order/with-focus-outside'; | ||
export { default as withFocusReturn } from './higher-order/with-focus-return'; | ||
export { default as withNotices } from './higher-order/with-notices'; | ||
export { default as withSpokenMessages } from './higher-order/with-spoken-messages'; | ||
export * from '../packages/components/src'; | ||
|
||
export const ifCondition = deprecated.ifCondition; | ||
export const withGlobalEvents = deprecated.withGlobalEvents; | ||
export const withInstanceId = deprecated.withInstanceId; | ||
export const withSafeTimeout = deprecated.withSafeTimeout; | ||
export const withState = deprecated.withState; | ||
import '../packages/components/src/style.scss'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a tough one to read… might be nicer to import as
deAsync
🤷♂️There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if it's nonsense, we should be strictly consistent in our camelcasing. If this were a module named
de-async
, I'd agreedeAsync
would be reasonable. Same reason we [should] useimport classnames from 'classnames';
and notimport classNames from 'classnames';
.