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

Replace hand-rolled dropdown on the dashboard and menu-related UI fixes #5037

Open
wants to merge 34 commits into
base: saved-segments/singular-bar
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f6985a6
Try popover
apata Jan 28, 2025
ce86bbe
Pass targetRef instead of target, stop Escape clearing filters
apata Jan 29, 2025
719e59e
Stop Escape clearing filters when popover menus active
apata Jan 29, 2025
9bfc4ec
Attempt get rid of hand-rolled dropdown
apata Jan 29, 2025
d392d3b
Fix issue with comparison calendar
apata Jan 29, 2025
315ce65
Almost works
apata Jan 29, 2025
5ca7af2
Unify styles
apata Jan 29, 2025
9f1cb57
Focus modals on mount
apata Jan 29, 2025
776a19f
Refactor date picker logic
apata Jan 29, 2025
6db18d8
Replace navigate keybinds with straightforward keybinds
apata Jan 29, 2025
688c947
Remove extraneous Calendar component, better props
apata Jan 29, 2025
15efcc3
Attempt optimise menu re-renders
apata Jan 29, 2025
38a7360
Memoise QueryPeriodsMenu, refactor getDatePeriodGroups
apata Jan 30, 2025
e2dae51
Refactor ComparisonMenu to Popover
apata Jan 30, 2025
ec86842
Refactor QueryPeriodMenu to Popover
apata Jan 30, 2025
b8c68f9
Pull calendar out of components
apata Jan 30, 2025
c49465d
Refactor calendar to receive position from JS
apata Jan 30, 2025
868dd40
Simpler calendar API
apata Jan 30, 2025
c526804
Add click outside listener for Calendar, fix FiltersBar measurements
apata Jan 30, 2025
3dbd86a
Give back top bar room
apata Jan 30, 2025
d21f724
Update tests
apata Jan 30, 2025
68afaeb
Apply unified button text style
apata Jan 30, 2025
2633518
Close calendar on keyboard nav to othe menus as well
apata Jan 30, 2025
a6a3807
Kinda works
apata Feb 3, 2025
994c52c
Works even better
apata Feb 3, 2025
ea6fe11
Working well
apata Feb 3, 2025
cb9fbe3
Sometimes menu stays active
apata Feb 3, 2025
382b13f
WIP
apata Feb 3, 2025
2793345
Adapter
apata Feb 3, 2025
5788d62
Works with error
apata Feb 3, 2025
85a7b33
Fixed the error
apata Feb 3, 2025
304758c
Remove handrolled isOpen
apata Feb 3, 2025
cec6f02
Introduce shared adapter
apata Feb 3, 2025
8fdeb07
Share adapter
apata Feb 3, 2025
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
7 changes: 1 addition & 6 deletions assets/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@import './modal.css';
@import './loader.css';
@import './tooltip.css';
@import './flatpickr.css';
@import './flatpickr-colors.css';
@import './chartjs.css';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';
Expand Down Expand Up @@ -246,11 +246,6 @@ blockquote {
transition: opacity 100ms ease-in;
}

.flatpickr-calendar.static.open {
right: 2px;
top: 12px;
}

.datamaps-subunit {
cursor: pointer;
}
Expand Down
22 changes: 0 additions & 22 deletions assets/css/flatpickr.css → assets/css/flatpickr-colors.css
Original file line number Diff line number Diff line change
@@ -1,28 +1,6 @@
/* @format */
/* stylelint-disable media-feature-range-notation */
/* stylelint-disable selector-class-pattern */
.flatpickr-calendar::before,
.flatpickr-calendar::after {
right: 22px !important;
}

.flatpickr-wrapper {
right: 35% !important;
}

@media (max-width: 768px) {
.flatpickr-wrapper {
right: 50% !important;
}
}

@media (max-width: 768px) {
.flatpickr-wrapper {
position: absolute !important;
right: 0 !important;
left: 0 !important;
}
}

