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 23 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
23 commits
Select commit Hold shift + click to select a range
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