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

Assembler: Allow to zoom out the preview #83034

Merged
merged 15 commits into from
Oct 24, 2023
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 @@ -64,6 +64,6 @@ export const PATTERN_ASSEMBLER_EVENTS = {
/**
* Large Preview
*/
LARGE_PREVIEW_ADD_HEADER_BUTTON_CLICK:
'calypso_signup_pattern_assembler_large_preview_add_header_button_click',
LARGE_PREVIEW_ZOOM_OUT_SCALE_CHANGE:
'calypso_signup_pattern_assembler_large_preview_zoom_out_scale_change',
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,6 @@ const PatternAssembler = ( props: StepProps & NoticesProps ) => {

return (
<StepContainer
className="pattern-assembler__sidebar-revamp"
stepName="pattern-assembler"
stepSectionName={ currentScreen.name }
backLabelText={
Expand Down
Original file line number Diff line number Diff line change
@@ -1,54 +1,90 @@
.pattern-assembler {
.pattern-action-bar {
.pattern-assembler__pattern-action-bar {
display: flex;
align-items: center;
gap: 0;
position: absolute;
top: 16px;
left: 16px;
height: 40px;
padding: 0;
border: 1px solid #1e1e1e;
border-radius: 2px;
box-sizing: border-box;
background-color: #fff;
z-index: 1;

&.pattern-assembler__pattern-action-bar--overflow {
transform: translate(-16px, calc(-100% - 16px - 12px));

&::before {
display: block;
}
}

.pattern-action-bar__block {
flex-direction: column;
display: flex;
opacity: 0;
align-items: center;
position: absolute;
justify-content: center;
}

.pattern-action-bar__action {
height: 40px;
right: 0;

.pattern-action-bar__block {
flex-direction: column;
display: flex;
align-items: center;
justify-content: center;
&.has-icon {
min-width: 40px;
max-width: 40px;
padding: 0;
}

.pattern-action-bar__action {
&.has-icon {
min-width: 40px;
max-width: 40px;
padding: 0;
}
svg {
fill: var(--studio-gray-80);
}

&:not(:disabled):hover {
color: var(--studio-blue-50);

svg {
fill: var(--studio-gray-80);
fill: var(--studio-blue-50);
}
}

&:not(:disabled):hover {
color: var(--studio-blue-50);
&--move-up,
&--move-down {
height: 13px;
display: flex;
align-items: center;
}

svg {
fill: var(--studio-blue-50);
}
&--shuffle {
&.has-icon {
flex-direction: row;
gap: 4px;
line-height: 40px;
max-width: none;
padding: 0 12px;
}
}
}

&--move-up,
&--move-down {
height: 13px;
display: flex;
align-items: center;
}
> .pattern-action-bar__action:not(:first-child) {
border-left: 1px solid #1e1e1e;
}

&--shuffle {
&.has-icon {
flex-direction: row;
gap: 4px;
line-height: 40px;
max-width: none;
padding: 0 12px;
}
}
}
/**
* Increase the area of the action bar to keep the element active
* when hovering on the the action bar
*/
&::before {
content: "";
display: none;
position: absolute;
top: -12px;
left: -12px;
width: 100%;
height: 100%;
padding: 12px 12px 20px 12px;
box-sizing: content-box;
z-index: -1;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Button } from '@wordpress/components';
import { chevronUp, chevronDown, edit, shuffle, trash } from '@wordpress/icons';
import classnames from 'classnames';
import { useTranslate } from 'i18n-calypso';
import React from 'react';
import { recordTracksEvent } from 'calypso/lib/analytics/tracks';
import { PATTERN_ASSEMBLER_EVENTS } from './events';
import type { Category } from './types';
Expand All @@ -12,11 +14,13 @@ type PatternActionBarProps = {
onMoveUp?: () => void;
onMoveDown?: () => void;
onShuffle: () => void;
onMouseLeave?: ( event: React.MouseEvent< HTMLElement > ) => void;
disableMoveUp?: boolean;
disableMoveDown?: boolean;
patternType: string;
category?: Category;
source: 'list' | 'large_preview';
isOverflow?: boolean;
};

const PatternActionBar = ( {
Expand All @@ -25,11 +29,13 @@ const PatternActionBar = ( {
onMoveUp,
onMoveDown,
onShuffle,
onMouseLeave,
disableMoveUp,
disableMoveDown,
patternType,
category,
source,
isOverflow,
}: PatternActionBarProps ) => {
const translate = useTranslate();
const eventProps = {
Expand All @@ -39,10 +45,14 @@ const PatternActionBar = ( {
};

return (
// eslint-disable-next-line jsx-a11y/interactive-supports-focus
<div
className="pattern-action-bar"
className={ classnames( 'pattern-assembler__pattern-action-bar', {
'pattern-assembler__pattern-action-bar--overflow': isOverflow,
} ) }
role="menubar"
aria-label={ translate( 'Pattern actions' ) }
onMouseLeave={ onMouseLeave }
>
{ onMoveUp && onMoveDown && (
<div className="pattern-action-bar__block">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,45 +37,6 @@
$pattern-large-preview-outer-border-radius: calc(var(--device-switcher-border-radius) - var(--device-switcher-border-width));
position: relative;

.pattern-action-bar {
box-sizing: border-box;
position: absolute;
top: 16px;
left: 16px;
right: unset;
padding: 0;
border: 1px solid #1e1e1e;
border-radius: 2px;
gap: 0;
background-color: #fff;
opacity: 0;
z-index: 1;
// Scale up the action bar in fixed viewport
transform: scale(calc(1 / var(--viewport-scale)));
transform-origin: top left;

> .pattern-action-bar__action {
position: relative;
min-height: 40px;
min-width: 40px;
padding: 2px;

&:first-child::after {
content: none;
}

&::after {
background-color: #1e1e1e;
bottom: 0;
content: "";
left: 0;
position: absolute;
top: 0;
width: 1px;
}
}
}

&::after {
content: "";
position: absolute;
Expand All @@ -96,16 +57,13 @@
border-bottom-right-radius: $pattern-large-preview-outer-border-radius;
}

&--active,
&:hover,
&:focus,
&:focus-within {
.pattern-action-bar {
opacity: 1;
}

&::after {
// Scale up the border of a hovered pattern in fixed viewport
border: calc(2px * (1 / var(--viewport-scale))) solid var(--color-primary-light);
// Scale up the border of a active pattern
border: calc(2px * (1 / var(--viewport-scale) / var(--pattern-large-preview-zoom-out-scale))) solid var(--color-primary-light);
}
}
}
Expand Down
Loading
Loading