/* Because Flatpickr offers zero support for dynamic theming on its own (outside of third-party plugins) */
.dark .flatpickr-calendar {
Expand Down
175 changes: 0 additions & 175 deletions assets/js/dashboard/components/dropdown.tsx

This file was deleted.

10 changes: 8 additions & 2 deletions assets/js/dashboard/components/filter-operator-selector.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @format */

import React, { Fragment } from 'react'
import React, { Fragment, useRef } from 'react'

import {
FILTER_OPERATIONS,
Expand All @@ -12,9 +12,11 @@ import {
import { Menu, Transition } from '@headlessui/react'
import { ChevronDownIcon } from '@heroicons/react/20/solid'
import classNames from 'classnames'
import { BlurMenuButtonOnEscape } from '../keybinding'

export default function FilterOperatorSelector(props) {
const filterName = props.forFilter
const buttonRef = useRef()

function renderTypeItem(operation, shouldDisplay) {
return (
Expand Down Expand Up @@ -46,8 +48,12 @@ export default function FilterOperatorSelector(props) {
<Menu as="div" className="relative inline-block text-left w-full">
{({ open }) => (
<>
<BlurMenuButtonOnEscape targetRef={buttonRef} />
<div className="w-full">
<Menu.Button className="inline-flex justify-between items-center w-full rounded-md border border-gray-300 dark:border-gray-500 shadow-sm px-4 py-2 bg-white dark:bg-gray-800 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-850 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-100 dark:focus:ring-offset-gray-900 focus:ring-indigo-500 text-left">
<Menu.Button
ref={buttonRef}
className="inline-flex justify-between items-center w-full rounded-md border border-gray-300 dark:border-gray-500 shadow-sm px-4 py-2 bg-white dark:bg-gray-800 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-850 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-100 dark:focus:ring-offset-gray-900 focus:ring-indigo-500 text-left"
>
{FILTER_OPERATIONS_DISPLAY_NAMES[props.selectedType]}
<ChevronDownIcon
className="-mr-2 ml-2 h-4 w-4 text-gray-500 dark:text-gray-400"
Expand Down
67 changes: 67 additions & 0 deletions assets/js/dashboard/components/popover.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/** @format */
import { TransitionClasses } from '@headlessui/react'
import classNames from 'classnames'

const TRANSITION_CONFIG: TransitionClasses = {
enter: 'transition ease-out duration-100',
enterFrom: 'opacity-0 scale-95',
enterTo: 'opacity-100 scale-100',
leave: 'transition ease-in duration-75',
leaveFrom: 'opacity-100 scale-100',
leaveTo: 'opacity-0 scale-95'
}

const transition = {
props: TRANSITION_CONFIG,
classNames: { fullwidth: 'z-10 absolute left-0 right-0' }
}

const panel = {
classNames: {
roundedSheet:
'focus:outline-none rounded-md shadow-lg bg-white dark:bg-gray-800 ring-1 ring-black ring-opacity-5 font-medium text-gray-800 dark:text-gray-200'
}
}

const toggleButton = {
classNames: {
rounded: 'flex items-center rounded text-sm leading-tight h-9',
shadow:
'bg-white dark:bg-gray-800 shadow text-gray-800 dark:text-gray-200 hover:bg-gray-200 dark:hover:bg-gray-900',
ghost:
'text-gray-500 hover:text-gray-800 hover:bg-gray-200 dark:hover:text-gray-200 dark:hover:bg-gray-900',
truncatedText: 'truncate block font-medium'
}
}

const items = {
classNames: {
navigationLink: classNames(
'flex items-center justify-between',
'px-4 py-2 text-sm leading-tight'
),
selectedOption: classNames('data-[selected=true]:font-bold'),
hoverLink: classNames(
'hover:bg-gray-100',
'hover:text-gray-900',
'dark:hover:bg-gray-900',
'dark:hover:text-gray-100',

'focus-within:bg-gray-100',
'focus-within:text-gray-900',
'dark:focus-within:bg-gray-900',
'dark:focus-within:text-gray-100'
),
roundedStartEnd: classNames(
'first-of-type:rounded-t-md',
'last-of-type:rounded-b-md'
)
}
}

export const popover = {
toggleButton,
panel,
transition,
items
}
4 changes: 2 additions & 2 deletions assets/js/dashboard/components/search-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ export const SearchInput = ({
type="keyup"
handler={blurSearchBox}
shouldIgnoreWhen={[isModifierPressed, () => !isFocused]}
target={searchBoxRef.current}
targetRef={searchBoxRef}
/>
<Keybind
keyboardKey="/"
type="keyup"
handler={focusSearchBox}
shouldIgnoreWhen={[isModifierPressed, () => isFocused]}
target={document}
targetRef="document"
/>
<input
onBlur={() => setIsFocused(false)}
Expand Down
Loading