Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
root: true,
extends: ["custom"],
extends: ["custom", "plugin:storybook/recommended"],
};
27 changes: 27 additions & 0 deletions apps/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

*storybook.log
storybook-static
40 changes: 40 additions & 0 deletions apps/docs/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// This file has been automatically migrated to valid ESM format by Storybook.
import { createRequire } from "node:module";
import type { StorybookConfig } from "@storybook/react-vite";
import { dirname, join } from "path";
import { mergeConfig } from "vite";

const require = createRequire(import.meta.url);
const gql = require("vite-plugin-simple-gql").default;

/**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/
function getAbsolutePath(value: string): any {
return dirname(require.resolve(join(value, "package.json")));
}
const config: StorybookConfig = {
stories: [
"../src/**/*.stories.@(js|jsx|mjs|ts|tsx)",
"../../../packages/ui/src/**/*.stories.@(js|jsx|mjs|ts|tsx)",
"../../../packages/sections/src/**/*.stories.@(js|jsx|mjs|ts|tsx)",
],

addons: [],

framework: {
name: getAbsolutePath("@storybook/react-vite"),
options: {},
},

async viteFinal(config) {
return mergeConfig(config, {
plugins: [gql()],
esbuild: {
jsxInject: `import React from 'react'`,
},
});
},
};
export default config;
17 changes: 17 additions & 0 deletions apps/docs/.storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<script>
// Set window configuration before any React code loads
// This is required by @ot/config theme used by UI components
window.configProfile = {
primaryColor: '#3489ca',
secondaryColor: '#18405e',
isPartnerPreview: false,
partnerDataTypes: [],
};

// Set other required config values
// Using production API endpoint as it has CORS enabled for Storybook
window.configUrlApi = 'https://api.platform.opentargets.org/api/v4/graphql';
window.configOTAiApi = 'https://ai.platform.opentargets.org';
window.configGeneticsPortalUrl = 'https://genetics.opentargets.org';
window.gitVersion = 'storybook-dev';
</script>
98 changes: 98 additions & 0 deletions apps/docs/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { createTheme } from "@mui/material/styles";
import { getConfig } from "@ot/config";
import type { Preview } from "@storybook/react-vite";
import { darken, lighten } from "polished";
import React from "react";
import { MemoryRouter } from "react-router-dom";
import { OTApolloProvider, ThemeProvider } from "ui";

// Create theme for Storybook - matching the @ot/config theme structure
const PRIMARY = "#3489ca";
const SECONDARY = "#18405e";

const theme = createTheme({
shape: {
borderRadius: 2,
},
typography: {
fontFamily: '"Inter", sans-serif',
},
palette: {
primary: {
light: lighten(0.2, PRIMARY),
main: PRIMARY,
dark: darken(0.2, PRIMARY),
contrastText: "#fff",
},
secondary: {
light: lighten(0.2, SECONDARY),
main: SECONDARY,
dark: darken(0.2, SECONDARY),
contrastText: "#fff",
},
text: {
primary: "#5A5F5F",
},
},
components: {
MuiButton: {
defaultProps: {
disableRipple: true,
},
styleOverrides: {
root: {
border: "1px solid",
padding: "6px 12px",
minWidth: "32px",
minHeight: "32px",
height: "32px",
textTransform: "none",
color: "#5A5F5F",
borderColor: "rgb(196,196,196)",
},
},
},
MuiTab: {
defaultProps: {
disableRipple: true,
},
styleOverrides: {
root: {
textTransform: "none",
},
},
},
},
});

// Get config from window (set in preview-head.html)
const config = getConfig();

const preview: Preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
decorators: [
(Story) =>
React.createElement(
MemoryRouter,
{ initialEntries: ["/"] },
React.createElement(OTApolloProvider, {
config,
// biome-ignore lint/correctness/noChildrenProp: TODO: fix this
children: React.createElement(ThemeProvider, {
theme,
// biome-ignore lint/correctness/noChildrenProp: TODO: fix this
children: React.createElement(Story),
}),
})
),
],
};

export default preview;
73 changes: 73 additions & 0 deletions apps/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## React Compiler

The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:

```js
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...

// Remove tseslint.configs.recommended and replace with this
tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
tseslint.configs.stylisticTypeChecked,

// Other configs...
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```

You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:

```js
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'

export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```
31 changes: 31 additions & 0 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "docs",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "storybook dev -p 6006",
"build": "storybook build"
},
"dependencies": {
"@mui/material": "^5.14.1",
"@ot/config": "*",
"polished": "^2.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "6.28.0",
"ui": "*"
},
"devDependencies": {
"@storybook/addon-docs": "10.0.6",
"@storybook/react-vite": "^10.0.6",
"@types/node": "^24.6.0",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@vitejs/plugin-react": "^5.0.4",
"storybook": "^10.0.6",
"typescript": "~5.9.3",
"vite": "^7.1.7",
"vite-plugin-simple-gql": "^0.5.0"
}
}
1 change: 1 addition & 0 deletions apps/docs/src/assets/react.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions apps/docs/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2022",
"useDefineForClassFields": true,
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"module": "ESNext",
"types": ["vite/client"],
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["src"]
}
4 changes: 4 additions & 0 deletions apps/docs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"files": [],
"references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" }]
}
26 changes: 26 additions & 0 deletions apps/docs/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2023",
"lib": ["ES2023"],
"module": "ESNext",
"types": ["node"],
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["vite.config.ts"]
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"dev": "turbo run dev --parallel",
"dev:platform": "turbo run dev --filter=platform",
"build:platform": "turbo run build --filter=platform",
"dev:docs": "turbo run dev --filter=docs",
"build:docs": "turbo run build --filter=docs",
"dev:platform:ppp": "turbo run dev-ppp --filter=platform",
"build:platform:ppp": "turbo run build-ppp --filter=platform",
"lint": "npx biome check .",
Expand Down
1 change: 1 addition & 0 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"uuid": "^9.0.1"
},
"devDependencies": {
"@storybook/react": "^10.0.6",
"@types/d3-format": "^3.0.1",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
Expand Down
Loading