Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
Move global components to ui package
Browse files Browse the repository at this point in the history
  • Loading branch information
barbarah committed Apr 6, 2023
1 parent 4e28d9c commit 04e82b4
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 13 deletions.
8 changes: 8 additions & 0 deletions apps/dataset-browser/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
module.exports = {
root: true,
extends: ['custom'],
rules: {
'node/no-extraneous-import': [
'error',
{
allowModules: ['ui'],
},
],
},
};
2 changes: 1 addition & 1 deletion apps/dataset-browser/src/app/[locale]/about/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import LocalizedMarkdown from '@/components/localized-markdown';
import {LocalizedMarkdown} from 'ui';

export default function About() {
return <LocalizedMarkdown name="about" />;
Expand Down
2 changes: 1 addition & 1 deletion apps/dataset-browser/src/app/[locale]/client-filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import {SearchOptions, SearchResult} from '@/lib/dataset-fetcher';
import FilterSet from './filter-set';
import Paginator from './paginator';
import {PageTitle, PageHeader} from '@/components/page';
import {PageTitle, PageHeader} from 'ui';
import {useTranslations} from 'next-intl';
import SelectedFilters from './selected-filters';
import {useRouter} from 'next/navigation';
Expand Down
2 changes: 1 addition & 1 deletion apps/dataset-browser/src/app/[locale]/contact/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import LocalizedMarkdown from '@/components/localized-markdown';
import {LocalizedMarkdown} from 'ui';

export default function Contact() {
return <LocalizedMarkdown name="contact" />;
Expand Down
2 changes: 1 addition & 1 deletion apps/dataset-browser/src/app/[locale]/dataset-card.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Link} from 'next-intl';
import {useTranslations} from 'next-intl';
import {Dataset} from '@/lib/dataset-fetcher';
import Badge from '@/components/badge';
import {Badge} from 'ui';

export default function DatasetCard({dataset}: {dataset: Dataset}) {
const t = useTranslations('DatasetCard');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {getTranslations} from 'next-intl/server';
import {PageHeader, PageTitle} from '@/components/page';
import {PageHeader, PageTitle} from 'ui';
import {ChevronLeftIcon} from '@heroicons/react/24/solid';
import datasetFetcher from '@/lib/dataset-fetcher-instance';
import {Link} from 'next-intl';
Expand Down
2 changes: 1 addition & 1 deletion apps/dataset-browser/src/app/[locale]/faq/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import LocalizedMarkdown from '@/components/localized-markdown';
import {LocalizedMarkdown} from 'ui';

export default function Faq() {
return <LocalizedMarkdown name="faq" />;
Expand Down
2 changes: 1 addition & 1 deletion apps/dataset-browser/src/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import './globals.css';
import {useLocale} from 'next-intl';
import {notFound} from 'next/navigation';
import {ReactNode} from 'react';
import Navigation from '@/components/navigation';
import Navigation from './navigation';
import {useTranslations} from 'next-intl';
import {locales} from '@/middleware';

Expand Down
2 changes: 1 addition & 1 deletion apps/dataset-browser/src/app/[locale]/selected-filters.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {SearchResultFilter} from '@/lib/dataset-fetcher';
import {Dispatch} from 'react';
import {useTranslations} from 'next-intl';
import Badge from '@/components/badge';
import {Badge} from 'ui';

interface Props {
filters: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface Props {
variant?: 'transparent' | 'gray';
}

export default function Badge({
export function Badge({
children,
variant = 'transparent',
testId,
Expand Down
5 changes: 4 additions & 1 deletion packages/ui/index.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import * as React from 'react';
export * from './Button';
export * from './badge';
export * from './page';
export * from './localized-markdown';

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ interface Props {
name: string;
}

async function LocalizedMarkdown({name}: Props) {
const LocalizedMarkdown = (async ({ name }: Props) => {
const locale = useLocale();
try {
const Markdown = (await import(`@/messages/${locale}/${name}.mdx`)).default;
Expand All @@ -17,11 +17,12 @@ async function LocalizedMarkdown({name}: Props) {
} catch {
notFound();
}
}
}) as unknown as (props: Props) => JSX.Element

// TypeScript doesn't understand async components yet.
// So this is a temporary workaround.
// More info:
// - Next.js issue: https://github.com/vercel/next.js/issues/42292
// - Typescript pull request: https://github.com/microsoft/TypeScript/pull/51328
export default LocalizedMarkdown as unknown as (props: Props) => JSX.Element;
// export LocalizedMarkdown as unknown as (props: Props) => JSX.Element;
export {LocalizedMarkdown};
File renamed without changes.

0 comments on commit 04e82b4

Please sign in to comment.