Skip to content
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

Theme package for generating admin themes #54541

Open
wants to merge 10 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"@wordpress/shortcode": "file:packages/shortcode",
"@wordpress/style-engine": "file:packages/style-engine",
"@wordpress/sync": "file:packages/sync",
"@wordpress/theme": "file:packages/theme",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably run npm i to generate updates to package-lock.json

"@wordpress/token-list": "file:packages/token-list",
"@wordpress/undo-manager": "file:packages/undo-manager",
"@wordpress/url": "file:packages/url",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { css } from '@emotion/react';
/**
* Internal dependencies
*/
import { baseLabelTypography, boxSizingReset, font, COLORS } from '../../utils';
import { baseLabelTypography, boxSizingReset, font } from '../../utils';
import { space } from '../../ui/utils/space';

export const Wrapper = styled.div`
Expand Down Expand Up @@ -64,7 +64,7 @@ export const StyledHelp = styled.p`
margin-bottom: 0;
font-size: ${ font( 'helpText.fontSize' ) };
font-style: normal;
color: ${ COLORS.gray[ 700 ] };
color: var( --wp-theme-color-neutral-text-muted );

${ deprecatedMarginHelp }
`;
Expand Down
9 changes: 4 additions & 5 deletions packages/components/src/button/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
box-sizing: border-box;
padding: 6px 12px;
border-radius: $radius-block-ui;
color: $components-color-foreground;
color: var(--wp-theme-color-neutral-text);

&.is-next-40px-default-size {
height: $button-size-next-default-40px;
Expand Down Expand Up @@ -48,17 +48,16 @@

&.is-primary {
white-space: nowrap;
background: $components-color-accent;
color: $components-color-accent-inverted;
background: var(--wp-theme-color-primary-bg-strong);
color: var(--wp-theme-color-primary-text-inverse-strong);
text-decoration: none;
text-shadow: none;

// Show the boundary of the button, in High Contrast Mode.
outline: 1px solid transparent;

&:hover:not(:disabled) {
background: $components-color-accent-darker-10;
color: $components-color-accent-inverted;
background: var(--wp-theme-color-primary-bg-strong-hover);
}

&:active:not(:disabled) {
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/heading/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { WordPressComponentProps } from '../ui/context';
import { useContextSystem } from '../ui/context';
import { useText } from '../text';
import { getHeadingFontSize } from '../ui/utils/font-size';
import { CONFIG, COLORS } from '../utils';
import { CONFIG } from '../utils';
import type { HeadingProps } from './types';

export function useHeading(
Expand All @@ -31,7 +31,7 @@ export function useHeading(
}

const textProps = useText( {
color: COLORS.gray[ 900 ],
color: 'var(--wp-theme-color-neutral-text-strong)',
size: getHeadingFontSize( level ),
isBlock: true,
weight: CONFIG.fontWeightHeading as import('react').CSSProperties[ 'fontWeight' ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export const Root = styled( Flex )< RootProps >`

