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(dashboard): select tracker variants #117

Merged
merged 26 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1e31e07
perf: refactor to use css compose for usage settings
ayuhito Aug 5, 2024
b2da92e
refactor: section to css compose
ayuhito Aug 5, 2024
50b8666
refactor: button component to use compose css
ayuhito Aug 5, 2024
79ec09d
perf: remove all references to title import
ayuhito Aug 5, 2024
8cb9629
refactor: clean up settings text components
ayuhito Aug 5, 2024
c546764
refactor: use compose for text and unstyled buttons
ayuhito Aug 5, 2024
1fc15a0
feat: add checkbox and info tooltip components
ayuhito Aug 6, 2024
27c8582
feat: add valibot and tanstack form
ayuhito Aug 6, 2024
1d4745b
feat: add textfield component and use valibot
ayuhito Aug 7, 2024
e6ab719
perf: replace textinput
ayuhito Aug 7, 2024
8d05fce
chore: upgrade deps
ayuhito Aug 7, 2024
0eb7d4d
feat: add password input and radix icons
ayuhito Aug 8, 2024
5a146ff
chore: replace chevron icons
ayuhito Aug 8, 2024
4f6b629
fix: chevron padding on dropdowns
ayuhito Aug 8, 2024
87e29a6
style: format files
ayuhito Aug 8, 2024
6a29320
refactor: rename textfield to input
ayuhito Aug 8, 2024
0e377dd
chore: remove lucide-react
ayuhito Aug 8, 2024
a53055a
feat: add codeblock component
ayuhito Aug 10, 2024
f76170c
style: format files
ayuhito Aug 10, 2024
d060182
fix: add scrollarea to codeblock
ayuhito Aug 10, 2024
1f41a00
chore: fix lockfile
ayuhito Aug 10, 2024
caeb50a
chore: add react tooltip comp
ayuhito Aug 10, 2024
d8e7e0b
fix: cleanup anchor and code styles
ayuhito Aug 10, 2024
58f1314
feat: add info tooltips
ayuhito Aug 11, 2024
9d842f4
chore: rename css variables
ayuhito Aug 11, 2024
85f9886
fix: overwrite password prop
ayuhito Aug 11, 2024
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
Binary file modified bun.lockb
Binary file not shown.
2 changes: 2 additions & 0 deletions dashboard/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ tasks:
- ../core/client/**/*

lint:
aliases:
- format
cmds:
- bun run lint

Expand Down
24 changes: 24 additions & 0 deletions dashboard/app/components/Anchor.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.anchor {
appearance: none;
border: none;
display: inline;
padding: 0;
margin: 0;

color: var(--text-dark);
background-color: transparent;

border-radius: 4px;

cursor: pointer;
text-decoration: underline;

&:focus-visible {
outline: 2px solid var(--focus-outline);
outline-offset: 2px;
}

&:visited {
color: var(--text-dark);
}
}
21 changes: 21 additions & 0 deletions dashboard/app/components/Anchor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import classes from './Anchor.module.css';

interface AnchorProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
children: React.ReactNode;
}

const Anchor = ({ children, className, ...rest }: AnchorProps) => {
const isExternal = rest.href?.toString().startsWith('http');
return (
<a
className={className ? className : classes.anchor}
target={isExternal ? '_blank' : undefined}
rel={isExternal ? 'noopener noreferrer' : undefined}
{...rest}
>
{children}
</a>
);
};

export { Anchor };
67 changes: 0 additions & 67 deletions dashboard/app/components/Button.module.css

This file was deleted.

27 changes: 16 additions & 11 deletions dashboard/app/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { Cross1Icon } from '@radix-ui/react-icons';
import { VisuallyHidden } from '@radix-ui/react-visually-hidden';
import { Link, type LinkProps } from '@remix-run/react';
import clsx from 'clsx';
import { X } from 'lucide-react';
import type React from 'react';

import classes from './Button.module.css';

interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
loading?: boolean;
children: React.ReactNode;
Expand All @@ -32,7 +29,7 @@ const Button = ({
}: ButtonProps) => {
return (
<button
className={clsx(className, classes.base)}
className={className ? className : 'button'}
disabled={loading || disabled}
aria-busy={loading ? 'true' : 'false'}
{...rest}
Expand Down Expand Up @@ -69,10 +66,13 @@ const ButtonLink = ({
}: ButtonLinkProps) => {
return (
<Link
className={clsx(
variant === 'outline' ? classes.outline : classes.link,
className,
)}
className={
className
? className
: variant === 'outline'
? 'button-outline'
: 'button-link'
}
role="button"
{...rest}
>
Expand All @@ -83,7 +83,12 @@ const ButtonLink = ({

const IconButton = ({ children, label, ...rest }: IconButtonProps) => {
return (
<button className={classes.icon} type="button" aria-label={label} {...rest}>
<button
className="button button-icon"
type="button"
aria-label={label}
{...rest}
>
{children}
</button>
);
Expand All @@ -92,7 +97,7 @@ const IconButton = ({ children, label, ...rest }: IconButtonProps) => {
const CloseButton = ({ label, ...rest }: CloseButtonProps) => {
return (
<IconButton label={label} {...rest}>
<X />
<Cross1Icon />
</IconButton>
);
};
Expand Down
38 changes: 38 additions & 0 deletions dashboard/app/components/Checkbox.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.root {
background-color: white;
width: 22px;
height: 22px;
min-width: 22px;

border: 1px solid var(--border-light);
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;

&:hover {
background-color: var(--violet-a3);
}

&:focus-visible {
outline: 2px solid var(--focus-outline);
}

&[data-disabled] {
background-color: var(--black-a3);
}
}

.indicator {
color: var(--violet-indicator);

&[data-disabled] {
color: var(--text-disabled);
}
}

.label {
padding: 0 4px 0 12px;
font-size: 15px;
line-height: 1;
}
56 changes: 56 additions & 0 deletions dashboard/app/components/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
import { CheckIcon } from '@radix-ui/react-icons';
import * as Label from '@radix-ui/react-label';
import type React from 'react';

import { InfoTooltip } from '@/components/InfoTooltip';
import { Group } from '@/components/layout/Flex';

import classes from './Checkbox.module.css';

interface CheckBoxProps {
label: string;
value: string;
icon?: React.ReactNode;
tooltip?: React.ReactNode;

checked?: boolean;
disabled?: boolean;
onCheckedChange?: (checked: boolean) => void;
}

const CheckBox = ({
label,
value,
icon,
tooltip,
checked,
disabled,
onCheckedChange,
}: CheckBoxProps) => {
const id = `checkbox-${value}`;
return (
<Group style={{ justifyContent: 'flex-start' }}>
<CheckboxPrimitive.Root
id={id}
className={classes.root}
value={value}
checked={checked}
disabled={disabled}
onCheckedChange={onCheckedChange}
>
<CheckboxPrimitive.Indicator className={classes.indicator}>
{icon ? icon : <CheckIcon />}
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
<Group>
<Label.Root className={classes.label} htmlFor={id}>
{label}
</Label.Root>
{tooltip && <InfoTooltip>{tooltip}</InfoTooltip>}
</Group>
</Group>
);
};

export { CheckBox };
8 changes: 5 additions & 3 deletions dashboard/app/components/DatePicker.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
}

.header {
composes: group from global;
padding-bottom: 4px;
}

Expand All @@ -20,7 +21,7 @@
}

.content {
background-color: var(--me-color-bg-light);
background-color: var(--bg-light);
border-radius: 6px;
box-shadow: hsl(206 22% 7% / 35%) 0px 10px 38px -10px,
hsl(206 22% 7% / 20%) 0px 10px 20px -15px;
Expand All @@ -39,6 +40,7 @@
}

.apply {
composes: button from global;
margin-top: 20px;
width: 100%;
}
Expand All @@ -48,8 +50,8 @@
.root {
margin-top: 8px;

--rdp-accent-color: var(--me-color-border-violet);
--rdp-accent-background-color: var(--me-color-selected-snow);
--rdp-accent-color: var(--violet);
--rdp-accent-background-color: var(--selected-snow);
--rdp-font-family: var(--default-font-family);

--rdp-day-font: 400 16px var(--rdp-font-family);
Expand Down
11 changes: 5 additions & 6 deletions dashboard/app/components/DatePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import * as Dialog from '@radix-ui/react-dialog';
import { ChevronLeftIcon, ChevronRightIcon } from '@radix-ui/react-icons';
import * as VisuallyHidden from '@radix-ui/react-visually-hidden';
import { useSearchParams } from '@remix-run/react';
import { formatISO, parseISO, sub } from 'date-fns';
import { ChevronLeft, ChevronRight } from 'lucide-react';
import { useState } from 'react';
import { type DateRange, DayPicker } from 'react-day-picker';

import { Button, CloseButton } from '@/components/Button';
import { Group } from '@/components/layout/Flex';
import { useDidUpdate } from '@/hooks/use-did-update';
import { useMediaQuery } from '@/hooks/use-media-query';

Expand Down Expand Up @@ -61,14 +60,14 @@ const DatePickerRange = ({ open, setOpen }: DatePickerProps) => {
<Dialog.Portal>
<Dialog.Overlay className={classes.overlay} />
<Dialog.Content className={classes.content}>
<Group className={classes.header}>
<div className={classes.header}>
<Dialog.Title className={classes.title}>
Select a date range
</Dialog.Title>
<Dialog.Close asChild>
<CloseButton label="Close date picker" />
</Dialog.Close>
</Group>
</div>
<VisuallyHidden.Root asChild>
<Dialog.Description>
Select the start and end date for the date range.
Expand All @@ -83,9 +82,9 @@ const DatePickerRange = ({ open, setOpen }: DatePickerProps) => {
components={{
Chevron: (props) => {
if (props.orientation === 'left') {
return <ChevronLeft {...props} />;
return <ChevronLeftIcon {...props} />;
}
return <ChevronRight {...props} />;
return <ChevronRightIcon {...props} />;
},
}}
defaultMonth={sub(new Date(), { months: 1 })}
Expand Down
Loading
Loading