diff --git a/apps/codeimage/src/pages/Dashboard/components/ProjectItem/ProjectItem.css.ts b/apps/codeimage/src/pages/Dashboard/components/ProjectItem/ProjectItem.css.ts
index 79fb6db07..9985210c5 100644
--- a/apps/codeimage/src/pages/Dashboard/components/ProjectItem/ProjectItem.css.ts
+++ b/apps/codeimage/src/pages/Dashboard/components/ProjectItem/ProjectItem.css.ts
@@ -17,10 +17,19 @@ export const item = style([
display: 'inline-flex',
flexDirection: 'column',
selectors: {
+ ...withThemeMode({
+ dark: {backgroundColor: themeVars.dynamicColors.input.backgroundColor},
+ light: {
+ backgroundColor: themeVars.backgroundColor.white,
+ border: `1px solid ${themeVars.borderColor.default}`,
+ boxShadow: themeVars.boxShadow.default,
+ },
+ }),
+
...withThemeMode(
{
dark: {backgroundColor: darkGrayScale.gray2},
- light: {backgroundColor: darkGrayScale.gray10},
+ light: {backgroundColor: darkGrayScale.gray12},
},
'&:hover',
),
diff --git a/apps/codeimage/src/pages/Dashboard/components/ProjectList/ProjectList.css.ts b/apps/codeimage/src/pages/Dashboard/components/ProjectList/ProjectList.css.ts
index 706022a8c..ec7c2df31 100644
--- a/apps/codeimage/src/pages/Dashboard/components/ProjectList/ProjectList.css.ts
+++ b/apps/codeimage/src/pages/Dashboard/components/ProjectList/ProjectList.css.ts
@@ -41,11 +41,11 @@ export const fallbackContainer = style({
selectors: {
...withThemeMode({
light: {
- backgroundColor: darkGrayScale.gray3,
+ backgroundColor: themeVars.backgroundColor.gray['200'],
color: themeVars.dynamicColors.descriptionTextColor,
},
dark: {
- backgroundColor: themeVars.backgroundColor.gray['200'],
+ backgroundColor: darkGrayScale.gray3,
color: themeVars.dynamicColors.descriptionTextColor,
},
}),
diff --git a/apps/codeimage/src/pages/Dashboard/components/ProjectList/ProjectList.tsx b/apps/codeimage/src/pages/Dashboard/components/ProjectList/ProjectList.tsx
index b2f382f70..a6e72fc56 100644
--- a/apps/codeimage/src/pages/Dashboard/components/ProjectList/ProjectList.tsx
+++ b/apps/codeimage/src/pages/Dashboard/components/ProjectList/ProjectList.tsx
@@ -1,4 +1,4 @@
-import {getLastPage, Pagination} from '@codeimage/ui';
+import {Box, getLastPage, Pagination} from '@codeimage/ui';
import {ErrorBoundary, For, Index, Show, Suspense, untrack} from 'solid-js';
import {getDashboardState} from '../../dashboard.state';
import {ProjectItem} from '../ProjectItem/ProjectItem';
@@ -9,6 +9,7 @@ import * as styles from './ProjectList.css';
export function ProjectList() {
const dashboard = getDashboardState()!;
+ const {paginationState} = dashboard;
const listIsEmpty = () => {
return !dashboard.data.error && dashboard.filteredData()?.length === 0;
@@ -24,8 +25,10 @@ export function ProjectList() {
const list = Array.from({length: count || 5});
return {() => };
};
+
const lastPage = () =>
- getLastPage(dashboard.filteredData, () => dashboard.pageSize);
+ getLastPage(dashboard.filteredData, () => paginationState.pageSize);
+
return (
(
@@ -48,12 +51,14 @@ export function ProjectList() {
{item => }
-
-
+
+
+
+
diff --git a/apps/codeimage/src/pages/Dashboard/dashboard.state.ts b/apps/codeimage/src/pages/Dashboard/dashboard.state.ts
index 26dc04fae..8f43139e3 100644
--- a/apps/codeimage/src/pages/Dashboard/dashboard.state.ts
+++ b/apps/codeimage/src/pages/Dashboard/dashboard.state.ts
@@ -7,8 +7,9 @@ import {getThemeStore} from '@codeimage/store/theme/theme.store';
import {createPagedData} from '@codeimage/ui';
import {appEnvironment} from '@core/configuration';
import {createContextProvider} from '@solid-primitives/context';
-import {createResource, createSignal, createEffect} from 'solid-js';
+import {createEffect, createResource, createSignal} from 'solid-js';
import {API} from '../../data-access/api';
+
function makeDashboardState(authState = getAuth0State()) {
const [data, {mutate, refetch}] = createResource(fetchWorkspaceContent, {
initialValue: [],
@@ -27,15 +28,17 @@ function makeDashboardState(authState = getAuth0State()) {
);
return data();
};
- const [pagedData, {page, setPage}] = createPagedData(() => filteredData(), {
+
+ const [pagedData, paginationState] = createPagedData(filteredData, {
pageSize,
pageSelected: 1,
});
createEffect(() => {
const searchValue = search();
- if (searchValue.length > 2) setPage(1);
+ if (searchValue.length > 2) paginationState.setPage(1);
});
+
async function fetchWorkspaceContent(): Promise<
ApiTypes.GetProjectByIdApi['response'][]
> {
@@ -43,6 +46,7 @@ function makeDashboardState(authState = getAuth0State()) {
if (!userId) return [];
return API.project.getWorkspaceContent();
}
+
async function createNewProject() {
const theme = await getThemeStore().getThemeDef('vsCodeDarkTheme')?.load();
@@ -144,9 +148,14 @@ function makeDashboardState(authState = getAuth0State()) {
updateSnippetName,
cloneProject,
pagedData,
- page,
- setPage,
- pageSize,
+ paginationState: Object.assign(paginationState, {
+ get pageSize() {
+ return pageSize;
+ },
+ get hasOnePage() {
+ return pagedData().length <= pageSize;
+ },
+ }),
};
}
diff --git a/packages/ui/src/lib/primitives/Pagination/PageItem.css.ts b/packages/ui/src/lib/primitives/Pagination/PageItem.css.ts
new file mode 100644
index 000000000..f21cca2ca
--- /dev/null
+++ b/packages/ui/src/lib/primitives/Pagination/PageItem.css.ts
@@ -0,0 +1,5 @@
+import {style} from '@vanilla-extract/css';
+
+export const pageItemButton = style({
+ transition: 'none',
+});
diff --git a/packages/ui/src/lib/primitives/Pagination/page.tsx b/packages/ui/src/lib/primitives/Pagination/PageItem.tsx
similarity index 55%
rename from packages/ui/src/lib/primitives/Pagination/page.tsx
rename to packages/ui/src/lib/primitives/Pagination/PageItem.tsx
index f6e928018..5d73cf106 100644
--- a/packages/ui/src/lib/primitives/Pagination/page.tsx
+++ b/packages/ui/src/lib/primitives/Pagination/PageItem.tsx
@@ -1,13 +1,15 @@
import {ParentProps} from 'solid-js';
import {IconButton} from '../IconButton';
-import {buttonPaginationProps} from './buttons';
+import {ButtonPaginationProps} from './createPaginationButtons';
+import * as styles from './PageItem.css';
-const Page = (props: ParentProps) => {
+const PageItem = (props: ParentProps) => {
return (
props.onClick?.(props.value)}
>
{props.value}
@@ -15,4 +17,4 @@ const Page = (props: ParentProps) => {
);
};
-export default Page;
+export default PageItem;
diff --git a/packages/ui/src/lib/primitives/Pagination/Pagination.css.ts b/packages/ui/src/lib/primitives/Pagination/Pagination.css.ts
new file mode 100644
index 000000000..ae3cb040c
--- /dev/null
+++ b/packages/ui/src/lib/primitives/Pagination/Pagination.css.ts
@@ -0,0 +1,7 @@
+import {style} from '@vanilla-extract/css';
+import {themeVars} from '../../theme';
+
+export const pagination = style({
+ display: 'flex',
+ gap: themeVars.spacing[2],
+});
diff --git a/packages/ui/src/lib/primitives/Pagination/Pagination.tsx b/packages/ui/src/lib/primitives/Pagination/Pagination.tsx
index 3356220f8..29e2180fb 100644
--- a/packages/ui/src/lib/primitives/Pagination/Pagination.tsx
+++ b/packages/ui/src/lib/primitives/Pagination/Pagination.tsx
@@ -1,8 +1,9 @@
import {For, mergeProps, ParentProps, Setter} from 'solid-js';
-import {Box} from '../Box';
+import {SvgIcon, SvgIconProps} from '../Icon';
import {IconButton} from '../IconButton';
-import {createPaginationButtons} from './buttons';
-import Page from './page';
+import {createPaginationButtons} from './createPaginationButtons';
+import PageItem from './PageItem';
+import * as styles from './Pagination.css';
export interface PaginationProps {
pageNumber?: number;
@@ -10,11 +11,48 @@ export interface PaginationProps {
lastPage?: number;
}
+function NextIcon(props: SvgIconProps) {
+ return (
+
+
+
+ );
+}
+
+function PrevIcon(props: SvgIconProps) {
+ return (
+
+
+
+ );
+}
+
export const Pagination = (props: ParentProps) => {
const merged = mergeProps(
{pageNumber: 1, lastPage: 1} as Required,
props,
);
+
const itemButtons = createPaginationButtons(
() => merged.lastPage,
() => merged.pageNumber,
@@ -22,33 +60,23 @@ export const Pagination = (props: ParentProps) => {
false,
);
- const handlerNextChange = () => {
- merged.onChange(prev => prev + 1);
- };
+ const isPrevDisabled = () => merged.pageNumber === 1;
+ const isNextDisabled = () => merged.pageNumber === merged.lastPage;
- const handlerPrevChange = () => {
- merged.onChange(prev => prev - 1);
- };
+ const handlerNextChange = () => merged.onChange(prev => prev + 1);
+ const handlerPrevChange = () => merged.onChange(prev => prev - 1);
return (
-
-
-
- {'<'}
-
- {page => }
-
- {'>'}
-
-
-
+
);
};
diff --git a/packages/ui/src/lib/primitives/Pagination/buttons.ts b/packages/ui/src/lib/primitives/Pagination/createPaginationButtons.ts
similarity index 90%
rename from packages/ui/src/lib/primitives/Pagination/buttons.ts
rename to packages/ui/src/lib/primitives/Pagination/createPaginationButtons.ts
index 51f7af10b..39b436e93 100644
--- a/packages/ui/src/lib/primitives/Pagination/buttons.ts
+++ b/packages/ui/src/lib/primitives/Pagination/createPaginationButtons.ts
@@ -1,3 +1,10 @@
+/**
+ * Portions of this file are based on code from @material-ui/react.
+ * MIT Licensed, Copyright (c) 2014 Call-Em-All.
+ *
+ * Credits to the Material UI team:
+ * https://github.com/mui/material-ui/blob/master/packages/mui-material/src/usePagination/usePagination.js
+ */
import {Accessor, mapArray, Setter} from 'solid-js';
import {arrayFomRange} from '../../hooks';
@@ -101,7 +108,7 @@ export const createPaginationButtons = (
return items;
};
-export type buttonPaginationProps = {
+export type ButtonPaginationProps = {
onClick?: Setter;
value: number | string;
selected: boolean;