const containerDisabledStyles = ( { disabled }: ContainerProps ) => {
const backgroundColor = disabled
? COLORS.ui.backgroundDisabled
: COLORS.ui.background;
? 'var(--wp-theme-color-neutral-bg-disabled)'
: 'var(--wp-theme-color-neutral-bg-input)';

return css( { backgroundColor } );
};
Expand Down Expand Up @@ -211,7 +211,7 @@ export const Input = styled.input< InputProps >`
box-sizing: border-box;
border: none;
box-shadow: none !important;
color: ${ COLORS.gray[ 900 ] };
color: var( --wp-theme-color-neutral-text-strong );
display: block;
font-family: inherit;
margin: 0;
Expand Down Expand Up @@ -268,7 +268,9 @@ const backdropFocusedStyles = ( {
disabled,
isFocused,
}: BackdropProps ): SerializedStyles => {
let borderColor = isFocused ? COLORS.ui.borderFocus : COLORS.ui.border;
let borderColor = isFocused
? 'var(--wp-theme-color-neutral-border-strong-hover)'
: 'var(--wp-theme-color-neutral-border-strong)';

let boxShadow;
let outline;
Expand All @@ -282,7 +284,7 @@ const backdropFocusedStyles = ( {
}

if ( disabled ) {
borderColor = COLORS.ui.borderDisabled;
borderColor = 'var(--wp-theme-color-neutral-border-disabled)';
}

return css( {
Expand Down
8 changes: 5 additions & 3 deletions packages/components/src/search-control/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

input[type="search"].components-search-control__input {
@include input-control;
color: var(--wp-theme-color-neutral-text-strong);
display: block;
padding: $grid-unit-20 $grid-unit-60 $grid-unit-20 $grid-unit-20;
background: $gray-100;
background: var(--wp-theme-color-neutral-bg);
border: none;
width: 100%;
height: $grid-unit-60;
Expand All @@ -21,12 +22,12 @@
}

&:focus {
background: $white;
background: var(--wp-theme-color-neutral-bg-input);
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent;
}

&::placeholder {
color: $gray-700;
color: var(--wp-theme-color-neutral-text-muted);
}

&::-webkit-search-decoration,
Expand All @@ -49,6 +50,7 @@
justify-content: center;

> svg {
fill: var(--wp-theme-color-neutral-text);
margin: $grid-unit-10 0;
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/text/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { css } from '@emotion/react';
import { COLORS, CONFIG } from '../utils';

export const Text = css`
color: ${ COLORS.gray[ 900 ] };
color: var( --wp-theme-color-neutral-text );
line-height: ${ CONFIG.fontLineHeightBase };
margin: 0;
`;
Expand All @@ -27,7 +27,7 @@ export const destructive = css`
`;

export const muted = css`
color: ${ COLORS.gray[ 700 ] };
color: var( --wp-theme-color-neutral-text-muted );
`;

export const highlighterText = css`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const buttonView = ( {
background: transparent;
border: none;
border-radius: ${ CONFIG.controlBorderRadius };
color: ${ COLORS.gray[ 700 ] };
color: var( --wp-theme-color-neutral-text );
fill: currentColor;
cursor: pointer;
display: flex;
Expand All @@ -62,7 +62,7 @@ export const buttonView = ( {
}

&:active {
background: ${ CONFIG.toggleGroupControlBackgroundColor };
background: var( --wp-theme-color-neutral-bg-strong );
}

${ isDeselectable && deselectable }
Expand All @@ -71,7 +71,7 @@ export const buttonView = ( {
`;

const pressed = css`
color: ${ COLORS.white };
color: var( --wp-theme-color-neutral-text-strong );

&:active {
background: transparent;
Expand Down Expand Up @@ -111,7 +111,7 @@ const isIconStyles = ( {
};

export const backdropView = css`
background: ${ COLORS.gray[ 900 ] };
background: var( --wp-theme-color-neutral-bg-active );
border-radius: ${ CONFIG.controlBorderRadius };
position: absolute;
inset: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const toggleGroupControl = ( {
}: Pick< ToggleGroupControlProps, 'isBlock' | 'isDeselectable' > & {
size: NonNullable< ToggleGroupControlProps[ 'size' ] >;
} ) => css`
background: ${ COLORS.ui.background };
background: var( --wp-theme-color-neutral-bg-input );
border: 1px solid transparent;
border-radius: ${ CONFIG.controlBorderRadius };
display: inline-flex;
Expand All @@ -31,14 +31,14 @@ export const toggleGroupControl = ( {

const enclosingBorders = ( isBlock: ToggleGroupControlProps[ 'isBlock' ] ) => {
const enclosingBorder = css`
border-color: ${ COLORS.ui.border };
border-color: var( --wp-theme-color-neutral-border-strong );
`;

return css`
${ isBlock && enclosingBorder }

&:hover {
border-color: ${ COLORS.ui.borderHover };
border-color: var( --wp-theme-color-neutral-border-strong-hover );
}

&:focus-within {
Expand Down
1 change: 1 addition & 0 deletions packages/edit-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"@wordpress/reusable-blocks": "file:../reusable-blocks",
"@wordpress/router": "file:../router",
"@wordpress/style-engine": "file:../style-engine",
"@wordpress/theme": "file:../theme",
"@wordpress/url": "file:../url",
"@wordpress/viewport": "file:../viewport",
"@wordpress/widgets": "file:../widgets",
Expand Down
21 changes: 12 additions & 9 deletions packages/edit-site/src/components/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* WordPress dependencies
*/
import { SlotFillProvider } from '@wordpress/components';
import { ThemeProvider } from '@wordpress/theme';
import { UnsavedChangesWarning } from '@wordpress/editor';
import { store as noticesStore } from '@wordpress/notices';
import { useDispatch } from '@wordpress/data';
Expand Down Expand Up @@ -34,14 +35,16 @@ export default function App() {
}

return (
<SlotFillProvider>
<GlobalStylesProvider>
<UnsavedChangesWarning />
<RouterProvider>
<Layout />
<PluginArea onError={ onPluginAreaError } />
</RouterProvider>
</GlobalStylesProvider>
</SlotFillProvider>
<ThemeProvider isDark className="edit-site-theme">
<SlotFillProvider>
<GlobalStylesProvider>
<UnsavedChangesWarning />
<RouterProvider>
<Layout />
<PluginArea onError={ onPluginAreaError } />
</RouterProvider>
</GlobalStylesProvider>
</SlotFillProvider>
</ThemeProvider>
);
}
17 changes: 11 additions & 6 deletions packages/edit-site/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import classnames from 'classnames';
* WordPress dependencies
*/
import { useSelect } from '@wordpress/data';
import { ThemeProvider } from '@wordpress/theme';
import {
__unstableMotion as motion,
__unstableAnimatePresence as AnimatePresence,
Expand Down Expand Up @@ -256,7 +257,9 @@ export default function Layout() {
ease: 'easeOut',
} }
>
<Header />
<ThemeProvider className="edit-site-layout_header-wrapper">
<Header />
</ThemeProvider>
</NavigableRegion>
) }
</AnimatePresence>
Expand Down Expand Up @@ -368,11 +371,13 @@ export default function Layout() {
backgroundColor,
} }
>
<Editor
isLoading={
isEditorLoading
}
/>
<ThemeProvider className="edit-site-editor-wrapper">
<Editor
isLoading={
isEditorLoading
}
/>
</ThemeProvider>
</ResizableFrame>
</ErrorBoundary>
</motion.div>
Expand Down
4 changes: 2 additions & 2 deletions packages/edit-site/src/components/layout/style.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.edit-site-layout {
height: 100%;
background: $gray-900;
color: $gray-400;
background: var(--wp-theme-color-neutral-bg-muted);
color: var(--wp-theme-color-neutral-text);
display: flex;
flex-direction: column;
}
Expand Down
Loading
Loading