Fixed descriptions on checkbox components

This commit is contained in:
nizune 2021-07-04 20:15:38 +02:00
parent 1c80d5675f
commit 8d8b13ec12
9 changed files with 37 additions and 47 deletions

2
external/lang vendored

@ -1 +1 @@
Subproject commit 6ccd590846c35e8d3b948e9203510ccf8718a79c Subproject commit c2245a290439f0ed8efe70eb6a11cfb42c3e13c1

View file

@ -3,9 +3,9 @@ import { Children } from "../../types/Preact";
import styled, { css } from "styled-components"; import styled, { css } from "styled-components";
const CheckboxBase = styled.label` const CheckboxBase = styled.label`
margin-top: 20px;
gap: 4px; gap: 4px;
z-index: 1; z-index: 1;
padding: 4px;
display: flex; display: flex;
border-radius: 4px; border-radius: 4px;
align-items: center; align-items: center;
@ -16,25 +16,19 @@ const CheckboxBase = styled.label`
transition: 0.2s ease all; transition: 0.2s ease all;
p {
margin: 0;
}
input { input {
display: none; display: none;
} }
&:hover { &:hover {
background: var(--secondary-background);
.check { .check {
background: var(--background); background: var(--background);
} }
} }
&[disabled] { &[disabled] {
opacity: 0.5; opacity: .5;
cursor: unset; cursor: not-allowed;
&:hover { &:hover {
background: unset; background: unset;
@ -43,15 +37,15 @@ const CheckboxBase = styled.label`
`; `;
const CheckboxContent = styled.span` const CheckboxContent = styled.span`
flex-grow: 1;
display: flex; display: flex;
flex-grow: 1;
font-size: 1rem; font-size: 1rem;
font-weight: 600; font-weight: 600;
flex-direction: column; flex-direction: column;
`; `;
const CheckboxDescription = styled.span` const CheckboxDescription = styled.span`
font-size: 0.8em; font-size: .75rem;
font-weight: 400; font-weight: 400;
color: var(--secondary-foreground); color: var(--secondary-foreground);
`; `;

View file

