Skip to content

Commit

Permalink
chore: reduce Searchbox button layout shift (#7358)
Browse files Browse the repository at this point in the history
  • Loading branch information
rjborba authored Jan 6, 2025
1 parent 4b710a9 commit fef1932
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
3 changes: 3 additions & 0 deletions apps/site/components/Common/Search/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import tailwindConfig from '@/tailwind.config';

const colors = tailwindConfig.theme.colors;
export const themeConfig = {
typography: {
'--font-primary': 'var(--font-open-sans)',
},
colors: {
light: {
'--text-color-primary': colors.neutral[900],
Expand Down
6 changes: 4 additions & 2 deletions apps/site/components/Common/Skeleton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import classNames from 'classnames';
import type { FC, PropsWithChildren } from 'react';
import { isValidElement } from 'react';

import styles from './index.module.css';

type SkeletonProps = { hide?: boolean; loading?: boolean };
type SkeletonProps = { hide?: boolean; loading?: boolean; className?: string };

const Skeleton: FC<PropsWithChildren<SkeletonProps>> = ({
children,
className,
hide = false,
loading = true,
}) => {
Expand All @@ -26,7 +28,7 @@ const Skeleton: FC<PropsWithChildren<SkeletonProps>> = ({
<span
tabIndex={-1}
aria-hidden="true"
className={styles.skeleton}
className={classNames(styles.skeleton, className)}
data-inline-skeleton={isValidElement(children) ? undefined : true}
>
{children}
Expand Down
11 changes: 11 additions & 0 deletions apps/site/components/Containers/NavBar/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@
dark:border-neutral-900;
}

span.searchButtonSkeleton {
@apply my-px
mr-2
flex-grow
rounded-xl;

&:empty {
@apply h-10;
}
}

.ghIconWrapper {
@apply size-9
rounded-md
Expand Down
4 changes: 4 additions & 0 deletions apps/site/components/Containers/NavBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useState } from 'react';
import type { FC, ComponentProps, HTMLAttributeAnchorTarget } from 'react';

import LanguageDropdown from '@/components/Common/LanguageDropDown';
import Skeleton from '@/components/Common/Skeleton';
import ThemeToggle from '@/components/Common/ThemeToggle';
import NavItem from '@/components/Containers/NavBar/NavItem';
import GitHub from '@/components/Icons/Social/GitHub';
Expand All @@ -19,6 +20,9 @@ import style from './index.module.css';

const SearchButton = dynamic(() => import('@/components/Common/Search'), {
ssr: false,
loading: () => (
<Skeleton className={style.searchButtonSkeleton} loading={true} />
),
});

const navInteractionIcons = {
Expand Down

0 comments on commit fef1932

Please sign in to comment.