Skip to content

Commit

Permalink
feat(graph): change to sticky header on scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongemi committed Apr 23, 2024
1 parent 35f3916 commit 412d6a3
Show file tree
Hide file tree
Showing 26 changed files with 654 additions and 185 deletions.
2 changes: 1 addition & 1 deletion graph/client/src/app/ui-components/error-boundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function ErrorBoundary() {
<ProjectDetailsHeader />
<h1 className="mb-4 text-4xl dark:text-slate-100">Error</h1>
<div>
<p className="text-lg mb-4 dark:text-slate-200">{message}</p>
<p className="mb-4 text-lg dark:text-slate-200">{message}</p>
<p className="text-sm">Error message: {error?.toString()}</p>
</div>
</div>
Expand Down
110 changes: 97 additions & 13 deletions graph/client/src/assets/project-graphs/e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -1189,27 +1189,111 @@
}
],
"targets": {
"lint": {
"cache": true,
"options": {
"cwd": "apps/cart-e2e",
"command": "eslint ."
},
"inputs": [
"default",
"^default",
"{workspaceRoot}/.eslintrc.json",
"{projectRoot}/.eslintrc.json",
"{workspaceRoot}/tools/eslint-rules/**/*",
{
"externalDependencies": ["eslint"]
}
],
"executor": "nx:run-commands",
"configurations": {}
},
"e2e": {
"executor": "@nrwl/cypress:cypress",
"cache": true,
"inputs": ["default", "^production"],
"outputs": [
"{workspaceRoot}/dist/cypress/apps/cart-e2e/videos",
"{workspaceRoot}/dist/cypress/apps/cart-e2e/screenshots"
],
"metadata": {
"technologies": ["cypress"],
"description": "Runs Cypress Tests"
},
"executor": "nx:run-commands",
"options": {
"cypressConfig": "apps/cart-e2e/cypress.config.ts",
"devServerTarget": "cart:serve",
"testingType": "e2e"
"cwd": "apps/cart-e2e",
"command": "cypress run"
},
"configurations": {
"production": {
"devServerTarget": "cart:serve:production"
"configurations": {}
},
"e2e-ci--src/e2e/app.cy.ts": {
"outputs": [
"{workspaceRoot}/dist/cypress/apps/cart-e2e/videos",
"{workspaceRoot}/dist/cypress/apps/cart-e2e/screenshots"
],
"inputs": [
"default",
"^production",
{
"externalDependencies": ["cypress"]
}
],
"cache": true,
"options": {
"cwd": "apps/cart-e2e",
"command": "cypress run --env webServerCommand=\"nx run cart:serve\" --spec src/e2e/app.cy.ts"
},
"inputs": ["default", "^production"]
"metadata": {
"technologies": ["cypress"],
"description": "Runs Cypress Tests in src/e2e/app.cy.ts in CI"
},
"executor": "nx:run-commands",
"configurations": {}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"e2e-ci": {
"executor": "nx:noop",
"cache": true,
"inputs": [
"default",
"^production",
{
"externalDependencies": ["cypress"]
}
],
"outputs": [
"{workspaceRoot}/dist/cypress/apps/cart-e2e/videos",
"{workspaceRoot}/dist/cypress/apps/cart-e2e/screenshots"
],
"dependsOn": [
{
"target": "e2e-ci--src/e2e/app.cy.ts",
"projects": "self",
"params": "forward"
}
],
"metadata": {
"technologies": ["cypress"],
"description": "Runs Cypress Tests in CI"
},
"options": {},
"configurations": {}
},
"open-cypress": {
"options": {
"lintFilePatterns": ["apps/cart-e2e/**/*.{ts,tsx,js,jsx}"]
"cwd": "apps/cart-e2e",
"command": "cypress open"
},
"outputs": ["{options.outputFile}"],
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"]
"metadata": {
"technologies": ["cypress"],
"description": "Opens Cypress"
},
"executor": "nx:run-commands",
"configurations": {}
}
},
"metadata": {
"targetGroups": {
"E2E (CI)": ["e2e-ci--src/e2e/app.cy.ts", "e2e-ci"]
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions graph/project-details/src/lib/project-details-wrapper.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import {
RootState,
expandTargetActions,
getExpandedTargets,
getSelectedTargetGroup,
selectTargetGroupActions,
getSelectedTarget,
selectTargetActions,
} from '@nx/graph/state';

const mapStateToProps = (state: RootState) => {
return {
expandTargets: getExpandedTargets(state),
selectedTargetGroup: getSelectedTargetGroup(state),
getSelectedTarget: getSelectedTarget(state),
};
};

Expand All @@ -19,14 +19,14 @@ const mapDispatchToProps = (dispatch: AppDispatch) => {
setExpandTargets(targets: string[]) {
dispatch(expandTargetActions.setExpandTargets(targets));
},
selectTargetGroup(targetGroup: string) {
dispatch(selectTargetGroupActions.selectTargetGroup(targetGroup));
selectTarget(targetGroup: string) {
dispatch(selectTargetActions.selectTarget(targetGroup));
},
collapseAllTargets() {
dispatch(expandTargetActions.collapseAllTargets());
},
clearTargetGroup() {
dispatch(selectTargetGroupActions.clearTargetGroup());
dispatch(selectTargetActions.clearSelectedTarget());
},
};
};
Expand Down
20 changes: 10 additions & 10 deletions graph/project-details/src/lib/project-details-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export function ProjectDetailsWrapperComponent({
sourceMap,
setExpandTargets,
expandTargets,
selectedTargetGroup,
selectTargetGroup,
getSelectedTarget,
selectTarget,
clearTargetGroup,
collapseAllTargets,
}: ProjectDetailsProps) {
Expand Down Expand Up @@ -116,17 +116,15 @@ export function ProjectDetailsWrapperComponent({
}
};

useEffect(() => {
/* useEffect(() => {
if (!project.data.targets) return;
const selectedTargetGroupParams = searchParams.get('targetGroup');
const selectedTargetNameParam = searchParams.get('targetName');
if (
selectedTargetGroupParams &&
selectedTargetGroup !== selectedTargetGroupParams
selectedTargetNameParam &&
selectedTarget !== selectedTargetNameParam
) {
selectTargetGroup(selectedTargetGroupParams);
} else if (!selectedTargetGroupParams) {
selectTargetGroup(defaultSelectTargetGroup(project)); // set first target group as default
selectTarget(selectedTargetNameParam);
}
const expandedTargetsParams =
Expand All @@ -138,7 +136,7 @@ export function ProjectDetailsWrapperComponent({
const targetName = searchParams.get('targetName');
if (targetName) {
const targetGroup = getTargetGroupForTarget(targetName, project);
selectTargetGroup(targetGroup);
selectTarget(targetGroup);
setExpandTargets([targetName]);
}
Expand All @@ -150,6 +148,7 @@ export function ProjectDetailsWrapperComponent({
setSearchParams(searchParams, { replace: true });
};
}, []); // only run on mount
useEffect(() => {
if (!project.data.targets) return;
Expand Down Expand Up @@ -184,6 +183,7 @@ export function ProjectDetailsWrapperComponent({
searchParams,
setSearchParams,
]);
*/

return (
<ProjectDetails
Expand Down
3 changes: 2 additions & 1 deletion graph/state/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './lib/expand-targets/expand-targets.slice';
export * from './lib/select-target-group/select-target-group.slice';
export * from './lib/select-target/select-target.slice';
export * from './lib/root/root-state.initial';
export * from './lib/root/root-state.interface';
export * from './lib/root/root.reducer';
export * from './lib/root/root.store';
export * from './lib/store.decorator';
11 changes: 5 additions & 6 deletions graph/state/src/lib/root/root-state.initial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import {
initialExpandTargets,
} from '../expand-targets/expand-targets.slice';
import {
SELECT_TARGET_GROUP_KEY,
initialSelectTargetGroup,
} from '../select-target-group/select-target-group.slice';

import { RootState } from './root.reducer';
SELECT_TARGET_KEY,
initialSelectTarget,
} from '../select-target/select-target.slice';
import { RootState } from './root-state.interface';

export const initialRootState: RootState = {
[EXPAND_TARGETS_KEY]: initialExpandTargets,
[SELECT_TARGET_GROUP_KEY]: initialSelectTargetGroup,
[SELECT_TARGET_KEY]: initialSelectTarget,
};
7 changes: 7 additions & 0 deletions graph/state/src/lib/root/root-state.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { EXPAND_TARGETS_KEY } from '../expand-targets/expand-targets.slice';
import { SELECT_TARGET_KEY } from '../select-target/select-target.slice';

export interface RootState {
[EXPAND_TARGETS_KEY]: string[];
[SELECT_TARGET_KEY]: string;
}
16 changes: 6 additions & 10 deletions graph/state/src/lib/root/root.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ import {
expandTargetReducer,
} from '../expand-targets/expand-targets.slice';
import {
SELECT_TARGET_GROUP_KEY,
selectTargetGroupReducer,
} from '../select-target-group/select-target-group.slice';
SELECT_TARGET_KEY,
selectTargetReducer,
} from '../select-target/select-target.slice';
import { RootState } from './root-state.interface';

export const rootReducer = combineReducers<{
[EXPAND_TARGETS_KEY]: string[];
[SELECT_TARGET_GROUP_KEY]: string;
}>({
export const rootReducer = combineReducers<RootState>({
[EXPAND_TARGETS_KEY]: expandTargetReducer,
[SELECT_TARGET_GROUP_KEY]: selectTargetGroupReducer as any,
[SELECT_TARGET_KEY]: selectTargetReducer as any,
});

export type RootState = ReturnType<typeof rootReducer>;

This file was deleted.

29 changes: 29 additions & 0 deletions graph/state/src/lib/select-target/select-target.slice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { PayloadAction, createSlice } from '@reduxjs/toolkit';

export const SELECT_TARGET_KEY = 'selectTarget';

export const initialSelectTarget: string = '';

export const selectTargetSlice = createSlice({
name: SELECT_TARGET_KEY,
initialState: initialSelectTarget,
reducers: {
selectTarget: (_: string, action: PayloadAction<string>): string => {
return action.payload;
},
clearSelectedTarget: (): string => {
return '';
},
},
});

/*
* Export reducer for store configuration.
*/
export const selectTargetReducer = selectTargetSlice.reducer;

export const selectTargetActions = selectTargetSlice.actions;

export const getSelectedTarget = <ROOT extends { [SELECT_TARGET_KEY]: string }>(
rootState: ROOT
): string => rootState[SELECT_TARGET_KEY];
2 changes: 1 addition & 1 deletion graph/ui-icons/src/lib/framework-icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ export const frameworkIcons: Record<
viewBox="0 0 256 263"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
className="w-full h-full"
className="h-full w-full"
>
<g>
<path
Expand Down
2 changes: 1 addition & 1 deletion graph/ui-icons/src/lib/technology-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function TechnologyIcon({
}
return (
<div
className={`w-4 h-4 ${
className={`h-4 w-4 ${
frameworkIcons[technology as Framework].isAdaptiveIcon
? 'adpative-icon'
: ''
Expand Down
Loading

0 comments on commit 412d6a3

Please sign in to comment.