mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-18 11:39:08 +00:00
Arrow revealer
This commit is contained in:
21
src/client/lazy-app/Compress/Options/Revealer/index.tsx
Normal file
21
src/client/lazy-app/Compress/Options/Revealer/index.tsx
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { h, Component } from 'preact';
|
||||||
|
import * as style from './style.css';
|
||||||
|
import 'add-css:./style.css';
|
||||||
|
import { Arrow } from '../../../icons';
|
||||||
|
|
||||||
|
interface Props extends preact.JSX.HTMLAttributes {}
|
||||||
|
interface State {}
|
||||||
|
|
||||||
|
export default class Revealer extends Component<Props, State> {
|
||||||
|
render(props: Props) {
|
||||||
|
return (
|
||||||
|
<div class={style.checkbox}>
|
||||||
|
{/* @ts-ignore - TS bug https://github.com/microsoft/TypeScript/issues/16019 */}
|
||||||
|
<input class={style.realCheckbox} type="checkbox" {...props} />
|
||||||
|
<div class={style.arrow}>
|
||||||
|
<Arrow />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
29
src/client/lazy-app/Compress/Options/Revealer/style.css
Normal file
29
src/client/lazy-app/Compress/Options/Revealer/style.css
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
.checkbox {
|
||||||
|
display: inline-block;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.arrow {
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
fill: var(--white);
|
||||||
|
transition: transform 200ms ease;
|
||||||
|
transform: rotate(-90deg);
|
||||||
|
|
||||||
|
svg {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.real-checkbox {
|
||||||
|
top: 0;
|
||||||
|
position: absolute;
|
||||||
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
|
||||||
|
&:checked + .arrow {
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
import * as style from './style.css';
|
import * as style from './style.css';
|
||||||
import 'add-css:./style.css';
|
import 'add-css:./style.css';
|
||||||
import { UncheckedIcon, CheckedIcon } from '../../../icons';
|
|
||||||
|
|
||||||
interface Props extends preact.JSX.HTMLAttributes {}
|
interface Props extends preact.JSX.HTMLAttributes {}
|
||||||
interface State {}
|
interface State {}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
display: grid;
|
display: grid;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
grid-template-columns: 87px 1fr;
|
grid-template-columns: 87px 1fr;
|
||||||
grid-gap: 0.7em;
|
gap: 0.7em;
|
||||||
padding: 10px var(--horizontal-padding);
|
padding: 10px var(--horizontal-padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,10 +36,16 @@
|
|||||||
display: grid;
|
display: grid;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
grid-template-columns: 1fr auto;
|
grid-template-columns: 1fr auto;
|
||||||
grid-gap: 0.7em;
|
gap: 0.7em;
|
||||||
padding: 10px var(--horizontal-padding);
|
padding: 10px var(--horizontal-padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.option-reveal {
|
||||||
|
composes: option-toggle;
|
||||||
|
grid-template-columns: auto 1fr;
|
||||||
|
gap: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
.option-one-cell {
|
.option-one-cell {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import Expander from 'client/lazy-app/Compress/Options/Expander';
|
|||||||
import Select from 'client/lazy-app/Compress/Options/Select';
|
import Select from 'client/lazy-app/Compress/Options/Select';
|
||||||
import Range from 'client/lazy-app/Compress/Options/Range';
|
import Range from 'client/lazy-app/Compress/Options/Range';
|
||||||
import linkState from 'linkstate';
|
import linkState from 'linkstate';
|
||||||
|
import Revealer from 'client/lazy-app/Compress/Options/Revealer';
|
||||||
|
|
||||||
export const encode = (
|
export const encode = (
|
||||||
signal: AbortSignal,
|
signal: AbortSignal,
|
||||||
@@ -288,12 +289,12 @@ export class Options extends Component<Props, State> {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Expander>
|
</Expander>
|
||||||
<label class={style.optionToggle}>
|
<label class={style.optionReveal}>
|
||||||
Show advanced settings
|
<Revealer
|
||||||
<Checkbox
|
|
||||||
checked={showAdvanced}
|
checked={showAdvanced}
|
||||||
onChange={linkState(this, 'showAdvanced')}
|
onChange={linkState(this, 'showAdvanced')}
|
||||||
/>
|
/>
|
||||||
|
Advanced settings
|
||||||
</label>
|
</label>
|
||||||
<Expander>
|
<Expander>
|
||||||
{showAdvanced && (
|
{showAdvanced && (
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import Range from 'client/lazy-app/Compress/Options/Range';
|
|||||||
import Checkbox from 'client/lazy-app/Compress/Options/Checkbox';
|
import Checkbox from 'client/lazy-app/Compress/Options/Checkbox';
|
||||||
import Expander from 'client/lazy-app/Compress/Options/Expander';
|
import Expander from 'client/lazy-app/Compress/Options/Expander';
|
||||||
import Select from 'client/lazy-app/Compress/Options/Select';
|
import Select from 'client/lazy-app/Compress/Options/Select';
|
||||||
|
import Revealer from 'client/lazy-app/Compress/Options/Revealer';
|
||||||
|
|
||||||
export function encode(
|
export function encode(
|
||||||
signal: AbortSignal,
|
signal: AbortSignal,
|
||||||
@@ -116,12 +117,12 @@ export class Options extends Component<Props, State> {
|
|||||||
Quality:
|
Quality:
|
||||||
</Range>
|
</Range>
|
||||||
</div>
|
</div>
|
||||||
<label class={style.optionToggle}>
|
<label class={style.optionReveal}>
|
||||||
Show advanced settings
|
<Revealer
|
||||||
<Checkbox
|
|
||||||
checked={showAdvanced}
|
checked={showAdvanced}
|
||||||
onChange={linkState(this, 'showAdvanced')}
|
onChange={linkState(this, 'showAdvanced')}
|
||||||
/>
|
/>
|
||||||
|
Advanced settings
|
||||||
</label>
|
</label>
|
||||||
<Expander>
|
<Expander>
|
||||||
{showAdvanced ? (
|
{showAdvanced ? (
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import Range from 'client/lazy-app/Compress/Options/Range';
|
|||||||
import Checkbox from 'client/lazy-app/Compress/Options/Checkbox';
|
import Checkbox from 'client/lazy-app/Compress/Options/Checkbox';
|
||||||
import Expander from 'client/lazy-app/Compress/Options/Expander';
|
import Expander from 'client/lazy-app/Compress/Options/Expander';
|
||||||
import Select from 'client/lazy-app/Compress/Options/Select';
|
import Select from 'client/lazy-app/Compress/Options/Select';
|
||||||
|
import Revealer from 'client/lazy-app/Compress/Options/Revealer';
|
||||||
|
|
||||||
export const encode = (
|
export const encode = (
|
||||||
signal: AbortSignal,
|
signal: AbortSignal,
|
||||||
@@ -224,12 +225,12 @@ export class Options extends Component<Props, State> {
|
|||||||
Quality:
|
Quality:
|
||||||
</Range>
|
</Range>
|
||||||
</div>
|
</div>
|
||||||
<label class={style.optionToggle}>
|
<label class={style.optionReveal}>
|
||||||
Show advanced settings
|
<Revealer
|
||||||
<Checkbox
|
|
||||||
checked={showAdvanced}
|
checked={showAdvanced}
|
||||||
onChange={linkState(this, 'showAdvanced')}
|
onChange={linkState(this, 'showAdvanced')}
|
||||||
/>
|
/>
|
||||||
|
Advanced settings
|
||||||
</label>
|
</label>
|
||||||
<Expander>
|
<Expander>
|
||||||
{showAdvanced ? (
|
{showAdvanced ? (
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import Select from 'client/lazy-app/Compress/Options/Select';
|
|||||||
import Checkbox from 'client/lazy-app/Compress/Options/Checkbox';
|
import Checkbox from 'client/lazy-app/Compress/Options/Checkbox';
|
||||||
import Expander from 'client/lazy-app/Compress/Options/Expander';
|
import Expander from 'client/lazy-app/Compress/Options/Expander';
|
||||||
import linkState from 'linkstate';
|
import linkState from 'linkstate';
|
||||||
|
import Revealer from 'client/lazy-app/Compress/Options/Revealer';
|
||||||
|
|
||||||
export const encode = (
|
export const encode = (
|
||||||
signal: AbortSignal,
|
signal: AbortSignal,
|
||||||
@@ -212,12 +213,12 @@ export class Options extends Component<Props, State> {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Expander>
|
</Expander>
|
||||||
<label class={style.optionToggle}>
|
<label class={style.optionReveal}>
|
||||||
Show advanced settings
|
<Revealer
|
||||||
<Checkbox
|
|
||||||
checked={showAdvanced}
|
checked={showAdvanced}
|
||||||
onChange={linkState(this, 'showAdvanced')}
|
onChange={linkState(this, 'showAdvanced')}
|
||||||
/>
|
/>
|
||||||
|
Advanced settings
|
||||||
</label>
|
</label>
|
||||||
<Expander>
|
<Expander>
|
||||||
{showAdvanced && (
|
{showAdvanced && (
|
||||||
|
|||||||
Reference in New Issue
Block a user