Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 packages/grid/src/grid-item.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
opacity: 0.4;
pointer-events: none;
outline: var(--wpds-border-width-sm) dashed var(--wpds-color-stroke-interactive-brand);
border-radius: var(--wpds-border-radius-lg);
}

@media (forced-colors: active) {
Expand Down
4 changes: 3 additions & 1 deletion packages/grid/src/grid.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
.drag-preview {
height: 100%;
transform: scale(1.05);
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.15);
box-shadow: var(--wpds-elevation-md);
cursor: grabbing;
border-radius: var(--wpds-border-radius-lg);
overflow: hidden;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@retrofox, do you think it should be possible to apply these styles from the consumer / Dashboard side rather than in the grid library?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it makes total sense. I'd try to follow a DS UI pattern, probably just adding a className prop?

}

@media (prefers-reduced-motion: reduce) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
.editActionsEnter,
.editActionsExit {
display: inline-flex;
gap: var(--wp--preset--spacing--20);
transform-origin: right center;
}

@media not ( prefers-reduced-motion ) {
.editActionsEnter,
.editActionsExit {
will-change: opacity, transform;
}

.editActionsEnter {
animation: actions-slide-in 220ms ease-out forwards;
}

.editActionsExit {
animation: actions-fold-out 50ms ease-in forwards;
}

@keyframes actions-slide-in {
from {
opacity: 0;
transform: translateX(12px) scaleX(0.92);
}

to {
opacity: 1;
transform: translateX(0) scaleX(1);
}
}

@keyframes actions-fold-out {
from {
opacity: 1;
transform: translateX(0) scaleX(1);
}

to {
opacity: 0;
transform: translateX(12px) scaleX(0.92);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/**
* WordPress dependencies
*/
import { useCallback } from '@wordpress/element';
import { useCallback, useEffect, useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
// eslint-disable-next-line @wordpress/use-recommended-components
import { Button, Stack } from '@wordpress/ui';

/**
* Internal dependencies
*/
import styles from './actions.module.css';
import { useDashboardInternalContext } from '../../context/dashboard-context';

/**
Expand All @@ -24,6 +25,29 @@ import { useDashboardInternalContext } from '../../context/dashboard-context';
*/
export function Actions(): React.ReactNode {
const { editMode, onEditChange } = useDashboardInternalContext();
const [ isEditActionsMounted, setIsEditActionsMounted ] =
useState( editMode );
const [ isExitingEditActions, setIsExitingEditActions ] = useState( false );

useEffect( () => {
if ( editMode ) {
setIsEditActionsMounted( true );
setIsExitingEditActions( false );
return;
}

if ( ! isEditActionsMounted ) {
return;
}

setIsExitingEditActions( true );
const exitTimeout = setTimeout( () => {
setIsEditActionsMounted( false );
setIsExitingEditActions( false );
}, 220 );

return () => clearTimeout( exitTimeout );
}, [ editMode, isEditActionsMounted ] );

const handleEditMode = useCallback( () => {
onEditChange?.( ! editMode );
Expand Down Expand Up @@ -52,8 +76,16 @@ export function Actions(): React.ReactNode {

return (
<Stack direction="row" gap="sm">
{ editMode ? (
<>
{ isEditActionsMounted ? (
<Stack
direction="row"
gap="sm"
className={
isExitingEditActions
? styles.editActionsExit
: styles.editActionsEnter
}
>
<Button
variant="minimal"
tone="brand"
Expand All @@ -78,7 +110,7 @@ export function Actions(): React.ReactNode {
>
{ __( 'Done' ) }
</Button>
</>
</Stack>
) : (
<Button
variant="outline"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
.grid {
width: 100%;
}

.tile {
height: 100%;
border-radius: var(--wpds-border-radius-lg);
}

.tileEditMode {
box-shadow: var(--wpds-elevation-xs);
}

.tileEditMode:hover,
.tileEditMode:focus-visible {
box-shadow: var(--wpds-elevation-md);
}

.tileEditMode:focus-visible {
outline: var(--wpds-border-width-focus) solid var(--wpds-color-stroke-focus-brand);
outline-offset: 2px;
}

@media not ( prefers-reduced-motion ) {
.tile {
transition: box-shadow 180ms ease;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@ export const Widgets = forwardRef< HTMLDivElement, WidgetsProps >(
);

const children = layout.map( ( widget, index ) => (
<WidgetChrome
<div

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added a separate tile wrapper for now, but I think these styles could move back to WidgetChrome directly.

key={ widget.uuid }
widget={ widget }
index={ index }
/>
className={ clsx( styles.tile, {
[ styles.tileEditMode ]: editMode,
} ) }
tabIndex={ editMode ? 0 : undefined }
>
<WidgetChrome widget={ widget } index={ index } />
</div>
) );

const sharedProps = {
Expand Down
Loading