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

chore: reduce Searchbox button layout shift #7358

Merged
merged 4 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading