Skip to content

Commit fcb8fbf

Browse files
committed
Simplify and brand Storybook introduction
1 parent c8a9566 commit fcb8fbf

9 files changed

Lines changed: 76 additions & 179 deletions

File tree

‎README.md‎

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
# react-intersection-observer
2-
3-
[![Version Badge][npm-version-svg]][package-url]
4-
[![Test][test-image]][test-url]
5-
[![License][license-image]][license-url]
6-
[![Downloads][downloads-image]][downloads-url]
1+
<h1>
2+
<img src="apps/docs/public/logo-horizontal.svg" alt="React Intersection Observer" width="290" />
3+
</h1>
4+
5+
[![Version Badge](https://img.shields.io/npm/v/react-intersection-observer.svg)](https://npmjs.org/package/react-intersection-observer)
6+
[![Test](https://github.com/thebuilder/react-intersection-observer/workflows/Test/badge.svg)](https://github.com/thebuilder/react-intersection-observer/actions?query=workflow%3ATest)
7+
[![License](http://img.shields.io/npm/l/react-intersection-observer.svg)](LICENSE)
8+
[![Downloads](http://img.shields.io/npm/dm/react-intersection-observer.svg)](http://npm-stat.com/charts.html?package=react-intersection-observer)
79
![npm package minimized gzipped size](https://img.shields.io/bundlejs/size/react-intersection-observer?exports=InView%2C%20useOnInView%2C%20useInView&externals=react&format=both)
810

911
A React implementation of the [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)
@@ -259,9 +261,9 @@ extend the `IntersectionObserverEntry` with the `isVisible` boolean.
259261
The `IntersectionObserver` itself is just a simple but powerful tool. Here's a
260262
few ideas for how you can use it.
261263
262-
- [Lazy image load](docs/Recipes.md#lazy-image-load)
263-
- [Trigger animations](docs/Recipes.md#trigger-animations)
264-
- [Track impressions](docs/Recipes.md#track-impressions) _(Google Analytics, Tag
264+
- [Lazy image load](apps/docs/docs/guides/recipes.mdx#lazy-image-loading)
265+
- [Trigger animations](apps/docs/docs/guides/recipes.mdx#scroll-triggered-animation)
266+
- [Track impressions](apps/docs/docs/guides/recipes.mdx#track-an-impression) _(Google Analytics, Tag
265267
Manager, etc.)_
266268
267269
## FAQ
@@ -375,7 +377,7 @@ globally, alongside either `jest.fn` or `vi.fn`.
375377
376378
See the instructions for [Vitest](#vitest). You should be able to use a similar
377379
setup/reset code, adapted to the testing library you are using. Failing that,
378-
copy the code from [test-utils.ts][test-utils-url], and make your own version.
380+
copy the code from [test-utils.ts](packages/react-intersection-observer/src/test-utils.ts), and make your own version.
379381
380382
### Fallback Behavior
381383
@@ -574,13 +576,3 @@ order to destroy the observer again.
574576
> You most likely won't need this, but it can be useful if you
575577
> need to handle IntersectionObservers outside React, or need full control over
576578
> how instances are created.
577-
578-
[package-url]: https://npmjs.org/package/react-intersection-observer
579-
[npm-version-svg]: https://img.shields.io/npm/v/react-intersection-observer.svg
580-
[license-image]: http://img.shields.io/npm/l/react-intersection-observer.svg
581-
[license-url]: LICENSE
582-
[downloads-image]: http://img.shields.io/npm/dm/react-intersection-observer.svg
583-
[downloads-url]: http://npm-stat.com/charts.html?package=react-intersection-observer
584-
[test-image]: https://github.com/thebuilder/react-intersection-observer/workflows/Test/badge.svg
585-
[test-url]: https://github.com/thebuilder/react-intersection-observer/actions?query=workflow%3ATest
586-
[test-utils-url]: https://github.com/thebuilder/react-intersection-observer/blob/master/src/test-utils.ts
Lines changed: 20 additions & 0 deletions
Loading

‎apps/storybook/.storybook/main.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,29 @@
11
import type { StorybookConfig } from "@storybook/react-vite";
22

3+
const favicon = `<link rel="icon" type="image/svg+xml" href="/favicon.svg" />`;
4+
35
const config: StorybookConfig = {
46
framework: "@storybook/react-vite",
7+
staticDirs: [{ from: "../../docs/public", to: "/" }],
58
stories: [
69
"../stories/**/*.mdx",
710
"../stories/**/*.@(story|stories).@(ts|tsx)",
811
],
912
addons: ["@storybook/addon-docs", "@storybook/addon-vitest"],
13+
// Storybook's generated brandImage rule uses !important, so this needs to be
14+
// appended after it and match that priority.
15+
managerHead: (head) => `
16+
${head}
17+
${favicon}
18+
<style>
19+
img[alt="React Intersection Observer"] {
20+
width: 100%;
21+
height: auto;
22+
max-width: 100% !important;
23+
}
24+
</style>
25+
`,
26+
previewHead: (head) => `${head}${favicon}`,
1027
core: {
1128
builder: "@storybook/builder-vite",
1229
},
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { addons } from "storybook/manager-api";
2-
import { themes } from "storybook/theming";
2+
import docsLogo from "../../docs/public/logo-horizontal.svg";
3+
import { storybookTheme } from "./theme";
34

45
addons.setConfig({
56
theme: {
6-
...themes.dark,
7-
brandTitle: "React IntersectionObserver",
8-
brandUrl: "https://github.com/thebuilder/react-intersection-observer",
7+
...storybookTheme,
8+
brandImage: docsLogo,
9+
brandTitle: "React Intersection Observer",
10+
brandUrl: "https://react-intersection-observer.vercel.app/",
911
},
1012
});
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import { themes } from "storybook/theming";
1+
import { storybookTheme } from "./theme";
22
import "../styles.css";
33

44
export const parameters = {
55
controls: {
66
expanded: true,
77
},
8-
theme: {
9-
...themes.dark,
10-
},
8+
theme: storybookTheme,
119
docs: {
12-
theme: themes.dark,
10+
theme: storybookTheme,
1311
},
1412
};

‎apps/storybook/.storybook/theme.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { themes } from "storybook/theming";
2+
3+
// sRGB equivalent of the docs light-mode accent: oklch(0.6 0.15 290).
4+
// Storybook's theme engine does not support oklch() values.
5+
const docsAccent = "#816dd2";
6+
7+
export const storybookTheme = {
8+
...themes.light,
9+
barSelectedColor: docsAccent,
10+
colorPrimary: docsAccent,
11+
colorSecondary: docsAccent,
12+
};

‎apps/storybook/stories/Intro.mdx‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { Markdown } from '@storybook/addon-docs/blocks';
2-
import Readme from '../../../README.md?raw';
1+
# Explore the API
32

4-
<Markdown>{Readme}</Markdown>
3+
A React implementation of the [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API).
4+
5+
Use the stories in this library to explore the `InView` component, `useInView`, and `useOnInView` in isolation.
6+
7+
For installation, API reference, guides, and recipes, visit the [documentation site](https://react-intersection-observer.vercel.app/).

‎apps/storybook/stories/Recipes.mdx‎

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

‎docs/Recipes.md‎

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

0 commit comments

Comments
 (0)