未验证 提交 b9217586 编写于 作者: M Méril 提交者: GitHub

feat(console): improve responsiveness for QueryPicker component (#428)

The QueryPicker width is now 600px and it will automatically fit the screen when
its width is smaller.
上级 f2835a11
...@@ -96,7 +96,7 @@ export const PopperHover = ({ ...@@ -96,7 +96,7 @@ export const PopperHover = ({
{ReactDOM.createPortal( {ReactDOM.createPortal(
<CSSTransition <CSSTransition
classNames="popper-fade" classNames="fade-reg"
in={active} in={active}
timeout={TransitionDuration.REG} timeout={TransitionDuration.REG}
unmountOnExit unmountOnExit
......
...@@ -105,7 +105,7 @@ export const PopperToggle = ({ ...@@ -105,7 +105,7 @@ export const PopperToggle = ({
{React.isValidElement(children) && ( {React.isValidElement(children) && (
<CSSTransition <CSSTransition
classNames="popper-fade" classNames="fade-reg"
in={_active} in={_active}
timeout={TransitionDuration.REG} timeout={TransitionDuration.REG}
unmountOnExit unmountOnExit
......
...@@ -30,16 +30,19 @@ const store = createStore(rootReducer, compose(applyMiddleware(epicMiddleware))) ...@@ -30,16 +30,19 @@ const store = createStore(rootReducer, compose(applyMiddleware(epicMiddleware)))
epicMiddleware.run(rootEpic) epicMiddleware.run(rootEpic)
store.dispatch(actions.console.bootstrap()) store.dispatch(actions.console.bootstrap())
const GlobalTransitionStyles = createGlobalFadeTransition( const FadeReg = createGlobalFadeTransition("fade-reg", TransitionDuration.REG)
"popper-fade",
TransitionDuration.REG, const FadeSlow = createGlobalFadeTransition(
"fade-slow",
TransitionDuration.SLOW,
) )
ReactDOM.render( ReactDOM.render(
<ScreenSizeProvider> <ScreenSizeProvider>
<Provider store={store}> <Provider store={store}>
<ThemeProvider theme={theme}> <ThemeProvider theme={theme}>
<GlobalTransitionStyles /> <FadeSlow />
<FadeReg />
<Layout /> <Layout />
</ThemeProvider> </ThemeProvider>
</Provider> </Provider>
......
...@@ -2,18 +2,13 @@ import React, { useEffect, useRef, useState } from "react" ...@@ -2,18 +2,13 @@ import React, { useEffect, useRef, useState } from "react"
import { CSSTransition } from "react-transition-group" import { CSSTransition } from "react-transition-group"
import styled, { keyframes } from "styled-components" import styled, { keyframes } from "styled-components"
import { createGlobalFadeTransition, TransitionDuration } from "components" import { TransitionDuration } from "components"
import { color } from "utils" import { color } from "utils"
type Props = Readonly<{ type Props = Readonly<{
show: boolean show: boolean
}> }>
const GlobalTransitionStyles = createGlobalFadeTransition(
"editor-loader-fade",
TransitionDuration.SLOW,
)
const move = keyframes` const move = keyframes`
0% { 0% {
background-position: left bottom; background-position: left bottom;
...@@ -69,9 +64,8 @@ const Loader = ({ show }: Props) => { ...@@ -69,9 +64,8 @@ const Loader = ({ show }: Props) => {
return ( return (
<> <>
<GlobalTransitionStyles />
<CSSTransition <CSSTransition
classNames="editor-loader-fade" classNames="fade-slow"
in={visible && show} in={visible && show}
timeout={TransitionDuration.SLOW} timeout={TransitionDuration.SLOW}
unmountOnExit unmountOnExit
......
...@@ -3,7 +3,7 @@ import styled from "styled-components" ...@@ -3,7 +3,7 @@ import styled from "styled-components"
import { DownArrowSquare } from "@styled-icons/boxicons-solid/DownArrowSquare" import { DownArrowSquare } from "@styled-icons/boxicons-solid/DownArrowSquare"
import { UpArrowSquare } from "@styled-icons/boxicons-solid/UpArrowSquare" import { UpArrowSquare } from "@styled-icons/boxicons-solid/UpArrowSquare"
import { Text, useKeyPress, useScreenSize } from "components" import { Text, useKeyPress } from "components"
import { QueryShape } from "types" import { QueryShape } from "types"
import { BusEvent, color } from "utils" import { BusEvent, color } from "utils"
...@@ -15,10 +15,11 @@ type Props = { ...@@ -15,10 +15,11 @@ type Props = {
ref: Ref<HTMLDivElement> ref: Ref<HTMLDivElement>
} }
const Wrapper = styled.div<{ _width: number }>` const Wrapper = styled.div`
display: flex; display: flex;
max-height: ${({ _width }) => _width}px; max-height: 600px;
width: ${({ _width }) => _width}px; width: 600px;
max-width: 100vw;
padding: 0.6rem 0; padding: 0.6rem 0;
flex-direction: column; flex-direction: column;
background: ${color("draculaBackgroundDarker")}; background: ${color("draculaBackgroundDarker")};
...@@ -45,7 +46,6 @@ const QueryPicker = ({ hidePicker, queries, ref }: Props) => { ...@@ -45,7 +46,6 @@ const QueryPicker = ({ hidePicker, queries, ref }: Props) => {
const enterPress = useKeyPress("Enter", { preventDefault: true }) const enterPress = useKeyPress("Enter", { preventDefault: true })
const [cursor, setCursor] = useState(0) const [cursor, setCursor] = useState(0)
const [hovered, setHovered] = useState<QueryShape | undefined>() const [hovered, setHovered] = useState<QueryShape | undefined>()
const { sm } = useScreenSize()
useEffect(() => { useEffect(() => {
if (queries.length && downPress) { if (queries.length && downPress) {
...@@ -75,7 +75,7 @@ const QueryPicker = ({ hidePicker, queries, ref }: Props) => { ...@@ -75,7 +75,7 @@ const QueryPicker = ({ hidePicker, queries, ref }: Props) => {
}, [hovered, queries]) }, [hovered, queries])
return ( return (
<Wrapper _width={sm ? 370 : 600} ref={ref}> <Wrapper ref={ref}>
<Helper _style="italic" color="draculaForeground" size="xs"> <Helper _style="italic" color="draculaForeground" size="xs">
Navigate the list with <UpArrowSquare size="16px" /> Navigate the list with <UpArrowSquare size="16px" />
<DownArrowSquare size="16px" /> keys, exit with&nbsp; <DownArrowSquare size="16px" /> keys, exit with&nbsp;
......
...@@ -3,17 +3,12 @@ import { useDispatch, useSelector } from "react-redux" ...@@ -3,17 +3,12 @@ import { useDispatch, useSelector } from "react-redux"
import { CSSTransition } from "react-transition-group" import { CSSTransition } from "react-transition-group"
import styled from "styled-components" import styled from "styled-components"
import { createGlobalFadeTransition, TransitionDuration } from "components" import { TransitionDuration } from "components"
import { actions, selectors } from "store" import { actions, selectors } from "store"
import { color } from "utils" import { color } from "utils"
import Schema from "../Schema" import Schema from "../Schema"
const GlobalTransitionStyles = createGlobalFadeTransition(
"side-menu-backdrop-fade",
TransitionDuration.REG,
)
const WIDTH = 280 const WIDTH = 280
const Backdrop = styled.div` const Backdrop = styled.div`
...@@ -68,15 +63,15 @@ const SideMenu = () => { ...@@ -68,15 +63,15 @@ const SideMenu = () => {
return ( return (
<> <>
{opened && <GlobalTransitionStyles />}
<CSSTransition <CSSTransition
classNames="side-menu-backdrop-fade" classNames="fade-reg"
in={opened} in={opened}
timeout={TransitionDuration.REG} timeout={TransitionDuration.REG}
unmountOnExit unmountOnExit
> >
<Backdrop onClick={handleBackdropClick} /> <Backdrop onClick={handleBackdropClick} />
</CSSTransition> </CSSTransition>
<CSSTransition <CSSTransition
classNames="side-menu-slide" classNames="side-menu-slide"
in={opened} in={opened}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册