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

[Lexical][Gallery] Convert files to follow typescript #6383

Merged
merged 3 commits into from
Jul 9, 2024
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
1 change: 1 addition & 0 deletions packages/lexical-website/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
/fb/sdoc-cache.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ import Heading from '@theme/Heading';
import clsx from 'clsx';
import React from 'react';

import {Example} from './pluginList';
import styles from './styles.module.css';

function getCardImage(item) {
function getCardImage(item: Example) {
return (
item.preview ??
`https://slorber-api-screenshot.netlify.app/${encodeURIComponent(
item.uri,
item.uri ?? '',
)}/showcase`
);
}

function Card({item}) {
function Card({item}: {item: Example}) {
const image = getCardImage(item);
return (
<li key={item.title} className="card shadow--md">
Expand All @@ -35,7 +36,7 @@ function Card({item}) {
<div className="card__body">
<div className={clsx(styles.showcaseCardHeader)}>
<Heading as="h4" className={styles.showcaseCardTitle}>
<Link href={item.website} className={styles.showcaseCardLink}>
<Link href={item.uri} className={styles.showcaseCardLink}>
{item.title}
</Link>
</Heading>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
import BrowserOnly from '@docusaurus/BrowserOnly';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import clsx from 'clsx';
import {useEffect, useState} from 'react';
import React, {useEffect, useState} from 'react';

import Card from './Card';
import SearchBar from './components/SearchBar';
import {plugins} from './pluginList';
import {Example, plugins} from './pluginList';
import styles from './styles.module.css';
import {useFilteredExamples} from './utils';

function CardList({cards}) {
function CardList({cards}: {cards: Array<Example>}) {
return (
<div className="container">
<ul className={clsx('clean-list', styles.cardList)}>
{cards.map((item) => (
{cards.map((item: Example) => (
<Card key={item.title} item={item} />
))}
</ul>
Expand All @@ -38,7 +38,9 @@ function GalleryCardsImpl() {
siteConfig: {customFields},
} = useDocusaurusContext();

const [internGalleryCards, setInternGalleryCards] = useState(null);
const [internGalleryCards, setInternGalleryCards] = useState<{
InternGalleryCards: () => Array<Example>;
} | null>(null);

const pluginsCombined = plugins(customFields ?? {}).concat(
internGalleryCards != null ? internGalleryCards.InternGalleryCards() : [],
Expand All @@ -47,12 +49,9 @@ function GalleryCardsImpl() {
const filteredPlugins = useFilteredExamples(pluginsCombined);

useEffect(() => {
try {
if (process.env.FB_INTERNAL) {
import('../../../../InternGalleryCards').then(setInternGalleryCards);
}
} catch (e) {
throw e;
if (process.env.FB_INTERNAL) {
// @ts-ignore runtime dependency for intern builds
import('../../../../InternGalleryCards').then(setInternGalleryCards);
}
}, []);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
*
*/

import {ReactNode} from 'react';

export type Example = {
description: string;
title: string;
uri?: string;
renderPreview?: () => unknown;
preview?: string;
renderPreview?: () => ReactNode;
};

export const plugins = (customFields: {
Expand Down
Loading