Skip to content

Commit 7ecdfb4

Browse files
feat: workspace template with DS 1.0
0 parents  commit 7ecdfb4

File tree

101 files changed

+12398
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+12398
-0
lines changed

.envrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source_url "https://raw.githubusercontent.com/cachix/devenv/d1f7b48e35e6dee421cfd0f51481d17f77586997/direnvrc" "sha256-YBzqskFZxmNb3kYVoKD9ZixoPXJh1C9ZvTLGFRkauZ0="
2+
3+
use devenv

.github/workflows/deploy.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Node
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 20
28+
cache: "npm"
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Build
34+
run: npm run build
35+
36+
- name: Setup Pages
37+
uses: actions/configure-pages@v5
38+
39+
- name: Upload artifact
40+
uses: actions/upload-pages-artifact@v3
41+
with:
42+
path: ./dist
43+
44+
deploy:
45+
environment:
46+
name: github-pages
47+
url: ${{ github.event.deployment.payload.web_url || steps.deployment.outputs.page_url }}
48+
runs-on: ubuntu-latest
49+
needs: build
50+
steps:
51+
- name: Deploy to GitHub Pages
52+
id: deployment
53+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?
25+
26+
# Devenv
27+
.devenv*
28+
devenv.local.nix
29+
30+
# direnv
31+
.direnv
32+
33+
# pre-commit
34+
.pre-commit-config.yaml
35+
36+
coverage
37+
38+
39+
# Local Netlify folder
40+
.netlify
41+
42+
# Local documentation (not tracked in repo)
43+
docs/
44+
PAGE-IMPLEMENTATION-GUIDE.md
45+
PENDING-COMMITS.md
46+
WORKSPACE-SETUP.md

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"printWidth": 90,
3+
"singleQuote": false,
4+
"endOfLine": "lf",
5+
"trailingComma": "all"
6+
}

README.md

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# Workspace Template (DS 2.0)
2+
3+
A template for building Alberta government **workspace applications** using the GoA Design System 2.0. This template provides a starting point for internal staff-facing applications with common patterns and components already implemented.
4+
5+
## Tech Stack
6+
7+
- **React** 18.2 with TypeScript 5.3
8+
- **Vite** 5.1 for fast development and builds
9+
- **React Router** 6.22 for routing
10+
- **GoA Design System 2.0** (`@abgov/react-components`, `@abgov/web-components`)
11+
- **Vitest** for testing
12+
13+
## Features
14+
15+
- **Work Side Menu** - Responsive sidebar navigation with primary, secondary, and account sections
16+
- **Dynamic page headers** - Sticky headers with title and action buttons
17+
- **Data tables** - Sorting, filtering, keyboard navigation, and horizontal scroll shadows
18+
- **Notification system** - Popover notifications with localStorage persistence
19+
- **Loading states** - Progress indicators for async operations
20+
- **Error boundary** - Graceful error handling with fallback UI
21+
- **Mock API utilities** - Simulate network requests for development
22+
23+
## Project Structure
24+
25+
```
26+
src/
27+
├── components/ # Reusable UI components
28+
│ ├── ErrorBoundary.tsx
29+
│ ├── PageHeader.tsx
30+
│ └── ScrollContainer.tsx
31+
├── constants/ # Shared constants
32+
│ └── breakpoints.ts
33+
├── contexts/ # React Context providers
34+
│ ├── MenuContext.tsx
35+
│ ├── NotificationContext.tsx
36+
│ └── PageHeaderContext.tsx
37+
├── data/ # Mock data
38+
│ ├── mockClients.json
39+
│ ├── mockNotifications.ts
40+
│ └── mockSearchResults.json
41+
├── routes/ # Page components
42+
│ ├── ClientsPage.tsx
43+
│ ├── SearchPage.tsx
44+
│ └── ...
45+
├── types/ # TypeScript interfaces
46+
│ ├── Client.ts
47+
│ ├── Notification.ts
48+
│ └── SearchResult.ts
49+
├── utils/ # Helper functions
50+
│ ├── badgeUtils.ts
51+
│ ├── dateUtils.ts
52+
│ ├── mockApi.ts
53+
│ └── searchUtils.ts
54+
├── App.tsx # Root layout
55+
├── App.css # Global styles
56+
└── index.tsx # Entry point
57+
```
58+
59+
## Getting Started
60+
61+
### Prerequisites
62+
63+
- Node.js 18+
64+
- npm 9+
65+
66+
### Installation
67+
68+
1. Click the green **Use this template** button
69+
2. Select **Create a new repository**
70+
3. Select an owner and give the repo a suitable name
71+
4. Clone the repo onto your machine
72+
5. Install dependencies:
73+
74+
```bash
75+
npm install
76+
```
77+
78+
### Development
79+
80+
Start the development server:
81+
82+
```bash
83+
npm run dev
84+
```
85+
86+
Open [http://localhost:5173](http://localhost:5173) in your browser.
87+
88+
### Available Scripts
89+
90+
| Script | Description |
91+
|--------|-------------|
92+
| `npm run dev` | Start development server |
93+
| `npm run build` | Build for production |
94+
| `npm run build:check` | Type-check and build |
95+
| `npm run preview` | Preview production build |
96+
| `npm run test` | Run tests |
97+
| `npm run coverage` | Run tests with coverage |
98+
99+
## Key Patterns
100+
101+
### Loading States
102+
103+
Use the `mockFetch` utility to simulate API calls with loading states:
104+
105+
```tsx
106+
import { mockFetch } from "../utils/mockApi";
107+
108+
const [data, setData] = useState([]);
109+
const [isLoading, setIsLoading] = useState(true);
110+
111+
useEffect(() => {
112+
const fetchData = async () => {
113+
setIsLoading(true);
114+
const result = await mockFetch(mockData);
115+
setData(result);
116+
setIsLoading(false);
117+
};
118+
fetchData();
119+
}, []);
120+
121+
// In JSX:
122+
<GoabCircularProgress visible={isLoading} variant="fullscreen" message="Loading..." />
123+
```
124+
125+
### Page Headers
126+
127+
Use the `usePageHeader` hook to set dynamic page titles and actions:
128+
129+
```tsx
130+
import { usePageHeader } from "../contexts/PageHeaderContext";
131+
132+
usePageHeader("Page Title", <GoabButton>Action</GoabButton>);
133+
```
134+
135+
### Error Handling
136+
137+
The app is wrapped in an `ErrorBoundary` component that catches errors and displays a fallback UI.
138+
139+
## Customization
140+
141+
### Styling
142+
143+
- Global styles are in `src/App.css`
144+
- GoA Design System tokens are imported via `@abgov/web-components/index.css`
145+
- Mobile breakpoint is set at 624px (defined in `src/constants/breakpoints.ts`)
146+
147+
### Adding New Pages
148+
149+
1. Create a new component in `src/routes/`
150+
2. Add the route in `src/index.tsx`
151+
3. Add a menu item in `src/App.tsx`
152+
153+
## Resources
154+
155+
- [GoA Design System 2.0](https://design.alberta.ca)
156+
- [UI Components Documentation](https://design.alberta.ca)
157+
158+
## License
159+
160+
This template is provided by the Government of Alberta for use by Alberta government teams building internal workspace applications.

0 commit comments

Comments
 (0)