Arrow revealer

This commit is contained in:
Jake Archibald
2020-12-07 14:19:01 +00:00
parent 6b2e15ab37
commit bf8b78657d
8 changed files with 74 additions and 15 deletions

View 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>
);
}
}

View 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;
}
}

View File

@@ -1,7 +1,6 @@
import { h, Component } from 'preact';
import * as style from './style.css';
import 'add-css:./style.css';
import { UncheckedIcon, CheckedIcon } from '../../../icons';
interface Props extends preact.JSX.HTMLAttributes {}
interface State {}

View File

@@ -27,7 +27,7 @@
display: grid;
align-items: center;
grid-template-columns: 87px 1fr;
grid-gap: 0.7em;
gap: 0.7em;
padding: 10px var(--horizontal-padding);
}
@@ -36,10 +36,16 @@
display: grid;
align-items: center;
grid-template-columns: 1fr auto;
grid-gap: 0.7em;
gap: 0.7em;
padding: 10px var(--horizontal-padding);
}
.option-reveal {
composes: option-toggle;
grid-template-columns: auto 1fr;
gap: 1em;
}
.option-one-cell {
display: grid;
grid-template-columns: 1fr;