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

fix: update checkbox ui and fix tab to switch element focus #76

Merged
merged 1 commit into from
Jun 20, 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
2 changes: 1 addition & 1 deletion src/renderer/src/components/ui/button/variants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { cn } from "@renderer/lib/utils"
import { cva } from "class-variance-authority"

export const buttonVariants = cva(
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors disabled:pointer-events-none disabled:opacity-50",
{
variants: {
size: {
Expand Down
35 changes: 16 additions & 19 deletions src/renderer/src/components/ui/checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
import { cn } from "@renderer/lib/utils"
import { Check } from "lucide-react"
import * as React from "react"

const Checkbox = React.forwardRef<
React.ElementRef<typeof CheckboxPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
>(({ className, ...props }, ref) => (
<CheckboxPrimitive.Root
ref={ref}
className={cn(
"peer size-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
className,
)}
{...props}
>
<CheckboxPrimitive.Indicator
className={cn("flex items-center justify-center text-current")}
>
<Check className="size-4" />
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
))
HTMLInputElement,
React.ComponentPropsWithoutRef<"input"> & {
onCheckedChange?: (checked: boolean) => void
}
>(({ className, onCheckedChange, ...props }, ref) => (
<input
type="checkbox"
ref={ref}
className={cn("checkbox", className)}
{...props}
onChange={(event) => {
onCheckedChange?.(event.target.checked)
props.onChange?.(event)
}}
/>
))
Checkbox.displayName = CheckboxPrimitive.Root.displayName

export { Checkbox }
2 changes: 1 addition & 1 deletion src/renderer/src/components/ui/switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Switch = React.forwardRef<
>(({ className, ...props }, ref) => (
<SwitchPrimitives.Root
className={cn(
"peer inline-flex h-6 w-11 shrink-0 items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",
"peer inline-flex h-6 w-11 shrink-0 items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
"duration-200 data-[state=checked]:bg-theme-accent data-[state=unchecked]:bg-theme-inactive dark:data-[state=unchecked]:bg-theme-accent-100/10",
className,
)}
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/src/components/ui/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const TabsTrigger = React.forwardRef<
<TabsPrimitive.Trigger
ref={ref}
className={cn(
"inline-flex items-center justify-center whitespace-nowrap px-3 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:text-theme-foreground",
"inline-flex items-center justify-center whitespace-nowrap px-3 text-sm font-medium ring-offset-background transition-all disabled:pointer-events-none disabled:opacity-50 data-[state=active]:text-theme-foreground",
tabsTriggerVariants({ variant }),
className,
)}
Expand All @@ -83,7 +83,7 @@ const TabsContent = React.forwardRef<
<TabsPrimitive.Content
ref={ref}
className={cn(
"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
"mt-2 ring-offset-background focus-visible:outline-none",
className,
)}
{...props}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/user-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const ProfileButton: FC<LoginProps> = memo((props) => {
return <LoginButton {...props} />
}
return (
<Link to="/profile">
<Link to="/profile" tabIndex={-1}>
<ActionButton tooltip="Profile">
<UserButton className="h-5 p-0" hideName />
</ActionButton>
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/modules/entry-column/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ const ListHeader: FC<{
)}
</ActionButton>
<Popover open={markPopoverOpen} onOpenChange={setMarkPopoverOpen}>
<PopoverTrigger>
<PopoverTrigger asChild>
<ActionButton
shortcut={shortcuts.entries.markAllAsRead.key}
tooltip="Mark All as Read"
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/modules/feed-column/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export function FeedColumn() {
)}
<div className="flex items-center gap-2" onClick={stopPropagation}>
<ProfileButton method="modal" />
<Link to="/discover">
<Link to="/discover" tabIndex={-1}>
<ActionButton shortcut="Meta+T" tooltip="Add">
<i className="i-mgc-add-cute-re size-5 text-theme-vibrancyFg" />
</ActionButton>
Expand Down
26 changes: 18 additions & 8 deletions src/renderer/src/pages/(external)/redirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,24 @@ export function Component() {
{" "}
and safely close this page.
</h2>
<StyledButton
className="h-14 rounded-lg px-10 text-lg"
onClick={async () => window.open(await getCallbackUrl())}
>
Open
{" "}
{APP_NAME}
</StyledButton>
<div className="center flex gap-4">
<StyledButton
variant="plain"
className="h-14 border-transparent px-10 text-base"
onClick={() => navigate("/")}
>
Continue in Browser
</StyledButton>

<StyledButton
className="h-14 !rounded-full px-10 text-lg"
onClick={async () => window.open(await getCallbackUrl())}
>
Open
{" "}
{APP_NAME}
</StyledButton>
</div>
</div>
)
}
4 changes: 4 additions & 0 deletions src/renderer/src/styles/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ body,
@apply font-theme;
}

:focus-visible {
outline: theme(colors.theme.accent.DEFAULT) auto 1px;
}

button,
a {
@apply cursor-default;
Expand Down
82 changes: 82 additions & 0 deletions src/renderer/src/styles/tailwind-extend.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
.shadow-modal {
@apply shadow-2xl shadow-stone-300 dark:shadow-stone-800;
}
/* Utils */
.no-animation {
--btn-focus-scale: 1;
--animation-btn: 0;
--animation-input: 0;
}
}

/* Radio styling */
Expand Down Expand Up @@ -139,3 +145,79 @@
background-color: oklch(0.232607 0.013807 253.101);
}
}

/* Checkbox */
@layer components {
.checkbox {
--chkbg: theme(colors.theme.accent.DEFAULT);
--chkfg: theme(colors.zinc.100);

flex-shrink: 0;
height: 0.9em;
width: 0.9em;
cursor: pointer;
appearance: none;
border-radius: 5px;
border-width: 1px;
border-color: theme(colors.zinc.500);
--tw-border-opacity: 0.2;
}

.checkbox:focus {
box-shadow: none;
}

.checkbox:focus-visible {
outline-style: solid;
outline-width: 2px;
outline-offset: 2px;
outline-color: theme(colors.theme.accent.DEFAULT);
border-color: theme(colors.theme.accent.DEFAULT);
}

.checkbox:disabled {
border-width: 0;
cursor: not-allowed;
border-color: transparent;
--tw-bg-opacity: 1;
background-color: var(--chkbg);
opacity: 0.2;
}

.checkbox:checked,
.checkbox[aria-checked="true"] {
background-repeat: no-repeat;
animation: checkmark var(--animation-input, 0.2s) ease-out;
border-color: theme(colors.theme.accent.DEFAULT);
background-color: var(--chkbg);
background-image: linear-gradient(
-45deg,
transparent 65%,
var(--chkbg) 65.99%
),
linear-gradient(45deg, transparent 75%, var(--chkbg) 75.99%),
linear-gradient(-45deg, var(--chkbg) 40%, transparent 40.99%),
linear-gradient(
45deg,
var(--chkbg) 30%,
var(--chkfg) 30.99%,
var(--chkfg) 40%,
transparent 40.99%
),
linear-gradient(-45deg, var(--chkfg) 50%, var(--chkbg) 50.99%);
}

@keyframes checkmark {
0% {
background-position-y: 5px;
}

50% {
background-position-y: -2px;
}

to {
background-position-y: 0;
}
}
}
Loading