@ -1,5 +1,6 @@
import { useRef } from "preact/hooks"; import { useRef } from "preact/hooks";
import { Check, Pencil } from "@styled-icons/boxicons-regular"; import { Check } from "@styled-icons/boxicons-regular";
import { Palette } from "@styled-icons/boxicons-solid";
import styled, { css } from "styled-components"; import styled, { css } from "styled-components";
interface Props { interface Props {
@ -98,7 +99,7 @@ export default function ColourSwatches({ value, onChange }: Props) {
type="large" type="large"
onClick={() => ref.current.click()} onClick={() => ref.current.click()}
> >
<Pencil size={32} /> <Palette size={32} />
</Swatch> </Swatch>
<input <input
type="color" type="color"

View file

@ -2,16 +2,19 @@ import styled from "styled-components";
export default styled.select` export default styled.select`
padding: 8px; padding: 8px;
border-radius: 2px; border-radius: 6px;
font-family: inherit; font-family: inherit;
color: var(--secondary-foreground); color: var(--secondary-foreground);
background: var(--secondary-background); background: var(--secondary-background);
font-size: .875rem;
border: none; border: none;
outline: 2px solid transparent; outline: 2px solid transparent;
transition: outline-color 0.2s ease-in-out; transition: outline-color 0.2s ease-in-out;
transition: box-shadow .3s;
cursor: pointer;
width: 100%;
&:focus { &:focus {
outline-color: var(--accent); box-shadow: 0 0 0 2pt var(--accent);
} }
`; `;

View file

@ -7,6 +7,13 @@ interface Props {
error?: boolean error?: boolean
} }
export const Separator = styled.div<Props>`
height: 1px;
width: calc(100% - 10px);
background: var(--secondary-header);
margin: 18px auto;
`;
export const TipBase = styled.div<Props>` export const TipBase = styled.div<Props>`
display: flex; display: flex;
padding: 12px; padding: 12px;
@ -46,9 +53,13 @@ export const TipBase = styled.div<Props>`
export default function Tip(props: Props & { children: Children }) { export default function Tip(props: Props & { children: Children }) {
const { children, ...tipProps } = props; const { children, ...tipProps } = props;
return ( return (
<>
<Separator />
<TipBase {...tipProps}> <TipBase {...tipProps}>
<InfoCircle size={20} /> <InfoCircle size={20} />
<span>{props.children}</span> <span>{props.children}</span>
</TipBase> </TipBase>
</>
); );
} }

View file

@ -8,7 +8,8 @@ import { useContext, useEffect, useState } from "preact/hooks";
import Preloader from "../../components/ui/Preloader"; import Preloader from "../../components/ui/Preloader";
import { determineFileSize } from "../../lib/fileSize"; import { determineFileSize } from "../../lib/fileSize";
import IconButton from '../../components/ui/IconButton'; import IconButton from '../../components/ui/IconButton';
import { Edit, Plus, X, XCircle } from "@styled-icons/boxicons-regular"; import { Plus, X, XCircle } from "@styled-icons/boxicons-regular";
import { Pencil } from "@styled-icons/boxicons-solid";
import { useIntermediate } from "../intermediate/Intermediate"; import { useIntermediate } from "../intermediate/Intermediate";
type Props = { type Props = {
@ -190,7 +191,7 @@ export function FileUploader(props: Props) {
<Preloader type="ring" /> <Preloader type="ring" />
</div> : </div> :
<div className={styles.edit}> <div className={styles.edit}>
<Edit size={30} /> <Pencil size={30} />
</div> } </div> }
</div> </div>
<div className={styles.modify}> <div className={styles.modify}>

View file

@ -39,6 +39,7 @@ export function Component({ options, dispatcher }: Props & WithDispatcher) {
<Checkbox <Checkbox
disabled={!("Notification" in window)} disabled={!("Notification" in window)}
checked={options?.desktopEnabled ?? false} checked={options?.desktopEnabled ?? false}
description={<Text id="app.settings.pages.notifications.descriptions.enable_desktop" />}
onChange={async desktopEnabled => { onChange={async desktopEnabled => {
if (desktopEnabled) { if (desktopEnabled) {
let permission = await Notification.requestPermission(); let permission = await Notification.requestPermission();
@ -57,13 +58,11 @@ export function Component({ options, dispatcher }: Props & WithDispatcher) {
}} }}
> >
<Text id="app.settings.pages.notifications.enable_desktop" /> <Text id="app.settings.pages.notifications.enable_desktop" />
<p>
<Text id="app.settings.pages.notifications.descriptions.enable_desktop" />
</p>
</Checkbox> </Checkbox>
<Checkbox <Checkbox
disabled={typeof pushEnabled === "undefined"} disabled={typeof pushEnabled === "undefined"}
checked={pushEnabled ?? false} checked={pushEnabled ?? false}
description={<Text id="app.settings.pages.notifications.descriptions.enable_push" />}
onChange={async pushEnabled => { onChange={async pushEnabled => {
try { try {
const reg = await navigator.serviceWorker?.getRegistration(); const reg = await navigator.serviceWorker?.getRegistration();
@ -99,9 +98,6 @@ export function Component({ options, dispatcher }: Props & WithDispatcher) {
}} }}
> >
<Text id="app.settings.pages.notifications.enable_push" /> <Text id="app.settings.pages.notifications.enable_push" />
<p>
<Text id="app.settings.pages.notifications.descriptions.enable_push" />
</p>
</Checkbox> </Checkbox>
<h3> <h3>
<Text id="app.settings.pages.notifications.sounds" /> <Text id="app.settings.pages.notifications.sounds" />

View file

@ -321,30 +321,16 @@
} }
} }
.notifications {
label {
margin-top: 12px;
}
p {
margin-top: 0;
font-size: 0.9em;
color: var(--secondary-foreground);
}
}
.languages { .languages {
.list { .list {
margin-bottom: 1em; margin-bottom: 1em;
.entry { .entry {
padding: 2px 8px;
height: 50px; height: 50px;
border-radius: 4px;
} }
.entry > span > span { .entry > span > span {
gap: 8px; gap: 20px;
display: flex; display: flex;
align-items: center; align-items: center;
flex-direction: row; flex-direction: row;

View file

@ -25,6 +25,7 @@ export function Component(props: Props & WithDispatcher) {
([ key, title ]) => ([ key, title ]) =>
<Checkbox <Checkbox
checked={(props.options?.disabled ?? []).indexOf(key) === -1} checked={(props.options?.disabled ?? []).indexOf(key) === -1}
description={<Text id={`app.settings.pages.sync.descriptions.${key}`} />}
onChange={enabled => { onChange={enabled => {
props.dispatcher({ props.dispatcher({
type: enabled ? 'SYNC_ENABLE_KEY' : 'SYNC_DISABLE_KEY', type: enabled ? 'SYNC_ENABLE_KEY' : 'SYNC_DISABLE_KEY',
@ -33,9 +34,6 @@ export function Component(props: Props & WithDispatcher) {
}} }}
> >
<Text id={`app.settings.pages.${title}`} /> <Text id={`app.settings.pages.${title}`} />
<p>
<Text id={`app.settings.pages.sync.descriptions.${key}`} />
</p>
</Checkbox> </Checkbox>
) )
} }