mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-16 10:39:53 +00:00
asdf
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
|||||||
RemoveIcon,
|
RemoveIcon,
|
||||||
ToggleBackgroundActiveIcon,
|
ToggleBackgroundActiveIcon,
|
||||||
RotateIcon,
|
RotateIcon,
|
||||||
|
MoreIcon,
|
||||||
} from '../../icons';
|
} from '../../icons';
|
||||||
import { twoUpHandle } from './custom-els/TwoUp/styles.css';
|
import { twoUpHandle } from './custom-els/TwoUp/styles.css';
|
||||||
import type { PreprocessorState } from '../../feature-meta';
|
import type { PreprocessorState } from '../../feature-meta';
|
||||||
@@ -34,6 +35,7 @@ interface State {
|
|||||||
scale: number;
|
scale: number;
|
||||||
editingScale: boolean;
|
editingScale: boolean;
|
||||||
altBackground: boolean;
|
altBackground: boolean;
|
||||||
|
menuOpen: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const scaleToOpts: ScaleToOpts = {
|
const scaleToOpts: ScaleToOpts = {
|
||||||
@@ -48,6 +50,7 @@ export default class Output extends Component<Props, State> {
|
|||||||
scale: 1,
|
scale: 1,
|
||||||
editingScale: false,
|
editingScale: false,
|
||||||
altBackground: false,
|
altBackground: false,
|
||||||
|
menuOpen: false,
|
||||||
};
|
};
|
||||||
canvasLeft?: HTMLCanvasElement;
|
canvasLeft?: HTMLCanvasElement;
|
||||||
canvasRight?: HTMLCanvasElement;
|
canvasRight?: HTMLCanvasElement;
|
||||||
@@ -160,6 +163,10 @@ export default class Output extends Component<Props, State> {
|
|||||||
this.pinchZoomLeft.scaleTo(this.state.scale / 1.25, scaleToOpts);
|
this.pinchZoomLeft.scaleTo(this.state.scale / 1.25, scaleToOpts);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private toggleMenu = () => {
|
||||||
|
this.setState(({ menuOpen }) => ({ menuOpen: !menuOpen }));
|
||||||
|
};
|
||||||
|
|
||||||
private onRotateClick = () => {
|
private onRotateClick = () => {
|
||||||
const { preprocessorState: inputProcessorState } = this.props;
|
const { preprocessorState: inputProcessorState } = this.props;
|
||||||
if (!inputProcessorState) return;
|
if (!inputProcessorState) return;
|
||||||
@@ -254,7 +261,7 @@ export default class Output extends Component<Props, State> {
|
|||||||
|
|
||||||
render(
|
render(
|
||||||
{ mobileView, leftImgContain, rightImgContain, source }: Props,
|
{ mobileView, leftImgContain, rightImgContain, source }: Props,
|
||||||
{ scale, editingScale, altBackground }: State,
|
{ scale, editingScale, altBackground, menuOpen }: State,
|
||||||
) {
|
) {
|
||||||
const leftDraw = this.leftDrawable();
|
const leftDraw = this.leftDrawable();
|
||||||
const rightDraw = this.rightDrawable();
|
const rightDraw = this.rightDrawable();
|
||||||
@@ -341,26 +348,34 @@ export default class Output extends Component<Props, State> {
|
|||||||
<button class={style.button} onClick={this.zoomIn}>
|
<button class={style.button} onClick={this.zoomIn}>
|
||||||
<AddIcon />
|
<AddIcon />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
|
||||||
<div class={style.buttonsNoWrap}>
|
|
||||||
<button
|
<button
|
||||||
class={style.button}
|
class={`${style.button} ${style.moreButton} ${
|
||||||
onClick={this.onRotateClick}
|
menuOpen ? style.open : ''
|
||||||
title="Rotate image"
|
}`}
|
||||||
|
onClick={this.toggleMenu}
|
||||||
>
|
>
|
||||||
<RotateIcon />
|
<MoreIcon />
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
class={`${style.button} ${altBackground ? style.active : ''}`}
|
|
||||||
onClick={this.toggleBackground}
|
|
||||||
title="Change canvas color"
|
|
||||||
>
|
|
||||||
{altBackground ? (
|
|
||||||
<ToggleBackgroundActiveIcon />
|
|
||||||
) : (
|
|
||||||
<ToggleBackgroundIcon />
|
|
||||||
)}
|
|
||||||
</button>
|
</button>
|
||||||
|
<aside class={`${style.menu} ${menuOpen ? style.open : ''}`}>
|
||||||
|
<button
|
||||||
|
class={style.button}
|
||||||
|
onClick={this.onRotateClick}
|
||||||
|
title="Rotate image"
|
||||||
|
>
|
||||||
|
<RotateIcon />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class={`${style.button} ${altBackground ? style.active : ''}`}
|
||||||
|
onClick={this.toggleBackground}
|
||||||
|
title="Change canvas color"
|
||||||
|
>
|
||||||
|
{altBackground ? (
|
||||||
|
<ToggleBackgroundActiveIcon />
|
||||||
|
) : (
|
||||||
|
<ToggleBackgroundIcon />
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
|
|
||||||
/* Allow clicks to fall through to the pinch zoom area */
|
/* Allow clicks to fall through to the pinch zoom area */
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|
||||||
& > * {
|
& > * {
|
||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
}
|
}
|
||||||
@@ -76,6 +77,7 @@
|
|||||||
border-bottom-left-radius: 0;
|
border-bottom-left-radius: 0;
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
& :not(:last-child) {
|
& :not(:last-child) {
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
border-right-width: 0;
|
border-right-width: 0;
|
||||||
@@ -90,46 +92,97 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
margin: 4px;
|
margin: 4px;
|
||||||
background-color: #fff;
|
background-color: rgba(29, 29, 29, 0.92);
|
||||||
border: 1px solid rgba(0, 0, 0, 0.2);
|
border: 1px solid rgba(0, 0, 0, 0.67);
|
||||||
border-radius: 5px;
|
border-radius: 6px;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
height: 36px;
|
height: 39px;
|
||||||
padding: 0 8px;
|
padding: 0 8px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
|
/*
|
||||||
@media (min-width: 600px) {
|
@media (min-width: 600px) {
|
||||||
height: 48px;
|
height: 39px;
|
||||||
padding: 0 16px;
|
padding: 0 16px;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
&:focus {
|
&:focus {
|
||||||
box-shadow: 0 0 0 2px var(--button-fg);
|
box-shadow: 0 0 0 2px #fff;
|
||||||
outline: none;
|
outline: none;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
color: var(--button-fg);
|
color: #fff;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: #eee;
|
/* background-color: #eee; */
|
||||||
|
background: rgba(40, 40, 40, 0.92);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
background: #34b9eb;
|
background: rgba(72, 72, 72, 0.92);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
|
||||||
|
/*
|
||||||
&:hover {
|
&:hover {
|
||||||
background: #32a3ce;
|
background: rgba(72, 72, 72, 0.92);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.moreButton {
|
||||||
|
padding: 0 4px;
|
||||||
|
|
||||||
|
&.open {
|
||||||
|
background: rgba(72, 72, 72, 0.92);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu {
|
||||||
|
display: inline-block;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
bottom: 100%;
|
||||||
|
z-index: 100;
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: flex-start;
|
||||||
|
display: none;
|
||||||
|
|
||||||
|
&.open {
|
||||||
|
display: block;
|
||||||
|
animation: menuOpen 500ms ease forwards 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
margin-top: 8px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
border-radius: 1.2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
h5 {
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: #fff;
|
||||||
|
margin: 8px 4px;
|
||||||
|
padding: 10px 0 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes menuOpen {
|
||||||
|
0% {
|
||||||
|
transform: translateY(10px) scale(0.8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.zoom {
|
.zoom {
|
||||||
color: #625e80;
|
color: #939393;
|
||||||
cursor: text;
|
cursor: text;
|
||||||
width: 6em;
|
width: 6em;
|
||||||
font: inherit;
|
font: inherit;
|
||||||
@@ -137,7 +190,7 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
||||||
&:focus {
|
&:focus {
|
||||||
box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.2), 0 0 0 2px var(--button-fg);
|
box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.2), 0 0 0 2px #fff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +198,7 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
top: 1px;
|
top: 1px;
|
||||||
margin: 0 3px 0 0;
|
margin: 0 3px 0 0;
|
||||||
color: #888;
|
color: #fff;
|
||||||
border-bottom: 1px dashed #999;
|
border-bottom: 1px dashed #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,14 @@ export const RotateIcon = (props: preact.JSX.HTMLAttributes) => (
|
|||||||
</Icon>
|
</Icon>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const MoreIcon = (props: preact.JSX.HTMLAttributes) => (
|
||||||
|
<Icon {...props}>
|
||||||
|
<circle cx="12" cy="6" r="2" fill="#fff" />
|
||||||
|
<circle cx="12" cy="12" r="2" fill="#fff" />
|
||||||
|
<circle cx="12" cy="18" r="2" fill="#fff" />
|
||||||
|
</Icon>
|
||||||
|
);
|
||||||
|
|
||||||
export const AddIcon = (props: preact.JSX.HTMLAttributes) => (
|
export const AddIcon = (props: preact.JSX.HTMLAttributes) => (
|
||||||
<Icon {...props}>
|
<Icon {...props}>
|
||||||
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
|
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
|
||||||
|
|||||||
Reference in New Issue
Block a user