Fix select input styles
This commit is contained in:
parent
284a4ef794
commit
3cc7892198
7 changed files with 45 additions and 56 deletions
|
@ -5,6 +5,9 @@
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
|
border: 1px solid var(--inputBorderColor);
|
||||||
|
background-color: var(--bgColor1);
|
||||||
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.option {
|
.option {
|
||||||
|
@ -25,7 +28,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.option.focused {
|
.option.focused {
|
||||||
background-color: var(--bgColor3);
|
background-color: rgba(111, 120, 130, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
.option.disabled {
|
.option.disabled {
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
max-width: 90vw;
|
max-width: 90vw;
|
||||||
width: 600px;
|
width: 600px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modalHeader {
|
.modalHeader {
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
import React, { forwardRef } from "react";
|
import React, { forwardRef, useRef } from "react";
|
||||||
import {
|
import { DismissButton, useOverlay } from "@react-aria/overlays";
|
||||||
DismissButton,
|
|
||||||
useOverlay,
|
|
||||||
OverlayContainer,
|
|
||||||
} from "@react-aria/overlays";
|
|
||||||
import { FocusScope } from "@react-aria/focus";
|
import { FocusScope } from "@react-aria/focus";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import styles from "./Popover.module.css";
|
import styles from "./Popover.module.css";
|
||||||
|
|
||||||
export const Popover = forwardRef(
|
export const Popover = forwardRef(
|
||||||
({ isOpen = true, onClose, className, children, ...rest }, ref) => {
|
({ isOpen = true, onClose, className, children, ...rest }, ref) => {
|
||||||
|
const fallbackRef = useRef();
|
||||||
|
const popoverRef = ref || fallbackRef;
|
||||||
|
|
||||||
const { overlayProps } = useOverlay(
|
const { overlayProps } = useOverlay(
|
||||||
{
|
{
|
||||||
isOpen,
|
isOpen,
|
||||||
|
@ -17,23 +16,21 @@ export const Popover = forwardRef(
|
||||||
shouldCloseOnBlur: true,
|
shouldCloseOnBlur: true,
|
||||||
isDismissable: true,
|
isDismissable: true,
|
||||||
},
|
},
|
||||||
ref
|
popoverRef
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<OverlayContainer>
|
|
||||||
<FocusScope restoreFocus>
|
<FocusScope restoreFocus>
|
||||||
<div
|
<div
|
||||||
{...overlayProps}
|
{...overlayProps}
|
||||||
{...rest}
|
{...rest}
|
||||||
className={classNames(styles.popover, className)}
|
className={classNames(styles.popover, className)}
|
||||||
ref={ref}
|
ref={popoverRef}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
<DismissButton onDismiss={onClose} />
|
<DismissButton onDismiss={onClose} />
|
||||||
</div>
|
</div>
|
||||||
</FocusScope>
|
</FocusScope>
|
||||||
</OverlayContainer>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -2,7 +2,7 @@ import React, { useRef } from "react";
|
||||||
import styles from "./PopoverMenu.module.css";
|
import styles from "./PopoverMenu.module.css";
|
||||||
import { useMenuTriggerState } from "@react-stately/menu";
|
import { useMenuTriggerState } from "@react-stately/menu";
|
||||||
import { useMenuTrigger } from "@react-aria/menu";
|
import { useMenuTrigger } from "@react-aria/menu";
|
||||||
import { useOverlayPosition } from "@react-aria/overlays";
|
import { OverlayContainer, useOverlayPosition } from "@react-aria/overlays";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { Popover } from "./Popover";
|
import { Popover } from "./Popover";
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ export function PopoverMenuTrigger({
|
||||||
ref={buttonRef}
|
ref={buttonRef}
|
||||||
/>
|
/>
|
||||||
{popoverMenuState.isOpen && (
|
{popoverMenuState.isOpen && (
|
||||||
|
<OverlayContainer>
|
||||||
<Popover
|
<Popover
|
||||||
{...overlayProps}
|
{...overlayProps}
|
||||||
isOpen={popoverMenuState.isOpen}
|
isOpen={popoverMenuState.isOpen}
|
||||||
|
@ -64,6 +65,7 @@ export function PopoverMenuTrigger({
|
||||||
onClose: popoverMenuState.close,
|
onClose: popoverMenuState.close,
|
||||||
})}
|
})}
|
||||||
</Popover>
|
</Popover>
|
||||||
|
</OverlayContainer>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -4,7 +4,6 @@ import { useButton } from "@react-aria/button";
|
||||||
import { useSelectState } from "@react-stately/select";
|
import { useSelectState } from "@react-stately/select";
|
||||||
import { Popover } from "./Popover";
|
import { Popover } from "./Popover";
|
||||||
import { ListBox } from "./ListBox";
|
import { ListBox } from "./ListBox";
|
||||||
import { useOverlayPosition } from "@react-aria/overlays";
|
|
||||||
import styles from "./SelectInput.module.css";
|
import styles from "./SelectInput.module.css";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { ReactComponent as ArrowDownIcon } from "./icons/ArrowDown.svg";
|
import { ReactComponent as ArrowDownIcon } from "./icons/ArrowDown.svg";
|
||||||
|
@ -21,16 +20,6 @@ export function SelectInput(props) {
|
||||||
|
|
||||||
const { buttonProps } = useButton(triggerProps, ref);
|
const { buttonProps } = useButton(triggerProps, ref);
|
||||||
|
|
||||||
const popoverRef = useRef();
|
|
||||||
|
|
||||||
const { overlayProps } = useOverlayPosition({
|
|
||||||
targetRef: ref,
|
|
||||||
overlayRef: popoverRef,
|
|
||||||
placement: "bottom left",
|
|
||||||
offset: 5,
|
|
||||||
isOpen: state.isOpen,
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(styles.selectInput, props.className)}>
|
<div className={classNames(styles.selectInput, props.className)}>
|
||||||
<h4 {...labelProps} className={styles.label}>
|
<h4 {...labelProps} className={styles.label}>
|
||||||
|
@ -52,15 +41,12 @@ export function SelectInput(props) {
|
||||||
</button>
|
</button>
|
||||||
{state.isOpen && (
|
{state.isOpen && (
|
||||||
<Popover
|
<Popover
|
||||||
ref={popoverRef}
|
|
||||||
isOpen={state.isOpen}
|
isOpen={state.isOpen}
|
||||||
onClose={state.close}
|
onClose={state.close}
|
||||||
className={styles.popover}
|
className={styles.popover}
|
||||||
{...overlayProps}
|
|
||||||
>
|
>
|
||||||
<ListBox
|
<ListBox
|
||||||
{...menuProps}
|
{...menuProps}
|
||||||
className
|
|
||||||
state={state}
|
state={state}
|
||||||
optionClassName={styles.option}
|
optionClassName={styles.option}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-bottom: 28px;
|
margin-bottom: 28px;
|
||||||
|
max-width: 444px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.label {
|
.label {
|
||||||
|
@ -23,6 +24,7 @@
|
||||||
color: var(--textColor1);
|
color: var(--textColor1);
|
||||||
height: 40px;
|
height: 40px;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.selectedItem {
|
.selectedItem {
|
||||||
|
@ -33,12 +35,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.popover {
|
.popover {
|
||||||
}
|
position: absolute;
|
||||||
|
margin-top: 5px;
|
||||||
.option:first-child {
|
width: 100%;
|
||||||
border-radius: 8px 8px 0 0;
|
z-index: 1;
|
||||||
}
|
|
||||||
|
|
||||||
.option:last-child {
|
|
||||||
border-radius: 0 0 8px 8px;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
.tabContainer {
|
.tabContainer {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tabList {
|
.tabList {
|
||||||
|
|
Loading…
Add table
Reference in a new issue