Skip to content

Commit 18ad100

Browse files
authored
Add contract templates and onboarding functionality (#330)
1 parent 2bb6dae commit 18ad100

200 files changed

Lines changed: 34795 additions & 5744 deletions

File tree

Some content is hidden

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

.github/workflows/chromatic.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Chromatic
2+
3+
on:
4+
pull_request:
5+
branches: ['**']
6+
push:
7+
branches: ['main']
8+
9+
jobs:
10+
chromatic:
11+
name: Visual Regression Tests
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 15
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0 # Required for Chromatic to detect changes
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '24'
25+
26+
- name: Setup pnpm
27+
uses: pnpm/action-setup@v4
28+
with:
29+
version: 10.24.0
30+
31+
- name: Get pnpm store directory
32+
shell: bash
33+
run: |
34+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
35+
36+
- name: Setup pnpm cache
37+
uses: actions/cache@v4
38+
with:
39+
path: ${{ env.STORE_PATH }}
40+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
41+
restore-keys: |
42+
${{ runner.os }}-pnpm-store-
43+
44+
- name: Install dependencies
45+
run: pnpm install --frozen-lockfile
46+
47+
- name: Initialize MSW
48+
run: pnpm msw init public --save=false
49+
50+
- name: Publish to Chromatic
51+
uses: chromaui/action@latest
52+
with:
53+
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
54+
buildScriptName: build-storybook
55+
onlyChanged: true
56+
autoAcceptChanges: main
57+
exitOnceUploaded: true
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Deploy Storybook
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+
name: Build Storybook
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 15
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: '24'
31+
32+
- name: Setup pnpm
33+
uses: pnpm/action-setup@v4
34+
with:
35+
version: 10.24.0
36+
37+
- name: Get pnpm store directory
38+
shell: bash
39+
run: |
40+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
41+
42+
- name: Setup pnpm cache
43+
uses: actions/cache@v4
44+
with:
45+
path: ${{ env.STORE_PATH }}
46+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
47+
restore-keys: |
48+
${{ runner.os }}-pnpm-store-
49+
50+
- name: Install dependencies
51+
run: pnpm install --frozen-lockfile
52+
53+
- name: Initialize MSW
54+
run: pnpm msw init public --save=false
55+
56+
- name: Build Storybook
57+
run: pnpm build-storybook
58+
59+
- name: Add CNAME file
60+
run: echo "design.cloudnativedays.no" > storybook-static/CNAME
61+
62+
- name: Setup Pages
63+
uses: actions/configure-pages@v5
64+
65+
- name: Upload artifact
66+
uses: actions/upload-pages-artifact@v3
67+
with:
68+
path: storybook-static
69+
70+
deploy:
71+
name: Deploy to GitHub Pages
72+
environment:
73+
name: github-pages
74+
url: ${{ steps.deployment.outputs.page_url }}
75+
runs-on: ubuntu-latest
76+
needs: build
77+
78+
steps:
79+
- name: Deploy to GitHub Pages
80+
id: deployment
81+
uses: actions/deploy-pages@v4

.github/workflows/pr-checks.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,50 @@ jobs:
9292
- name: Run tests
9393
run: pnpm run test
9494

95+
storybook:
96+
name: Storybook Tests
97+
runs-on: ubuntu-latest
98+
timeout-minutes: 15
99+
100+
steps:
101+
- name: Checkout code
102+
uses: actions/checkout@v4
103+
104+
- name: Setup Node.js
105+
uses: actions/setup-node@v4
106+
with:
107+
node-version: '24'
108+
109+
- name: Setup pnpm
110+
uses: pnpm/action-setup@v4
111+
with:
112+
version: 10.24.0
113+
114+
- name: Get pnpm store directory
115+
shell: bash
116+
run: |
117+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
118+
119+
- name: Setup pnpm cache
120+
uses: actions/cache@v4
121+
with:
122+
path: ${{ env.STORE_PATH }}
123+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
124+
restore-keys: |
125+
${{ runner.os }}-pnpm-store-
126+
127+
- name: Install dependencies
128+
run: pnpm install --frozen-lockfile
129+
130+
- name: Install Playwright browsers
131+
run: pnpm exec playwright install --with-deps chromium
132+
133+
- name: Initialize MSW
134+
run: pnpm msw init public --save=false
135+
136+
- name: Run Storybook tests
137+
run: pnpm run storybook:test-ci
138+
95139
build:
96140
name: Build
97141
runs-on: ubuntu-latest

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,9 @@ dist/
3838

3939
# backups
4040
*.tar.gz
41+
storybook-static/*
42+
43+
# msw
44+
public/mockServiceWorker.js
45+
# storybook local env
46+
.storybook/.env

.storybook/.env.example

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Storybook Environment Variables (Example Template)
2+
# ---------------------------------------------------------------------------
3+
# This file is an example/template only. Do NOT put real secrets or production
4+
# configuration in this committed file.
5+
#
6+
# Recommended usage:
7+
# 1. Copy this file to `.storybook/.env` (which should be gitignored).
8+
# 2. Replace the example values in that copy with your real local values.
9+
#
10+
# The variables below are commented out so this example file does not define
11+
# any active environment variables when loaded.
12+
# ---------------------------------------------------------------------------
13+
14+
# Sanity CMS
15+
# NEXT_PUBLIC_SANITY_PROJECT_ID=your_project_id
16+
# NEXT_PUBLIC_SANITY_DATASET=production
17+
# NEXT_PUBLIC_SANITY_API_VERSION=2024-01-01
18+
19+
# Base URL for stories
20+
# NEXT_PUBLIC_BASE_URL=http://localhost:6006
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from 'react'
2+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
3+
import { httpBatchLink } from '@trpc/client'
4+
import { api } from '@/lib/trpc/client'
5+
import type { Decorator } from '@storybook/nextjs-vite'
6+
7+
// Create these outside the decorator to avoid recreating on every render
8+
const queryClient = new QueryClient({
9+
defaultOptions: {
10+
queries: {
11+
retry: false,
12+
refetchOnWindowFocus: false,
13+
staleTime: Infinity,
14+
},
15+
},
16+
})
17+
18+
const trpcClient = api.createClient({
19+
links: [
20+
httpBatchLink({
21+
url: '/api/trpc',
22+
// MSW will intercept these requests (relative URL for cross-origin compatibility)
23+
}),
24+
],
25+
})
26+
27+
export const TRPCDecorator: Decorator = (Story) => {
28+
return (
29+
<api.Provider client={trpcClient} queryClient={queryClient}>
30+
<QueryClientProvider client={queryClient}>
31+
<Story />
32+
</QueryClientProvider>
33+
</api.Provider>
34+
)
35+
}

.storybook/main.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import type { StorybookConfig } from '@storybook/nextjs-vite'
2+
import { dirname, join } from 'node:path'
3+
import { fileURLToPath } from 'node:url'
4+
5+
const __filename = fileURLToPath(import.meta.url)
6+
const __dirname = dirname(__filename)
7+
8+
const config: StorybookConfig = {
9+
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
10+
addons: ['@storybook/addon-docs'],
11+
framework: {
12+
name: '@storybook/nextjs-vite',
13+
options: {
14+
nextConfigPath: join(__dirname, '../next.config.ts'),
15+
},
16+
},
17+
staticDirs: ['../public'],
18+
typescript: {
19+
check: false,
20+
reactDocgen: 'react-docgen-typescript',
21+
reactDocgenTypescriptOptions: {
22+
shouldExtractLiteralValuesFromEnum: true,
23+
propFilter: (prop) =>
24+
prop.parent ? !/node_modules/.test(prop.parent.fileName) : true,
25+
},
26+
},
27+
core: {
28+
disableTelemetry: true,
29+
},
30+
docs: {},
31+
features: {
32+
sidebarOnboardingChecklist: false,
33+
},
34+
}
35+
36+
export default config

.storybook/preview-head.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!-- Load Google Fonts for Storybook -->
2+
<link rel="preconnect" href="https://fonts.googleapis.com" />
3+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
4+
<link
5+
href="https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400;1,700&family=Bricolage+Grotesque:opsz,wght@12..96,200..800&family=IBM+Plex+Mono:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap"
6+
rel="stylesheet"
7+
/>
8+
9+
<style>
10+
:root {
11+
--font-inter: 'Inter', sans-serif;
12+
--font-jetbrains: 'JetBrains Mono', monospace;
13+
--font-space-grotesk: 'Space Grotesk', sans-serif;
14+
--font-ibm-plex-sans: 'IBM Plex Sans', sans-serif;
15+
--font-ibm-plex-mono: 'IBM Plex Mono', monospace;
16+
--font-bricolage: 'Bricolage Grotesque', sans-serif;
17+
--font-atkinson: 'Atkinson Hyperlegible', sans-serif;
18+
}
19+
</style>

0 commit comments

Comments
 (0)