diff --git a/COLLABORATOR_GUIDE.md b/COLLABORATOR_GUIDE.md index e87607377f88c..2fd1c8451d787 100644 --- a/COLLABORATOR_GUIDE.md +++ b/COLLABORATOR_GUIDE.md @@ -287,7 +287,7 @@ They also allow Developers to preview Components and be able to test them manual ```tsx import type { Meta as MetaObj, StoryObj } from '@storybook/react'; -import NameOfComponent from './index'; +import NameOfComponent from '@components/PathTo/YourComponent'; type Story = StoryObj; type Meta = MetaObj; diff --git a/components/Common/AvatarGroup/Avatar/index.stories.tsx b/components/Common/AvatarGroup/Avatar/index.stories.tsx index ef5432bf3f4b6..c70c047e7445e 100644 --- a/components/Common/AvatarGroup/Avatar/index.stories.tsx +++ b/components/Common/AvatarGroup/Avatar/index.stories.tsx @@ -1,9 +1,8 @@ import type { Meta as MetaObj, StoryObj } from '@storybook/react'; +import Avatar from '@/components/Common/AvatarGroup/Avatar'; import { githubProfileAvatarUrl } from '@/util/gitHubUtils'; -import Avatar from './'; - type Story = StoryObj; type Meta = MetaObj; diff --git a/components/Common/AvatarGroup/index.stories.tsx b/components/Common/AvatarGroup/index.stories.tsx index 9b3022e65391a..6dff66e2e20b7 100644 --- a/components/Common/AvatarGroup/index.stories.tsx +++ b/components/Common/AvatarGroup/index.stories.tsx @@ -1,9 +1,8 @@ import type { Meta as MetaObj, StoryObj } from '@storybook/react'; +import AvatarGroup from '@/components/Common/AvatarGroup'; import { githubProfileAvatarUrl } from '@/util/gitHubUtils'; -import AvatarGroup from './'; - type Story = StoryObj; type Meta = MetaObj; diff --git a/components/Common/AvatarGroup/index.tsx b/components/Common/AvatarGroup/index.tsx index 76af32e001f96..fdd8d1b475d0d 100644 --- a/components/Common/AvatarGroup/index.tsx +++ b/components/Common/AvatarGroup/index.tsx @@ -2,10 +2,10 @@ import classNames from 'classnames'; import type { ComponentProps, FC } from 'react'; import { useState, useMemo } from 'react'; +import Avatar from '@/components/Common/AvatarGroup/Avatar'; +import avatarstyles from '@/components/Common/AvatarGroup/Avatar/index.module.css'; import { getAcronymFromString } from '@/util/stringUtils'; -import Avatar from './Avatar'; -import avatarstyles from './Avatar/index.module.css'; import styles from './index.module.css'; type AvatarGroupProps = { diff --git a/components/Common/Badge/index.stories.tsx b/components/Common/Badge/index.stories.tsx index 698109a31677b..0b200b997c009 100644 --- a/components/Common/Badge/index.stories.tsx +++ b/components/Common/Badge/index.stories.tsx @@ -1,6 +1,6 @@ import type { Meta as MetaObj, StoryObj } from '@storybook/react'; -import Badge from './index'; +import Badge from '@/components/Common/Badge'; type Story = StoryObj; type Meta = MetaObj; diff --git a/components/Common/Banner/index.stories.tsx b/components/Common/Banner/index.stories.tsx index 1ce2db2887a7d..1bafc10b2d006 100644 --- a/components/Common/Banner/index.stories.tsx +++ b/components/Common/Banner/index.stories.tsx @@ -1,6 +1,6 @@ import type { Meta as MetaObj, StoryObj } from '@storybook/react'; -import Banner from './index'; +import Banner from '@/components/Common/Banner'; type Story = StoryObj; type Meta = MetaObj; diff --git a/components/Common/Blockquote/index.stories.tsx b/components/Common/Blockquote/index.stories.tsx index 62ef494bd5f3d..d00a56c084f33 100644 --- a/components/Common/Blockquote/index.stories.tsx +++ b/components/Common/Blockquote/index.stories.tsx @@ -1,6 +1,6 @@ import type { Meta as MetaObj, StoryObj } from '@storybook/react'; -import Blockquote from './index'; +import Blockquote from '@/components/Common/Blockquote'; type Story = StoryObj; type Meta = MetaObj; diff --git a/components/Common/Breadcrumbs/index.stories.tsx b/components/Common/Breadcrumbs/index.stories.tsx index 1e25483c2ee71..678def7290c08 100644 --- a/components/Common/Breadcrumbs/index.stories.tsx +++ b/components/Common/Breadcrumbs/index.stories.tsx @@ -1,6 +1,6 @@ import type { Meta as MetaObj, StoryObj } from '@storybook/react'; -import Breadcrumbs from './'; +import Breadcrumbs from '@/components/Common/Breadcrumbs'; type Story = StoryObj; type Meta = MetaObj; diff --git a/components/Common/Breadcrumbs/index.tsx b/components/Common/Breadcrumbs/index.tsx index bafede32626e4..512e89c279809 100644 --- a/components/Common/Breadcrumbs/index.tsx +++ b/components/Common/Breadcrumbs/index.tsx @@ -1,11 +1,11 @@ import { type LinkProps } from 'next/link'; import { useMemo, type FC } from 'react'; -import BreadcrumbHomeLink from './BreadcrumbHomeLink'; -import BreadcrumbItem from './BreadcrumbItem'; -import BreadcrumbLink from './BreadcrumbLink'; -import BreadcrumbRoot from './BreadcrumbRoot'; -import BreadcrumbTruncatedItem from './BreadcrumbTruncatedItem'; +import BreadcrumbHomeLink from '@/components/Common/Breadcrumbs/BreadcrumbHomeLink'; +import BreadcrumbItem from '@/components/Common/Breadcrumbs/BreadcrumbItem'; +import BreadcrumbLink from '@/components/Common/Breadcrumbs/BreadcrumbLink'; +import BreadcrumbRoot from '@/components/Common/Breadcrumbs/BreadcrumbRoot'; +import BreadcrumbTruncatedItem from '@/components/Common/Breadcrumbs/BreadcrumbTruncatedItem'; type BreadcrumbLink = { label: string; diff --git a/components/Common/Button/index.stories.tsx b/components/Common/Button/index.stories.tsx index c2ba29a4ee2b3..b7fe58cff4ada 100644 --- a/components/Common/Button/index.stories.tsx +++ b/components/Common/Button/index.stories.tsx @@ -1,6 +1,6 @@ import type { Meta as MetaObj, StoryObj } from '@storybook/react'; -import Button from './index'; +import Button from '@/components/Common/Button'; type Story = StoryObj; type Meta = MetaObj; diff --git a/components/Common/Button/index.tsx b/components/Common/Button/index.tsx index d8081a7d7152a..5ef4b8bec23bc 100644 --- a/components/Common/Button/index.tsx +++ b/components/Common/Button/index.tsx @@ -12,14 +12,13 @@ const Button: FC = ({ children, className, ...props -}) => { - const buttonStyles = classNames(styles.button, styles[variant], className); - - return ( - - ); -}; +}) => ( + +); export default Button; diff --git a/components/Common/CrossLink/index.stories.tsx b/components/Common/CrossLink/index.stories.tsx index 01b2f6994f42c..20f4deb5dd53a 100644 --- a/components/Common/CrossLink/index.stories.tsx +++ b/components/Common/CrossLink/index.stories.tsx @@ -1,6 +1,6 @@ import type { Meta as MetaObj, StoryObj } from '@storybook/react'; -import CrossLink from './index'; +import CrossLink from '@/components/Common/CrossLink'; type Story = StoryObj; type Meta = MetaObj; diff --git a/components/Common/LanguageDropDown/index.module.css b/components/Common/LanguageDropDown/index.module.css index 9f8f4b3800be9..c5dd3c9bd6e9e 100644 --- a/components/Common/LanguageDropDown/index.module.css +++ b/components/Common/LanguageDropDown/index.module.css @@ -1,9 +1,9 @@ .iconWrapper { @apply h-9 w-9 - rounded-md - bg-neutral-100 - p-2 + rounded-md + bg-neutral-100 + p-2 text-neutral-700 dark:bg-neutral-900 dark:text-neutral-300; @@ -12,23 +12,27 @@ .dropDownContent { @apply max-h-80 w-48 - overflow-y-scroll + overflow-hidden rounded - border - border-neutral-200 - py-[1px] + border + border-neutral-200 shadow-lg dark:border-neutral-900; + + > div { + @apply max-h-80 + w-48 overflow-y-auto; + } } .dropDownItem { - @apply cursor-default + @apply cursor-pointer px-2.5 - py-1.5 - text-sm + py-1.5 + text-sm font-medium - text-neutral-800 - outline-none + text-neutral-800 + outline-none data-[highlighted]:bg-green-600 data-[highlighted]:text-white dark:text-white; diff --git a/components/Common/LanguageDropDown/index.stories.tsx b/components/Common/LanguageDropDown/index.stories.tsx index 49ca0c78c5510..1454c5940a3f4 100644 --- a/components/Common/LanguageDropDown/index.stories.tsx +++ b/components/Common/LanguageDropDown/index.stories.tsx @@ -1,10 +1,19 @@ import type { Meta as MetaObj, StoryObj } from '@storybook/react'; -import LanguageDropDown from './index'; +import LanguageDropDown from '@/components/Common/LanguageDropDown'; type Story = StoryObj; type Meta = MetaObj; -export const Default: Story = {}; +export const Default: Story = { + args: { + availableLanguages: [ + { name: 'English', code: 'en' }, + { name: 'French', code: 'fr' }, + { name: 'Spanish', code: 'es' }, + ], + currentLanguage: { name: 'English', code: 'en' }, + }, +}; export default { component: LanguageDropDown } as Meta; diff --git a/components/Common/LanguageDropDown/index.tsx b/components/Common/LanguageDropDown/index.tsx index 69964dad7b094..5c2f81bf6d063 100644 --- a/components/Common/LanguageDropDown/index.tsx +++ b/components/Common/LanguageDropDown/index.tsx @@ -4,21 +4,26 @@ import classNames from 'classnames'; import type { FC } from 'react'; import { useIntl } from 'react-intl'; -import { useLocale } from '@/hooks/useLocale'; +import type { LocaleConfig } from '@/types'; import styles from './index.module.css'; -export type LanguageDropDownProps = { - onClick?: () => void; +type SimpleLocaleConfig = Pick; + +type LanguageDropDownProps = { + onChange?: (newLocale: SimpleLocaleConfig) => void; + currentLanguage: SimpleLocaleConfig; + availableLanguages: SimpleLocaleConfig[]; }; const LanguageDropdown: FC = ({ - onClick = () => {}, + onChange = () => {}, + currentLanguage, + availableLanguages, }) => { - const { availableLocales, currentLocale } = useLocale(); - const intl = useIntl(); + const { formatMessage } = useIntl(); - const ariaLabel = intl.formatMessage({ + const ariaLabel = formatMessage({ id: 'components.common.languageDropdown.label', }); @@ -36,17 +41,19 @@ const LanguageDropdown: FC = ({ className={styles.dropDownContent} sideOffset={5} > - {availableLocales.map(({ name, code }) => ( - - {name} - - ))} +
+ {availableLanguages.map(({ name, code }) => ( + onChange({ name, code })} + className={classNames(styles.dropDownItem, { + [styles.currentDropDown]: code === currentLanguage.code, + })} + > + {name} + + ))} +
diff --git a/components/Common/MetaBar/index.stories.tsx b/components/Common/MetaBar/index.stories.tsx index acce0aa8effd5..4be3e7192d185 100644 --- a/components/Common/MetaBar/index.stories.tsx +++ b/components/Common/MetaBar/index.stories.tsx @@ -4,10 +4,9 @@ import Image from 'next/image'; import { FormattedMessage } from 'react-intl'; import AvatarGroup from '@/components/Common/AvatarGroup'; +import MetaBar from '@/components/Common/MetaBar'; import LocalizedLink from '@/components/LocalizedLink'; -import MetaBar from './index'; - type Story = StoryObj; type Meta = MetaObj; diff --git a/components/Common/Notification/index.stories.tsx b/components/Common/Notification/index.stories.tsx index 0aa59b809ce7a..240b37bb77a12 100644 --- a/components/Common/Notification/index.stories.tsx +++ b/components/Common/Notification/index.stories.tsx @@ -2,7 +2,7 @@ import { CodeBracketIcon } from '@heroicons/react/24/solid'; import type { Meta as MetaObj, StoryObj } from '@storybook/react'; import { FormattedMessage } from 'react-intl'; -import Notification from './index'; +import Notification from '@/components/Common/Notification'; type Story = StoryObj; type Meta = MetaObj; diff --git a/components/Common/Pagination/PaginationListItem/index.tsx b/components/Common/Pagination/PaginationListItem/index.tsx index e8ce23810ddfe..90c89a559fcb7 100644 --- a/components/Common/Pagination/PaginationListItem/index.tsx +++ b/components/Common/Pagination/PaginationListItem/index.tsx @@ -19,13 +19,13 @@ const PaginationListItem: FC = ({ currentPage, totalPages, }) => { - const intl = useIntl(); + const { formatMessage } = useIntl(); return (
  • ; type Meta = MetaObj; diff --git a/components/Common/Pagination/index.tsx b/components/Common/Pagination/index.tsx index 8eff8017e01cf..f2ca0e090fdc7 100644 --- a/components/Common/Pagination/index.tsx +++ b/components/Common/Pagination/index.tsx @@ -9,7 +9,7 @@ import styles from './index.module.css'; type Page = { url: string }; -export type PaginationProps = { +type PaginationProps = { // One-based number of the current page currentPage: number; pages: Page[]; @@ -23,7 +23,7 @@ const Pagination: FC = ({ pages, currentPageSiblingsCount = 1, }) => { - const intl = useIntl(); + const { formatMessage } = useIntl(); const parsedPages = useGetPageElements( currentPage, @@ -33,14 +33,14 @@ const Pagination: FC = ({ return (