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

feat: hide preview button when the text in not being edited #657

Merged
merged 2 commits into from
Jul 25, 2024
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
13 changes: 5 additions & 8 deletions app/renderer/src/components/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@ import {
export type CheckboxProps = {
label?: string;
asPrimary?: boolean;
hidden?: boolean;
} & React.HTMLProps<HTMLInputElement>;

export const Checkbox = React.forwardRef<
HTMLInputElement,
CheckboxProps
>(({ id, label, name, disabled, asPrimary, ...props }, ref) => {
>(({ id, label, name, disabled, asPrimary, hidden, ...props }, ref) => {
return (
<StyledCheckbox
htmlFor={id}
disabled={disabled}
asPrimary={asPrimary}
>
<StyledCheckbox htmlFor={id} asPrimary={asPrimary}>
<input
type="checkbox"
name={name}
Expand All @@ -28,8 +25,8 @@ export const Checkbox = React.forwardRef<
disabled={disabled}
{...props}
/>
<StyledCheckboxBox />
<StyledCheckboxLabel>{label}</StyledCheckboxLabel>
<StyledCheckboxBox hidden={hidden} />
<StyledCheckboxLabel>{hidden ? "" : label}</StyledCheckboxLabel>
</StyledCheckbox>
);
});
Expand Down
7 changes: 1 addition & 6 deletions app/renderer/src/components/Radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ import { CheckboxProps } from "./Checkbox";
export const Radio = React.forwardRef<HTMLInputElement, CheckboxProps>(
({ id, label, name, disabled, asPrimary, ...props }, ref) => {
return (
<StyledCheckbox
htmlFor={id}
disabled={disabled}
tabIndex={0}
asPrimary={asPrimary}
>
<StyledCheckbox htmlFor={id} tabIndex={0} asPrimary={asPrimary}>
<input
type="radio"
name={name}
Expand Down
2 changes: 1 addition & 1 deletion app/renderer/src/routes/Tasks/TaskDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const TaskDetails = React.forwardRef<HTMLDivElement, Props>(
Description
<Checkbox
label="preview"
disabled={!editingDescription}
hidden={!editingDescription}
onChange={showPreviewCallback}
asPrimary
/>
Expand Down
33 changes: 9 additions & 24 deletions app/renderer/src/styles/components/checkbox.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import styled, { css } from "styled-components/macro";
import { themes } from "styles/themes";

export const StyledCheckboxBox = styled.span`
export const StyledCheckboxBox = styled.span<{ hidden?: boolean }>`
width: 1.1em;
height: 1.1em;

display: flex;
display: ${({ hidden }) => (hidden ? "none" : "flex")};
align-items: center;
justify-content: center;

Expand Down Expand Up @@ -44,7 +44,6 @@ export const StyledCheckboxLabel = styled.span`
`;

export const StyledCheckbox = styled.label<{
disabled?: boolean;
asPrimary?: boolean;
}>`
& > input {
Expand Down Expand Up @@ -79,35 +78,21 @@ export const StyledCheckbox = styled.label<{

&:hover ${StyledCheckboxBox} {
box-shadow: ${(p) =>
p.disabled
? `0 0 0 0.2rem rgba(var(--${
p.asPrimary ? "color-primary" : "color-green"
}-rgb), 0)`
: `0 0 0 0.2rem rgba(var(--${
p.asPrimary ? "color-primary" : "color-green"
}-rgb), 0.16)`};
`0 0 0 0.2rem rgba(var(--${
p.asPrimary ? "color-primary" : "color-green"
}-rgb), 0.16)`};
}

&:active ${StyledCheckboxBox} {
box-shadow: ${(p) =>
p.disabled
? `0 0 0 0.4rem rgba(var(--${
p.asPrimary ? "color-primary" : "color-green"
}-rgb), 0)`
: `0 0 0 0.4rem rgba(var(--${
p.asPrimary ? "color-primary" : "color-green"
}-rgb), 0.16)`};
`0 0 0 0.4rem rgba(var(--${
p.asPrimary ? "color-primary" : "color-green"
}-rgb), 0.16)`};
}

&:hover ${StyledCheckboxLabel}, &:focus ${StyledCheckboxLabel} {
color: ${(p) =>
p.disabled
? "var(--color-disabled-text)"
: `var(--${p.asPrimary ? "color-primary" : "color-green"})`};
}

${StyledCheckboxLabel} {
color: ${(p) => p.disabled && "var(--color-disabled-text)"};
`var(--${p.asPrimary ? "color-primary" : "color-green"})`};
}

display: inline-flex;
Expand Down
Loading