Skip to content

Commit 0682fd9

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

8 files changed

Lines changed: 52 additions & 177 deletions

File tree

README.md

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# react-intersection-observer
22

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]
3+
[![Version Badge](https://img.shields.io/npm/v/react-intersection-observer.svg)](https://npmjs.org/package/react-intersection-observer)
4+
[![Test](https://github.com/thebuilder/react-intersection-observer/workflows/Test/badge.svg)](https://github.com/thebuilder/react-intersection-observer/actions?query=workflow%3ATest)
5+
[![License](http://img.shields.io/npm/l/react-intersection-observer.svg)](LICENSE)
6+
[![Downloads](http://img.shields.io/npm/dm/react-intersection-observer.svg)](http://npm-stat.com/charts.html?package=react-intersection-observer)
77
![npm package minimized gzipped size](https://img.shields.io/bundlejs/size/react-intersection-observer?exports=InView%2C%20useOnInView%2C%20useInView&externals=react&format=both)
88

99
A React implementation of the [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)
@@ -259,9 +259,9 @@ extend the `IntersectionObserverEntry` with the `isVisible` boolean.
259259
The `IntersectionObserver` itself is just a simple but powerful tool. Here's a
260260
few ideas for how you can use it.
261261
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
262+
- [Lazy image load](apps/docs/docs/guides/recipes.mdx#lazy-image-loading)
263+
- [Trigger animations](apps/docs/docs/guides/recipes.mdx#scroll-triggered-animation)
264+
- [Track impressions](apps/docs/docs/guides/recipes.mdx#track-an-impression) _(Google Analytics, Tag
265265
Manager, etc.)_
266266
267267
## FAQ
@@ -375,7 +375,7 @@ globally, alongside either `jest.fn` or `vi.fn`.
375375
376376
See the instructions for [Vitest](#vitest). You should be able to use a similar
377377
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.
378+
copy the code from [test-utils.ts](packages/react-intersection-observer/src/test-utils.ts), and make your own version.
379379
380380
### Fallback Behavior
381381
@@ -574,13 +574,3 @@ order to destroy the observer again.
574574
> You most likely won't need this, but it can be useful if you
575575
> need to handle IntersectionObservers outside React, or need full control over
576576
> 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: 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.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: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
import { Markdown } from '@storybook/addon-docs/blocks';
2-
import Readme from '../../../README.md?raw';
1+
import logoSvg from '../../docs/public/logo.svg?raw';
32

4-
<Markdown>{Readme}</Markdown>
3+
<span
4+
aria-hidden="true"
5+
className="storybook-intro-logo"
6+
dangerouslySetInnerHTML={{ __html: logoSvg }}
7+
/>
8+
9+
# React Intersection Observer
10+
11+
A React implementation of the [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API).
12+
13+
Use the stories in this library to explore the `InView` component, `useInView`, and `useOnInView` in isolation.
14+
15+
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.

apps/storybook/styles.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
11
@import "tailwindcss";
2+
3+
.storybook-intro-logo {
4+
display: block;
5+
}
6+
7+
.storybook-intro-logo > svg {
8+
height: 4rem;
9+
width: 4rem;
10+
}

docs/Recipes.md

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

0 commit comments

Comments
 (0)