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

feat: migrate community page folder and their related components to typescript #2857

Merged
merged 24 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0c8532b
migrated ambassadors page
devilkiller-ag Apr 7, 2024
2f22d18
migrated community events page and its dependencies
devilkiller-ag Apr 7, 2024
a4475a5
migrated newsroom page
devilkiller-ag Apr 7, 2024
3127cad
migrated tsc
devilkiller-ag Apr 9, 2024
8b52d59
migrated community index
devilkiller-ag Apr 9, 2024
a28eaa9
migrated dashboard filter
devilkiller-ag Apr 10, 2024
77355fa
migrated dashboard pagination
devilkiller-ag Apr 10, 2024
74d9117
migrated dashboard Table, Row
devilkiller-ag Apr 10, 2024
c8d1eeb
migrated dashboard components
devilkiller-ag Apr 12, 2024
00ba87f
migrated dashboard, and fixed bugs
devilkiller-ag Apr 12, 2024
1981af3
Merge branch 'migrate-ts' into ag-ts-pages
devilkiller-ag Apr 12, 2024
5433f39
fixed linting issue comming from other PR in 404 page
devilkiller-ag Apr 12, 2024
dcc1b67
fix bugs from other PRs
devilkiller-ag Apr 12, 2024
fe052f7
lint fix in navigation component
devilkiller-ag Apr 12, 2024
749f8b3
resolved build error
devilkiller-ag Apr 13, 2024
f88c421
fix translations
anshgoyalevil Apr 15, 2024
652c7ab
fix lint
anshgoyalevil Apr 15, 2024
b65ce95
nit translation bug
anshgoyalevil Apr 15, 2024
9cdcfe5
Merge branch 'asyncapi:master' into ag-ts-pages
devilkiller-ag Apr 18, 2024
f2465fa
rectified style changes
devilkiller-ag Apr 18, 2024
71531f7
Revert "Merge branch 'asyncapi:master' into ag-ts-pages"
devilkiller-ag Apr 18, 2024
997a222
Merge branch 'migrate-ts' into ag-ts-pages
anshgoyalevil Apr 21, 2024
216770f
resolved styling issues
devilkiller-ag Apr 21, 2024
ce6a304
fix lint
anshgoyalevil Apr 21, 2024
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
7 changes: 4 additions & 3 deletions components/Calendar.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import moment from 'moment';
import { twMerge } from 'tailwind-merge';

