diff --git a/.github/workflows/deploy-storybook.yaml b/.github/workflows/deploy-storybook.yaml new file mode 100644 index 0000000..71fa3bf --- /dev/null +++ b/.github/workflows/deploy-storybook.yaml @@ -0,0 +1,43 @@ +name: Build and Publish storybook to GitHub Pages + +on: + push: + branches: + - "main" +jobs: + deploy: + environment: + name: github-pages + url: ${{ steps.build-publish.outputs.page_url }} + + permissions: + pages: write + id-token: write + + runs-on: ubuntu-latest + strategy: + matrix: + node-version: ["22.12.0"] + + steps: + - uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 + with: + run_install: | + args: [ --force ] + + - name: Set Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: pnpm + + - name: Build and publish + id: build-publish + uses: bitovi/github-actions-storybook-to-github-pages@v1.0.3 + with: + checkout: false + path: storybook/storybook-static + install_command: echo Already done + build_command: pnpm build:storybook diff --git a/.github/workflows/npm-publish.yaml b/.github/workflows/npm-publish.yaml new file mode 100644 index 0000000..b6bb6bb --- /dev/null +++ b/.github/workflows/npm-publish.yaml @@ -0,0 +1,45 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages + +name: Node.js Package + +on: + push: + tags: + - v* + + +jobs: + publish-npm: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + run_install: | + args: [ --force ] + + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: '22.12.0' + registry-url: https://registry.npmjs.org/ + scope: '@diamondlightsource' + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build + run: pnpm build + + - name: Test + run: pnpm jest + + - name: Publish + run: pnpm publish -r --no-git-checks --access public + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN_DLS}} diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml new file mode 100644 index 0000000..def4ee2 --- /dev/null +++ b/.github/workflows/test-build.yaml @@ -0,0 +1,39 @@ +# This workflow will install dependencies, run tests and lint + +name: Run CI + +on: + push: + branches: [ "main" ] + tags: ['v*'] + pull_request: + types: [ opened, synchronize ] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node-version: ["22.12.0"] + + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + uses: pnpm/action-setup@v4 + with: + run_install: | + args: [ --force ] + + - name: Set Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: pnpm + + - name: Run Typescript tests and lint client code + run: | + pnpm lint + pnpm jest + pnpm build diff --git a/.storybook/ThemeSwapper.tsx b/.storybook/ThemeSwapper.tsx index 206b375..71b36bb 100644 --- a/.storybook/ThemeSwapper.tsx +++ b/.storybook/ThemeSwapper.tsx @@ -1,27 +1,38 @@ -import {useColorScheme} from "@mui/material"; +import { useColorScheme } from "@mui/material"; import * as React from "react"; -import {useEffect} from "react"; +import { useEffect } from "react"; + +interface Globals { + theme: string; + themeMode: string; +} + +interface Context { + globals: Globals; +} export interface ThemeSwapperProps { - context: any, + context: Context; children: React.ReactNode; } -export const TextLight = 'Mode: Light' -export const TextDark = 'Mode: Dark' +export const TextLight = "Mode: Light"; +export const TextDark = "Mode: Dark"; -const ThemeSwapper = ( {context, children}: ThemeSwapperProps ) => { +const ThemeSwapper = ({ context, children }: ThemeSwapperProps) => { const { mode, setMode } = useColorScheme(); //if( !mode ) return - + useEffect(() => { const selectedThemeMode = context.globals.themeMode || TextLight; - setMode((selectedThemeMode == TextLight) ? "light" : "dark") - },[context.globals.themeMode]); - - return
Paragraph