Skip to content

Commit 4612a23

Browse files
committed
ui: theme: fix classNames for all component related to RepoList and settings
1 parent 7dd14d7 commit 4612a23

7 files changed

+21
-16
lines changed

components/LoginLogout.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export default function LoginLogout() {
1212
const [session, setSession] = useState<Session | null>(null);
1313
const { rudderEventMethods } = useContext(RudderContext);
1414

15-
1615
// FIXME: Ideally, this should have been automatically accomplished using useSession provided by NextAuth. But that is not working.
1716
useEffect(() => {
1817
fetch("/api/auth/session", { cache: "no-store" }).then(async (res) => {
@@ -46,22 +45,23 @@ export default function LoginLogout() {
4645
};
4746
}, [rudderEventMethods, session]);
4847

48+
const menuItemClassName = 'border-b-2 border-b-border last-of-type:border-0 p-2 text-center';
4949
if (session?.user) return (
5050
<>
5151
<Image src={getAuthUserImage(session)} onClick={() => setShowMenu(prev => !prev)} alt="Display picture" title={getAuthUserName(session)} width={300} height={300} className="h-full w-auto hover:cursor-pointer rounded-xl cursor-pointer max-h-8 mx-auto" />
5252
{/* Log out Pop up */}
5353
{showMenu ?
54-
<ol className='w-[40%] sm:w-[15%] rounded-md absolute right-5 sm:right-10 top-16 border-2 bg-primary-light text-primary-darktext'>
55-
<li className='border-b-2 border-b-gray-200 p-2 text-center'>
54+
<ol className='w-[40%] sm:w-[15%] rounded-md absolute right-5 sm:right-10 top-16 border-2 border-border bg-background text-primary-foreground'>
55+
<li className={menuItemClassName}>
5656
<Link href='/u' className='cursor-pointer w-full'>Profile</Link>
5757
</li>
58-
<li id='contribute-link' className='border-b-2 border-b-gray-200 p-2 text-center'>
58+
<li id='contribute-link' className={menuItemClassName}>
5959
<Link href='https://github.com/Alokit-Innovations/' target='_blank' className='cursor-pointer w-full'>Contribute</Link>
6060
</li>
61-
<li id='settings-link' className='border-b-2 border-b-gray-200 p-2 text-center'>
61+
<li id='settings-link' className={menuItemClassName}>
6262
<Link href='/settings' className='cursor-pointer w-full'>Settings</Link>
6363
</li>
64-
<li id='logout-link' className='p-2 text-center cursor-pointer' onClick={() => (logout(getAuthUserId(session), getAuthUserName(session), getAndSetAnonymousIdFromLocalStorage(), (rudderEventMethods ?? null)))}>
64+
<li id='logout-link' className={`cursor-pointer ${menuItemClassName}`} onClick={() => (logout(getAuthUserId(session), getAuthUserName(session), getAndSetAnonymousIdFromLocalStorage(), (rudderEventMethods ?? null)))}>
6565
Logout
6666
</li>
6767
</ol>
@@ -71,7 +71,7 @@ export default function LoginLogout() {
7171
</>
7272
)
7373
else return (
74-
<Button variant='contained' onClick={() => (login(getAndSetAnonymousIdFromLocalStorage(), (rudderEventMethods ?? null)))} className="rounded bg-inherit sm:bg-primary-main text-secondary-main py-2 px-4 font-semibold">
74+
<Button variant='contained' onClick={() => (login(getAndSetAnonymousIdFromLocalStorage(), (rudderEventMethods ?? null)))} className="rounded bg-inherit sm:bg-secondary text-secondary-foreground py-2 px-4 font-semibold">
7575
Login/Signup
7676
</Button>
7777
)

components/ProviderLogo.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import Image from "next/image";
22
import type { RepoProvider } from "../utils/providerAPI";
33
import React from "react";
4+
import { Theme } from "../utils/theme";
45

5-
export const getProviderLogoSrc = (provider: RepoProvider, theme: "light" | "dark") => `/${provider}${theme === 'dark' ? "-dark" : ""}.svg`;
6+
export const getProviderLogoSrc = (provider: RepoProvider, theme: Theme) => `/${provider}${theme !== 'dark' ? "-dark" : ""}.svg`;
67

7-
const ProviderLogo: React.FC<{ provider: RepoProvider, theme: "light" | "dark", className?: string }> = ({ provider, theme, className }) => {
8+
const ProviderLogo: React.FC<{ provider: RepoProvider, theme: Theme, className?: string }> = ({ provider, theme, className }) => {
89
return (
910
<Image
1011
loading="lazy"

components/SelectBase.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const SelectTrigger = React.forwardRef<
1414
>(({ className, children, ...props }, ref) => (
1515
<SelectPrimitive.Trigger
1616
ref={ref}
17-
className={"flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 " + className}
17+
className={"flex h-10 w-full items-center justify-between rounded-md border border-input bg-primary px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 " + className}
1818
{...props}
1919
>
2020
{children}

components/SwitchSubmit.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const SwitchSubmit = (props: PropsWithChildren<{
1515
checked={props.checked}
1616
onCheckedChange={props.toggleFunction}
1717
>
18-
<Switch.Thumb className="block w-[21px] h-[21px] bg-secondary-main rounded-full transition-transform duration-100 translate-x-0.5 will-change-transform data-[state=checked]:translate-x-[19px]" />
18+
<Switch.Thumb className="block w-[21px] h-[21px] bg-primary rounded-full transition-transform duration-100 translate-x-0.5 will-change-transform data-[state=checked]:translate-x-[19px]" />
1919
</Switch.Root>
2020
)
2121
}

components/Table.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { PropsWithChildren } from "react";
22

33
const TableHeaderCell = ({ className, children }: PropsWithChildren<{ className?: string }>) => (
4-
<th className={"px-6 py-3 bg-gray-100 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider " + className}>
4+
<th className={"px-6 py-3 bg-primary text-left text-xs font-semibold text-gray-500 uppercase tracking-wider " + className}>
55
{children}
66
</th>
77
);

views/MainAppBar.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default function MainAppBar() {
1313
}, [])
1414

1515
return (
16-
<AppBar position='fixed' className='mx-auto py-2 px-10 justify-between items-center max-w-7xl' backdropClassName='bg-primary-light'>
16+
<AppBar position='fixed' className='mx-auto py-2 px-10 justify-between items-center max-w-7xl' backdropClassName='bg-background'>
1717
<Link href="/" className="mr-16 h-full overflow-clip flex flex-row items-center">
1818
<Image src={VibinexDarkLogo} alt="Vibinex logo" className="inline w-10 mr-2" priority></Image>
1919
<h1 className='font-bold text-3xl sm:text-4xl font-sans tracking-wider'>

views/RepoList.tsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import ProviderLogo from "../components/ProviderLogo";
55
import SwitchSubmit from "../components/SwitchSubmit";
66
import { TableCell, TableHeaderCell } from "../components/Table";
77
import type { DbRepoSerializable, RepoIdentifier } from "../types/repository";
8+
import { getPreferredTheme, Theme } from "../utils/theme";
89

910
const RepoList = () => {
1011
const [loading, setLoading] = useState(false);
1112
const [configLoading, setConfigLoading] = useState(false); // while loading user can't send another api request to change setting
1213
const [repoList, setRepoList] = useState<DbRepoSerializable[]>([]);
14+
const [theme, setTheme] = useState<Theme>('light')
1315

1416
useEffect(() => {
1517
setLoading(true);
@@ -24,6 +26,8 @@ const RepoList = () => {
2426
.finally(() => {
2527
setLoading(false);
2628
});
29+
30+
setTheme(getPreferredTheme());
2731
}, [])
2832

2933
const setConfig = (repo: RepoIdentifier, configType: 'auto_assign' | 'comment', value: boolean) => {
@@ -57,7 +61,7 @@ const RepoList = () => {
5761
}
5862
return (<>
5963
<h2 className="text-xl font-semibold my-2">Added Repositories</h2>
60-
<table className="min-w-full divide-y divide-gray-200">
64+
<table className="min-w-full divide-y divide-border">
6165
<thead>
6266
<tr>
6367
<TableHeaderCell>Repo Name</TableHeaderCell>
@@ -68,7 +72,7 @@ const RepoList = () => {
6872
<TableHeaderCell>Stats</TableHeaderCell>
6973
</tr>
7074
</thead>
71-
<tbody className="bg-white divide-y divide-gray-200">
75+
<tbody className="bg-backgroudn divide-y divide-border">
7276
{repoList.map(({ repo_provider: repoProvider, repo_owner: repoOwner, repo_name: repoName, config }) => {
7377
const repoAddr = `${repoProvider}/${repoOwner}/${repoName}`;
7478
const repo_id: RepoIdentifier = {
@@ -80,7 +84,7 @@ const RepoList = () => {
8084
<tr key={repoAddr}>
8185
<TableCell>{repoName}</TableCell>
8286
<TableCell>{repoOwner}</TableCell>
83-
<TableCell className="text-center"><ProviderLogo provider={repoProvider} theme="dark" className="mx-auto" /></TableCell>
87+
<TableCell className="text-center"><ProviderLogo provider={repoProvider} theme={theme} className="mx-auto" /></TableCell>
8488
<TableCell className="text-center"><SwitchSubmit checked={config.auto_assign} toggleFunction={() => setConfig(repo_id, 'auto_assign', !config.auto_assign)} disabled={configLoading} /></TableCell>
8589
<TableCell className="text-center"><SwitchSubmit checked={config.comment} toggleFunction={() => setConfig(repo_id, 'comment', !config.comment)} disabled={configLoading} /></TableCell>
8690
<TableCell className="text-primary-main"><Link href={`/repo?repo_name=${repoAddr}`}>Link</Link></TableCell>

0 commit comments

Comments
 (0)