Stabalize search pixel shift when zoomed

This commit is contained in:
Dustin Brett 2024-03-28 21:09:19 -07:00
parent 5aafe7f031
commit 6475db133a
6 changed files with 48 additions and 26 deletions

View File

@ -6,7 +6,10 @@ import { THIN_SCROLLBAR_WIDTH } from "utils/constants";
const StyledResults = styled.div` const StyledResults = styled.div`
color: #fff; color: #fff;
display: flex; display: flex;
height: calc(100% - 52px); height: ${({ theme }) =>
`calc(100% - ${theme.sizes.search.headerHeight}px - ${theme.sizes.search.inputHeight}px)`};
position: absolute;
top: ${({ theme }) => `${theme.sizes.search.headerHeight}px`};
width: 100%; width: 100%;
.list { .list {

View File

@ -89,9 +89,13 @@ const StyledSearch = styled(motion.nav)<StyledSearchProps>`
color: rgb(175, 175, 175); color: rgb(175, 175, 175);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: calc(100% - 52px); height: ${({ theme }) =>
`calc(100% - ${theme.sizes.search.headerHeight}px - ${theme.sizes.search.inputHeight}px)`};
place-content: center; place-content: center;
place-items: center; place-items: center;
position: absolute;
top: ${({ theme }) => `${theme.sizes.search.headerHeight}px`};
width: 100%;
h1 { h1 {
font-size: 28px; font-size: 28px;

View File

@ -12,10 +12,14 @@ const StyledSections = styled.div<StyledSectionsProps>`
${ThinScrollBars} ${ThinScrollBars}
color: #fff; color: #fff;
display: flex; display: flex;
height: calc(100% - 52px); height: ${({ theme }) =>
`calc(100% - ${theme.sizes.search.headerHeight}px - ${theme.sizes.search.inputHeight}px)`};
overflow: hidden; overflow: hidden;
place-content: space-evenly; place-content: space-evenly;
place-items: start; place-items: start;
position: absolute;
top: ${({ theme }) => `${theme.sizes.search.headerHeight}px`};
width: 100%;
@media (hover: none), (pointer: coarse) { @media (hover: none), (pointer: coarse) {
overflow-y: scroll; overflow-y: scroll;

View File

@ -8,6 +8,7 @@ const StyledTabs = styled.ol`
font-weight: 600; font-weight: 600;
gap: 1px; gap: 1px;
padding: 2px 13px 0; padding: 2px 13px 0;
position: absolute;
li { li {
color: rgb(215, 215, 215); color: rgb(215, 215, 215);

View File

@ -1,31 +1,39 @@
import { type MotionProps } from "framer-motion"; import { type MotionProps } from "framer-motion";
import { useTheme } from "styled-components";
import { TRANSITIONS_IN_SECONDS } from "utils/constants"; import { TRANSITIONS_IN_SECONDS } from "utils/constants";
const useSearchInputTransition = (): MotionProps => ({ const useSearchInputTransition = (): MotionProps => {
animate: "active", const {
exit: { sizes: { search },
bottom: "-40px", } = useTheme();
position: "absolute", const negativeInputHeight = `-${search.inputHeight}px`;
return {
animate: "active",
exit: {
bottom: negativeInputHeight,
position: "absolute",
transition: {
duration: TRANSITIONS_IN_SECONDS.TASKBAR_ITEM / 10,
ease: "easeIn",
},
},
initial: "initial",
transition: { transition: {
duration: TRANSITIONS_IN_SECONDS.TASKBAR_ITEM / 10, duration: TRANSITIONS_IN_SECONDS.TASKBAR_ITEM / 1,
ease: "easeIn", ease: "easeOut",
}, },
}, variants: {
initial: "initial", active: {
transition: { bottom: 0,
duration: TRANSITIONS_IN_SECONDS.TASKBAR_ITEM / 1, position: "absolute",
ease: "easeOut", },
}, initial: {
variants: { bottom: negativeInputHeight,
active: { position: "absolute",
bottom: 0, },
position: "absolute",
}, },
initial: { };
bottom: "-40px", };
position: "absolute",
},
},
});
export default useSearchInputTransition; export default useSearchInputTransition;

View File

@ -30,6 +30,8 @@ const sizes = {
rowGap: "28px", rowGap: "28px",
}, },
search: { search: {
headerHeight: 52,
inputHeight: 40,
maxHeight: 415, maxHeight: 415,
size: 600, size: 600,
}, },