import type { IEvent } from '@/types/event';
Expand Down Expand Up @@ -38,13 +39,13 @@ export default function Calendar({ className = '', size }: ICalendarProps) {
<li key={index} data-testid='Calendar-list-item'>
<a href={event.url} className='mb-1 mt-2 flex grow flex-col items-start sm:flex-row sm:items-center'>
<div className='inline-flex h-12 min-w-12 flex-row rounded-full bg-pink-500 font-bold text-white'>
<span className='flex-1 self-center text-center'>{event.date.format('D')}</span>
<span className='flex-1 self-center text-center'>{moment(event.date).format('D')}</span>
anshgoyalevil marked this conversation as resolved.
Show resolved Hide resolved
</div>
<div className='grow text-left sm:mt-0 sm:pl-6'>
<h2 className='title-font text-xl font-medium text-gray-900 hover:text-gray-500'>{event.title}</h2>
<p className='text-gray-600'>
{event.date.local().format('LLLL')} UTC
{event.date.local().format('Z')}
{moment(event.date).local().format('LLLL')} UTC
{moment(event.date).local().format('Z')}
</p>
</div>
</a>
Expand Down
69 changes: 69 additions & 0 deletions components/Meeting.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { ArrowRightIcon } from '@heroicons/react/outline';

import { ParagraphTypeStyle } from '@/types/typography/Paragraph';

import Paragraph from './typography/Paragraph';
import TextLink from './typography/TextLink';

interface MeetingProps {
name?: string;
purpose?: string;
host?: string;
hostProfile?: string;
youtube?: string;
bg?: string;
}

/**
* @description This is the meeting card component.
*
* @param {MeetingProps} props - The props of the component.
* @param {string} props.name - The name of the meeting.
* @param {string} props.purpose - The purpose of the meeting.
* @param {string} props.host - The host of the meeting.
* @param {string} props.hostProfile - The host profile of the meeting.
* @param {string} props.youtube - The youtube link of the meeting.
* @param {string} props.bg - The background color of the meeting.
*/
export default function Meeting({
name = '',
purpose = '',
host = '',
hostProfile = '',
youtube = '',
bg = ''
}: MeetingProps) {
return (
<a href={youtube} target='_blank' rel='noreferrer' data-testid='Meeting-link'>
<div
className={`meeting-card bg-overflow-hidden flex h-[300px] w-full cursor-pointer flex-col justify-between p-4 hover:bg-dark hover:text-white lg:w-[300px] ${bg}`}
>
<div>
<h3 className='text-xl' data-testid='Meeting-heading'>
{name}
</h3>
<div data-testid='Meeting-paragraph'>
<Paragraph typeStyle={ParagraphTypeStyle.sm} className='my-4' textColor='white'>
{purpose}
</Paragraph>
</div>
</div>
<div className='flex items-center justify-between'>
<Paragraph typeStyle={ParagraphTypeStyle.md} className='my-4'>
<strong data-testid='Meeting-host'>Host:&nbsp;</strong>
{hostProfile ? (
<TextLink href={hostProfile} target='_blank' className='hover:text-primary-500'>
{host}
</TextLink>
) : (
`${host}.`
)}
</Paragraph>
<div>
<ArrowRightIcon className='ml-3 w-[20px] text-slate-400' />
</div>
</div>
</div>
</a>
);
}
2 changes: 1 addition & 1 deletion components/NewsletterSubscribe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ interface NewsletterSubscribeProps {
* @param {string} props.type - The type of subscription.
*/
export default function NewsletterSubscribe({
className = 'p-8 text-center',
className = 'p-8 text-center text-black',
dark = false,
title = 'Subscribe to our newsletter to receive news about AsyncAPI.',
subtitle = 'We respect your inbox. No spam, promise ✌️',
Expand Down
10 changes: 3 additions & 7 deletions components/buttons/GithubButton.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { ButtonIconPosition, ButtonSize } from '@/types/components/buttons/ButtonPropsType';

import { useTranslation } from '../../utils/i18n';
import IconGithub from '../icons/Github';
import Button from './Button';
import type { IButtonDefaultProps } from './types';
// TODO: add this again when we have i18n
// import { useTranslation } from '../../lib/i18n'

interface IGithubButtonProps extends IButtonDefaultProps {
inNav?: boolean;
Expand All @@ -26,14 +25,11 @@ export default function GithubButton({
className,
inNav
}: IGithubButtonProps) {
// TODO: add this again when we have i18n
// const { t } = useTranslation("common");
const { t } = useTranslation('common');

return (
<Button
// TODO: add this again when we have i18n
// text={t(text)}
text={text}
text={t(text)}
icon={<IconGithub className='-mt-1 inline-block size-6' />}
href={href}
iconPosition={iconPosition}
Expand Down
10 changes: 3 additions & 7 deletions components/buttons/GoogleCalendarButton.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { ButtonIconPosition } from '@/types/components/buttons/ButtonPropsType';

import { useTranslation } from '../../utils/i18n';
import IconGoogleCalendar from '../icons/GoogleCalendar';
import Button from './Button';
import type { IButtonDefaultProps } from './types';
// TODO: add this again when we have i18n
// import { useTranslation } from '../../lib/i18n';

interface IGoogleCalendarButtonProps extends IButtonDefaultProps {}

Expand All @@ -23,14 +22,11 @@ export default function GoogleCalendarButton({
iconPosition = ButtonIconPosition.LEFT,
className
}: IGoogleCalendarButtonProps) {
// TODO: add this again when we have i18n
// const { t } = useTranslation('common');
const { t } = useTranslation('common');

return (
<Button
// TODO: add this again when we have i18n
// text={t(text)}
text={text}
text={t(text)}
icon={<IconGoogleCalendar />}
href={href}
iconPosition={iconPosition}
Expand Down
10 changes: 3 additions & 7 deletions components/buttons/ICSFileButton.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { ButtonIconPosition } from '@/types/components/buttons/ButtonPropsType';

import { useTranslation } from '../../utils/i18n';
import IconCalendar from '../icons/Calendar';
import Button from './Button';
// TODO: add this again when we have i18n
// import { useTranslation } from '../../lib/i18n';
import type { IButtonDefaultProps } from './types';

interface IICSFButtonProps extends IButtonDefaultProps {}
Expand All @@ -23,14 +22,11 @@ export default function ICSFButton({
iconPosition = ButtonIconPosition.LEFT,
className
}: IICSFButtonProps) {
// TODO: add this again when we have i18n
// const { t } = useTranslation('common');
const { t } = useTranslation('common');

return (
<Button
// TODO: add this again when we have i18n
// text={t(text)}
text={text}
text={t(text)}
icon={<IconCalendar />}
href={href}
iconPosition={iconPosition}
Expand Down
8 changes: 3 additions & 5 deletions components/buttons/SubscribeButton.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ButtonIconPosition } from '@/types/components/buttons/ButtonPropsType';

import { useTranslation } from '../../utils/i18n';
import IconSubscribe from '../icons/Subscribe';
import Button from './Button';
// import { useTranslation } from '../../lib/i18n';
import type { IButtonDefaultProps } from './types';

interface IGoogleCalendarButtonProps extends IButtonDefaultProps {}
Expand All @@ -22,13 +22,11 @@ export default function GoogleCalendarButton({
iconPosition = ButtonIconPosition.LEFT,
className
}: IGoogleCalendarButtonProps) {
// const { t } = useTranslation('common');
const { t } = useTranslation('common');

return (
<Button
// TODO: add this again when we have i18n
// text={t(text)}
text={text}
text={t(text)}
icon={<IconSubscribe />}
href={href}
iconPosition={iconPosition}
Expand Down
16 changes: 8 additions & 8 deletions components/community/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import Paragraph from '../typography/Paragraph';
interface CardProps {
icon: string;
tagline: string;
taglineBg: string;
taglineBg?: string;
type?: CardType;
heading: string;
description: string;
bg: string;
btnText: string;
btnBg: string;
btnText?: string;
btnBg?: string;
link: string;
}

Expand All @@ -38,13 +38,13 @@ interface CardProps {
export default function Card({
icon,
tagline,
taglineBg,
taglineBg = '',
type = CardType.LARGE,
heading,
description,
bg,
btnText,
btnBg,
btnText = '',
btnBg = '',
link
}: CardProps) {
if (type === CardType.SMALL) {
Expand All @@ -63,7 +63,7 @@ export default function Card({
</Heading>
</div>
<div className='mt-2' data-testid='Card-desc'>
<Paragraph textColor={bg ? 'text-black' : 'text-gray-600'} typeStyle={ParagraphTypeStyle.sm}>
<Paragraph textColor={bg === 'bg-white' ? 'text-gray-600' : 'text-black'} typeStyle={ParagraphTypeStyle.sm}>
{description}
</Paragraph>
</div>
Expand All @@ -81,7 +81,7 @@ export default function Card({
data-testid='Card-lg-bg'
>
<div
className={`flex w-min justify-between rounded-xl p-2 text-center text-xs ${taglineBg}`}
className={`flex w-min justify-between rounded-xl p-2 text-center text-xs text-black ${taglineBg}`}
data-testid='Card-lg-tagline'
>
<span>{icon}</span> <span className='ml-[5px]'>{tagline}</span>
Expand Down
2 changes: 1 addition & 1 deletion components/community/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function Header({ className = '' }: HeaderProps) {
level={HeadingLevel.h2}
typeStyle={HeadingTypeStyle.bodyMd}
textColor='text-gray-700'
className='text-sm text-slate-500'
className='text-slate-500'
>
We&apos;re an OSS community that&apos;s passionate about AsyncAPI. Join us in building the future of Event
Driven APIs by asking questions, sharing ideas, and building connections.
Expand Down
2 changes: 1 addition & 1 deletion components/community/HomeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function HomeCards({ headline, title, description, btnText, link,
level={HeadingLevel.h2}
typeStyle={HeadingTypeStyle.bodyLg}
textColor='text-gray-700'
className='mt-10 text-sm text-slate-500'
className='mt-10 text-slate-500'
>
{description}
</Heading>
Expand Down
24 changes: 24 additions & 0 deletions components/dashboard/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
interface ButtonProps {
text: string;
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
}

/**
* @description Button component.
*
* @param {ButtonProps} props - The props of the component.
* @param {string} props.text - The text of the button.
* @param {Function} props.onClick - The function to be called when the button is clicked.
*/
function Button({ text, onClick }: ButtonProps) {
return (
<button
onClick={onClick}
className='rounded-r bg-gray-300 px-4 py-2 text-sm font-semibold text-gray-800 hover:bg-gray-400'
>
{text}
</button>
);
}

export default Button;
84 changes: 84 additions & 0 deletions components/dashboard/GoodFirstIssues.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { useState } from 'react';

import type { Issue } from '@/types/components/dashboard/TableTypes';

import GoodFirstIssuesTip from './GoodFirstIssuesTip';
import Filters from './table/Filters';
import Table from './table/Table';

interface FiltersType {
selectedRepo: string;
selectedArea: string;
}

interface GoodFirstIssuesProps {
issues: Issue[];
}

/**
* @description Filter issues based on selected repo and area.
*
* @param {Issue[]} issues - The list of issues to filter.
* @param {FiltersType} filters - The filters to apply.
* @returns {Issue[]} The filtered list of issues.
*/
export function filterIssues(issues: Issue[], filters: FiltersType): Issue[] {
let result = issues;

if (filters.selectedRepo !== 'Repository - All') {
result = result.filter((issue) => issue.repo === filters.selectedRepo);
}
if (filters.selectedArea !== 'Area - All') {
result = result.filter((issue) => issue.area === filters.selectedArea);
}

return result;
}

/**
* @description Component that displays a list of good first issues.
*
* @param {GoodFirstIssuesProps} props - The props for the component.
* @param {Issue[]} props.issues - The list of good first issues.
*/
export default function GoodFirstIssues({ issues }: GoodFirstIssuesProps) {
const [selectedRepo, setSelectedRepo] = useState('All');
const [selectedArea, setSelectedArea] = useState('All');

// Get current issues

let filteredIssues = issues;

const allIssues = issues;

if (selectedRepo !== 'All') {
filteredIssues = filteredIssues.filter((issue) => issue.repo === selectedRepo);
}
if (selectedArea !== 'All') {
filteredIssues = filteredIssues.filter((issue) => issue.area === selectedArea);
}

return (
<Table
title={
<div className='flex gap-3' data-testid='GoodFirstIssues-main-div'>
<span>Good First Issues</span>
<GoodFirstIssuesTip />
<Filters
className='ml-auto'
data-testid='GoodFirstIssues-filter-component'
issues={filteredIssues}
allIssues={allIssues}
setSelectedRepo={setSelectedRepo}
setSelectedArea={setSelectedArea}
selectedArea={selectedArea}
selectedRepo={selectedRepo}
/>
</div>
}
data={filteredIssues.slice(0, 24)}
className='grow'
listClassName='lg:grid-cols-2'
/>
);
}
Loading
Loading