Skip to content

Commit e8d62da

Browse files
kubeclaude
andcommitted
FE-518: Add Storybook and update build/lint setup for refractive
Replace the playground/ dev server with Storybook for component development and visual testing. - Remove playground/ folder and its Vite dev server setup - Add Storybook 9 with @storybook/react-vite framework - Create playground story showing refractive glass effect over scrollable article content - Simplify vite.config.ts for lib-only builds (Storybook handles dev) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 46e4caf commit e8d62da

12 files changed

Lines changed: 112 additions & 123 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { StorybookConfig } from "@storybook/react-vite";
2+
3+
const config: StorybookConfig = {
4+
framework: "@storybook/react-vite",
5+
stories: ["../stories/**/*.stories.@(ts|tsx)"],
6+
};
7+
8+
export default config;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { Preview } from "@storybook/react";
2+
3+
const preview: Preview = {
4+
parameters: {
5+
layout: "fullscreen",
6+
},
7+
};
8+
9+
export default preview;

libs/@hashintel/refractive/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,25 @@
2323
"types": "./dist/index.d.ts",
2424
"scripts": {
2525
"build": "vite build",
26-
"dev": "vite",
26+
"dev": "storybook dev -p 6006",
2727
"dev:lib": "vite build --watch",
2828
"fix:eslint": "eslint --fix .",
2929
"lint:eslint": "eslint --report-unused-disable-directives .",
3030
"lint:tsc": "tsc --noEmit",
31-
"prepublishOnly": "yarn build"
31+
"prepublishOnly": "yarn build",
32+
"build-storybook": "storybook build"
3233
},
3334
"devDependencies": {
3435
"@local/eslint": "workspace:*",
3536
"@local/tsconfig": "workspace:*",
37+
"@storybook/react": "9.1.13",
38+
"@storybook/react-vite": "9.1.13",
3639
"@types/react": "19.2.7",
3740
"@types/react-dom": "19.2.3",
3841
"@vitejs/plugin-react": "5.0.4",
3942
"babel-plugin-react-compiler": "1.0.0",
4043
"eslint": "9.39.3",
44+
"storybook": "9.1.19",
4145
"typescript": "5.9.3",
4246
"vite": "7.1.11",
4347
"vite-plugin-dts": "4.5.4"

libs/@hashintel/refractive/playground/index.html

Lines changed: 0 additions & 17 deletions
This file was deleted.

libs/@hashintel/refractive/playground/main.tsx

Lines changed: 0 additions & 17 deletions
This file was deleted.

libs/@hashintel/refractive/playground/playground.tsx

Lines changed: 0 additions & 37 deletions
This file was deleted.

libs/@hashintel/refractive/playground/style.css

Lines changed: 0 additions & 9 deletions
This file was deleted.

libs/@hashintel/refractive/playground/example-article.tsx renamed to libs/@hashintel/refractive/stories/example-article.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const ExampleArticle: React.FC = () => {
6363

6464
<img
6565
src="https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?q=80&w=2728&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
66-
alt="Something"
66+
alt="Abstract colorful shapes"
6767
style={{
6868
width: "100%",
6969
height: "400px",
@@ -137,7 +137,7 @@ export const ExampleArticle: React.FC = () => {
137137

138138
<img
139139
src="https://images.unsplash.com/photo-1496096265110-f83ad7f96608?q=80&w=2670&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
140-
alt="Something"
140+
alt="Light refraction through prism"
141141
style={{
142142
width: "100%",
143143
height: "400px",
@@ -180,7 +180,7 @@ export const ExampleArticle: React.FC = () => {
180180

181181
<img
182182
src="https://images.unsplash.com/photo-1579547621113-e4bb2a19bdd6?q=80&w=1239&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
183-
alt="Something"
183+
alt="Scientific equipment"
184184
style={{
185185
width: "100%",
186186
height: "400px",
@@ -230,7 +230,7 @@ export const ExampleArticle: React.FC = () => {
230230

231231
<img
232232
src="https://images.unsplash.com/photo-1637789594401-5a0dac0d3e36?q=80&w=1294&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
233-
alt="Something"
233+
alt="Natural light patterns"
234234
style={{
235235
width: "100%",
236236
height: "400px",
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
3+
import { CONVEX } from "../src/helpers/surface-equations";
4+
import { refractive } from "../src/hoc/refractive";
5+
import { ExampleArticle } from "./example-article";
6+
7+
const refraction = {
8+
blur: 2,
9+
radius: 20,
10+
specularOpacity: 0.9,
11+
bezelWidth: 30,
12+
glassThickness: 70,
13+
refractiveIndex: 1.5,
14+
bezelHeightFn: CONVEX,
15+
specularAngle: 2,
16+
};
17+
18+
const GlassOverArticle = () => (
19+
<div style={{ position: "relative" }}>
20+
<refractive.div
21+
style={{
22+
position: "sticky",
23+
top: 100,
24+
marginLeft: 50,
25+
width: 300,
26+
height: 200,
27+
resize: "both",
28+
overflow: "auto",
29+
backgroundColor: "rgba(255, 255, 255, 0.6)",
30+
display: "flex",
31+
alignItems: "center",
32+
justifyContent: "center",
33+
zIndex: 1,
34+
}}
35+
refraction={refraction}
36+
>
37+
Refractive Glass
38+
</refractive.div>
39+
40+
<ExampleArticle />
41+
</div>
42+
);
43+
44+
const meta = {
45+
title: "Playground",
46+
component: GlassOverArticle,
47+
} satisfies Meta<typeof GlassOverArticle>;
48+
49+
export default meta;
50+
51+
type Story = StoryObj<typeof meta>;
52+
53+
export const Default: Story = {};

libs/@hashintel/refractive/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"noEmit": true,
1010
"isolatedModules": true
1111
},
12-
"include": ["src/**/*", "playground/**/*"],
12+
"include": ["src/**/*", "stories/**/*"],
1313
"exclude": [
1414
"node_modules",
1515
"dist",

0 commit comments

Comments
 (0)