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

Saved Templates: fix buttons being hidden under elements #12610

Merged
merged 3 commits into from
Nov 10, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ PreviewPageWrapper.propTypes = {
pageSize: PageSizePropType.isRequired,
};

const ElementsWrapper = styled.div`
z-index: 10;
`;

const TemplateInsertionOverlay = styled(InsertionOverlay)`
z-index: 11;
`;

const DeleteButton = styled(ActionButton)`
top: 4px;
right: 4px;
Expand Down Expand Up @@ -218,18 +226,24 @@ function SavedPageTemplate(
draggable={false}
/>
) : (
<UnitsProvider
pageSize={{
height: pageSize.height,
width: pageSize.width,
}}
>
{page.elements.map((element) => (
<DisplayElement key={element.id} previewMode element={element} />
))}
</UnitsProvider>
<ElementsWrapper>
<UnitsProvider
pageSize={{
height: pageSize.height,
width: pageSize.width,
}}
>
{page.elements.map((element) => (
<DisplayElement
key={element.id}
previewMode
element={element}
/>
))}
</UnitsProvider>
</ElementsWrapper>
)}
{isActive && <InsertionOverlay showIcon={false} />}
{isActive && <TemplateInsertionOverlay showIcon={false} />}
<ActionButton
ref={insertButtonRef}
onClick={(e) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
import styled, { css } from 'styled-components';
import { Button, BUTTON_VARIANTS } from '@googleforcreators/design-system';

/**
* Internal dependencies
*/
import { Z_INDEX_LIBRARY_ACTION_BUTTON } from '../../../../constants/zIndex';

export const PANE_PADDING = '1em';

const Pane = styled.section.attrs(({ isActive }) => ({
Expand Down Expand Up @@ -62,6 +67,7 @@ const ActionButton = styled(Button).attrs({ variant: BUTTON_VARIANTS.ICON })`
width: ${ACTION_BUTTON_SIZE}px;
height: ${ACTION_BUTTON_SIZE}px;
opacity: ${({ $display }) => ($display ? '1' : '0')};
z-index: ${Z_INDEX_LIBRARY_ACTION_BUTTON};
`;

const PageTemplateTitleContainer = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ const Scrim = styled.div`
pointer-events: none;
`;

function InsertionOverlay({ showIcon = true }) {
function InsertionOverlay({ showIcon = true, className = '' }) {
// The icon looks like a button but is just representational.
// The real interactive element is the containing element.
// If the showIcon is `false`, we still display the scrim for shade.
return (
<Scrim>
<Scrim className={className}>
{showIcon && (
<IconContainer role="presentation">
<Icons.PlusFilledSmall />
Expand All @@ -66,6 +66,7 @@ function InsertionOverlay({ showIcon = true }) {

InsertionOverlay.propTypes = {
showIcon: PropTypes.bool,
className: PropTypes.string,
};

export default InsertionOverlay;
3 changes: 3 additions & 0 deletions packages/story-editor/src/constants/zIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ export const Z_INDEX_GRID_VIEW_SLIDER = 11;
// In PublishTime, the time picker's tooltip's z-index needs to be higher than
// the z-index of the date picker popup itself.
export const Z_INDEX_TIME_PICKER_TOOLTIP = 11;

// In the library, the action button has to be on top of the other layers.
export const Z_INDEX_LIBRARY_ACTION_BUTTON = 20;