From 8684351bd801250a6fde4465ae16ee2849d77ea1 Mon Sep 17 00:00:00 2001 From: Brion Date: Sat, 21 Dec 2024 23:39:29 +0530 Subject: [PATCH 1/4] chore: move configurations to a `meetup.config` --- .eslintrc.js | 36 ++++++- apps/www/.eslintrc.cjs | 1 + apps/www/app/layout.tsx | 32 +++--- apps/www/app/page.tsx | 2 +- apps/www/components/FlipWords.tsx | 131 +++++++++++++------------ apps/www/components/Footer.tsx | 58 ++++++----- apps/www/components/Hero.tsx | 69 +++++-------- apps/www/components/NavBar.tsx | 10 +- apps/www/components/RegisterButton.tsx | 2 +- apps/www/hooks/useMeetupConfig.ts | 14 +++ apps/www/meetup.config.tsx | 52 ++++++++++ apps/www/package.json | 2 +- apps/www/public/robots.txt | 2 + apps/www/tsconfig.json | 2 +- apps/www/types/meetup-config.ts | 38 +++++++ package.json | 4 +- packages/js/.eslintrc.cjs | 3 +- packages/react/.eslintrc.cjs | 3 +- pnpm-lock.yaml | 124 +++++++---------------- turbo.json | 3 +- 20 files changed, 343 insertions(+), 245 deletions(-) create mode 100644 apps/www/hooks/useMeetupConfig.ts create mode 100644 apps/www/meetup.config.tsx create mode 100644 apps/www/public/robots.txt create mode 100644 apps/www/types/meetup-config.ts diff --git a/.eslintrc.js b/.eslintrc.js index c80d021..1d1c29d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,7 +1,7 @@ /** * MIT License * - * Copyright (c) 2024, Brion Mario + * Copyright (c) 2024, JavaScript Colombo * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,6 +22,35 @@ * SOFTWARE. */ +const LICENSE_HEADER_DEFAULT_PATTERN = [ + '*', + ' * MIT License', + ' *', + { + pattern: ' Copyright \\(c\\) \\d{4}, JavaScript Colombo', + template: ` * Copyright (c) ${new Date().getFullYear()}, JavaScript Colombo`, + }, + ' *', + ' * Permission is hereby granted, free of charge, to any person obtaining a copy', + ' * of this software and associated documentation files (the "Software"), to deal', + ' * in the Software without restriction, including without limitation the rights', + ' * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell', + ' * copies of the Software, and to permit persons to whom the Software is', + ' * furnished to do so, subject to the following conditions:', + ' *', + ' * The above copyright notice and this permission notice shall be included in all', + ' * copies or substantial portions of the Software.', + ' *', + ' * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR', + ' * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,', + ' * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE', + ' * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER', + ' * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,', + ' * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE', + ' * SOFTWARE.', + ' ', +]; + module.exports = { env: { es6: true, @@ -29,4 +58,9 @@ module.exports = { }, extends: ['turbo', 'plugin:@brionmario/internal', 'plugin:@brionmario/prettier'], plugins: ['@brionmario'], + rules: { + // Enforce JavaScript Colombo's license header. + // https://github.com/Stuk/eslint-plugin-header + 'header/header': ['warn', 'block', LICENSE_HEADER_DEFAULT_PATTERN, 2], + }, }; diff --git a/apps/www/.eslintrc.cjs b/apps/www/.eslintrc.cjs index 0ec0501..589ac19 100644 --- a/apps/www/.eslintrc.cjs +++ b/apps/www/.eslintrc.cjs @@ -35,6 +35,7 @@ module.exports = { 'plugin:@brionmario/prettier', 'plugin:@brionmario/next', 'plugin:react/jsx-runtime', + '../../.eslintrc.js' ], parserOptions: { project: [path.resolve(__dirname, 'tsconfig.json')], diff --git a/apps/www/app/layout.tsx b/apps/www/app/layout.tsx index 1a3c00e..f874600 100644 --- a/apps/www/app/layout.tsx +++ b/apps/www/app/layout.tsx @@ -25,9 +25,10 @@ import type {Metadata} from 'next'; import {ReactElement} from 'react'; import ThemeProvider from '@/components/ThemeProvider'; -import './globals.scss'; -import './custom.scss'; import {inter, spaceGrotesk} from './fonts'; +import useMeetupConfig from '@/hooks/useMeetupConfig'; +import './custom.scss'; +import './globals.scss'; export const metadata: Metadata = { title: 'JavaScript Colombo', @@ -39,14 +40,23 @@ const RootLayout = ({ children, }: Readonly<{ children: React.ReactNode; -}>): ReactElement => ( - - - - {children} - - - -); +}>): ReactElement => { + const {config} = useMeetupConfig(); + + return ( + + + + {children} + + + + ); +}; export default RootLayout; diff --git a/apps/www/app/page.tsx b/apps/www/app/page.tsx index 54af9c8..7a6d274 100644 --- a/apps/www/app/page.tsx +++ b/apps/www/app/page.tsx @@ -53,10 +53,10 @@ export default function Home(): ReactElement {
+
- + ); +}); export default Footer; diff --git a/apps/www/components/Hero.tsx b/apps/www/components/Hero.tsx index c1f2374..f84851e 100644 --- a/apps/www/components/Hero.tsx +++ b/apps/www/components/Hero.tsx @@ -31,11 +31,11 @@ import {AppRouterInstance} from 'next/dist/shared/lib/app-router-context.shared- import {cn} from '@/lib/utils'; import {TestableComponent} from '@/types/dom'; import NelumKuluna from '@/icons/NelumKuluna'; -import CoffeeBeans from '@/icons/CoffeeBeans'; import RegisterButton from './RegisterButton'; import FlipWords from './FlipWords'; import Meetup from '@/icons/Meetup'; import {goodBrush} from '@/app/fonts'; +import useMeetupConfig from '@/hooks/useMeetupConfig'; export type HeroProps = HTMLAttributes & TestableComponent; @@ -43,15 +43,11 @@ const Hero: ForwardRefExoticComponent> HTMLDivElement, HeroProps >(({className, ...rest}: HeroProps, ref: ForwardedRef) => { + const {config} = useMeetupConfig(); const router: AppRouterInstance = useRouter(); const handleRegisterClick = (): void => { - const orgName: string | undefined = process.env.NEXT_PUBLIC_ASGARDEO_CLIENT_APP_ORG || ''; - const clientId: string | undefined = process.env.NEXT_PUBLIC_ASGARDEO_CLIENT_APP_ID || ''; - const appName: string | undefined = process.env.NEXT_PUBLIC_ASGARDEO_CLIENT_APP_NAME || ''; - - const url: string = `https://accounts.asgardeo.io/t/${orgName}/accountrecoveryendpoint/register.do?client_id=${clientId}&sp=${appName}`; - router.push(url); + router.push(config.links.meetup.url); }; return ( @@ -66,51 +62,36 @@ const Hero: ForwardRefExoticComponent>

- JavaScript Colombo + {config.hero.title}

- Let's meetup in Colombo, grab a coffee - and talk{' '} - - ` - JavaScript - ` - + {config.hero.tagline}

-
-

🔔 Next session

-

- - Nov 6th 2024 - - ,{' '} - - - 6:00 PM Eastern - {' '} - at{' '} - - - WSO2, Colombo 4, Sri Lanka - -

-
+ {config.hero.showNextMeetupSummary && ( +
+

🔔 Next session

+

+ + {config.meetups.next.date} + + ,{' '} + + + {config.meetups.next.time} + {' '} + at{' '} + + + {config.meetups.next.location} + +

+
+ )}
-
-
- - check us out on{' '} - - - - - -
-
diff --git a/apps/www/components/NavBar.tsx b/apps/www/components/NavBar.tsx index e3d8ad3..7cf57a8 100644 --- a/apps/www/components/NavBar.tsx +++ b/apps/www/components/NavBar.tsx @@ -34,6 +34,7 @@ import {useReducedMotion, AnimatePresence, motion, Transition} from 'framer-moti import {AppRouterInstance} from 'next/dist/shared/lib/app-router-context.shared-runtime'; import Logo from './Logo'; import NavLink, {MobileNavLink} from './NavLink'; +import useMeetupConfig from '@/hooks/useMeetupConfig'; /** * The `NavBarProps` interface represents the props accepted by the `NavBar` component. @@ -58,6 +59,7 @@ export interface NavBarItem extends LinkProps { } const NavBar: FC = ({items}: NavBarProps): ReactElement => { + const {config} = useMeetupConfig(); const pathname = usePathname(); const shouldReduceMotion = useReducedMotion(); @@ -126,9 +128,11 @@ const NavBar: FC = ({items}: NavBarProps): ReactElement => { ))}
-
- -
+ {config.theme.showThemeSwitcher && ( +
+ +
+ )}
{/* Mobile menu button */}